evt-messaging-fixtures 0.0.0.0 → 0.0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/messaging/fixtures.rb +8 -2
- data/lib/messaging/fixtures/controls.rb +9 -0
- data/lib/messaging/fixtures/controls/entity.rb +76 -0
- data/lib/messaging/fixtures/controls/event.rb +89 -0
- data/lib/messaging/fixtures/controls/handler.rb +107 -0
- data/lib/messaging/fixtures/controls/id.rb +7 -0
- data/lib/messaging/fixtures/controls/message.rb +67 -0
- data/lib/messaging/fixtures/controls/sequence.rb +11 -0
- data/lib/messaging/fixtures/controls/store.rb +28 -0
- data/lib/messaging/fixtures/controls/time.rb +7 -0
- data/lib/messaging/fixtures/defaults.rb +15 -0
- data/lib/messaging/fixtures/handler.rb +102 -0
- data/lib/messaging/fixtures/input_message.rb +52 -0
- data/lib/messaging/fixtures/write.rb +90 -0
- data/lib/messaging/fixtures/written_message.rb +84 -0
- metadata +21 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 269b46f51f2dd3d63cd7f1655e281cf702300d0a9044b69d96dbc4a26eb7797b
|
4
|
+
data.tar.gz: 2d45a9b841af0036cd172070448ee5dd00caa27137e6ccc31b8b1a11914ced71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 708b275d3d264c5f6d43ab01db849cabae52cb9cf7b10baee26f985db40e9209c62e68a4d6d6c453a1e22135adf6b58c70f21e3a84b6084427bacd64db691d9a
|
7
|
+
data.tar.gz: 96c40f8d25a8ec8d33acef440b81d815ea2fa2045562e4843ba2a1ff08a94878ff634db7784b160a2e9b0d733359df779dd0d5b3a0db620e7afc574ee0891750
|
data/lib/messaging/fixtures.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'schema/fixtures'
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'entity_store'
|
4
|
+
|
5
|
+
require 'messaging/fixtures/defaults'
|
6
|
+
require 'messaging/fixtures/input_message'
|
7
|
+
require 'messaging/fixtures/written_message'
|
8
|
+
require 'messaging/fixtures/write'
|
9
|
+
require 'messaging/fixtures/handler'
|
@@ -1 +1,10 @@
|
|
1
1
|
require 'messaging/controls'
|
2
|
+
|
3
|
+
require 'messaging/fixtures/controls/id'
|
4
|
+
require 'messaging/fixtures/controls/time'
|
5
|
+
require 'messaging/fixtures/controls/message'
|
6
|
+
require 'messaging/fixtures/controls/event'
|
7
|
+
require 'messaging/fixtures/controls/sequence'
|
8
|
+
require 'messaging/fixtures/controls/entity'
|
9
|
+
require 'messaging/fixtures/controls/store'
|
10
|
+
require 'messaging/fixtures/controls/handler'
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Messaging
|
2
|
+
module Fixtures
|
3
|
+
module Controls
|
4
|
+
module Entity
|
5
|
+
class Example
|
6
|
+
include Schema::DataStructure
|
7
|
+
|
8
|
+
attribute :id, String
|
9
|
+
attribute :alternate_condition, Boolean, default: false
|
10
|
+
attribute :sequence, Integer
|
11
|
+
|
12
|
+
alias :alternate_condition? :alternate_condition
|
13
|
+
|
14
|
+
def processed?(message_sequence)
|
15
|
+
return false if sequence.nil?
|
16
|
+
|
17
|
+
message_sequence <= sequence
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.example(sequence: nil)
|
22
|
+
sequence ||= self.sequence
|
23
|
+
|
24
|
+
some_entity = Example.build
|
25
|
+
|
26
|
+
some_entity.id = id
|
27
|
+
some_entity.sequence = sequence
|
28
|
+
|
29
|
+
some_entity
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.id
|
33
|
+
ID.example(increment: id_increment)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.id_increment
|
37
|
+
11
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.amount
|
41
|
+
1
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.sequence
|
45
|
+
Event.sequence
|
46
|
+
end
|
47
|
+
|
48
|
+
module New
|
49
|
+
def self.example
|
50
|
+
Entity::Example.new
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
module Identified
|
55
|
+
def self.example
|
56
|
+
example = New.example
|
57
|
+
|
58
|
+
example.id = Entity.id
|
59
|
+
|
60
|
+
example
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
module Sequenced
|
65
|
+
def self.example
|
66
|
+
example = Identified.example
|
67
|
+
|
68
|
+
example.sequence = Entity.sequence
|
69
|
+
|
70
|
+
example
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Messaging
|
2
|
+
module Fixtures
|
3
|
+
module Controls
|
4
|
+
module Event
|
5
|
+
def self.example
|
6
|
+
output = Output.new
|
7
|
+
|
8
|
+
output.example_id = example_id
|
9
|
+
output.amount = amount
|
10
|
+
output.time = time
|
11
|
+
output.processed_time = processed_time
|
12
|
+
output.sequence = sequence
|
13
|
+
|
14
|
+
output.metadata = metadata
|
15
|
+
|
16
|
+
output
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.example_id
|
20
|
+
Entity.id
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.amount
|
24
|
+
1
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.time
|
28
|
+
Time::Effective.example
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.processed_time
|
32
|
+
Time::Processed.example
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.sequence
|
36
|
+
Message::Metadata.global_position + 1
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.metadata
|
40
|
+
Metadata.example
|
41
|
+
end
|
42
|
+
|
43
|
+
module Metadata
|
44
|
+
def self.example
|
45
|
+
metadata = Messaging::Message::Metadata.new
|
46
|
+
|
47
|
+
metadata.causation_message_stream_name = causation_message_stream_name
|
48
|
+
metadata.causation_message_position = causation_message_position
|
49
|
+
metadata.causation_message_global_position = causation_message_global_position
|
50
|
+
|
51
|
+
metadata
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.causation_message_stream_name
|
55
|
+
Message::Metadata.stream_name
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.causation_message_position
|
59
|
+
Message::Metadata.position
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.causation_message_global_position
|
63
|
+
Message::Metadata.global_position
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class Output
|
68
|
+
include Messaging::Message
|
69
|
+
|
70
|
+
attribute :example_id, String
|
71
|
+
attribute :amount, Integer
|
72
|
+
attribute :time, String
|
73
|
+
attribute :processed_time, String
|
74
|
+
attribute :sequence, Integer
|
75
|
+
end
|
76
|
+
|
77
|
+
class AlternateOutput
|
78
|
+
include Messaging::Message
|
79
|
+
|
80
|
+
attribute :example_id, String
|
81
|
+
attribute :amount, Integer
|
82
|
+
attribute :time, String
|
83
|
+
attribute :processed_time, String
|
84
|
+
attribute :sequence, Integer
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module Messaging
|
2
|
+
module Fixtures
|
3
|
+
module Controls
|
4
|
+
module Handler
|
5
|
+
def self.example
|
6
|
+
Example.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.noop
|
10
|
+
Noop.new
|
11
|
+
end
|
12
|
+
|
13
|
+
class Example
|
14
|
+
include Messaging::Handle
|
15
|
+
include Log::Dependency
|
16
|
+
include Messaging::StreamName
|
17
|
+
|
18
|
+
dependency :store, Controls::Store::Example
|
19
|
+
dependency :write, Messaging::Write
|
20
|
+
dependency :clock, Clock::UTC
|
21
|
+
dependency :identifier, Identifier::UUID::Random
|
22
|
+
|
23
|
+
category :example
|
24
|
+
|
25
|
+
handle Controls::Message::Input do |input|
|
26
|
+
example_id = input.example_id
|
27
|
+
|
28
|
+
example, version = store.fetch(example_id, include: :version)
|
29
|
+
|
30
|
+
sequence = input.metadata.global_position
|
31
|
+
|
32
|
+
if example.processed?(sequence)
|
33
|
+
logger.info(tag: :ignored) { "Input message ignored (Message: #{input.message_type}, Example ID: #{example_id}, Message Sequence: #{sequence}, Entity Sequence: #{example.sequence})" }
|
34
|
+
return
|
35
|
+
end
|
36
|
+
|
37
|
+
time = clock.iso8601
|
38
|
+
stream_name = stream_name(example_id)
|
39
|
+
|
40
|
+
attributes = [
|
41
|
+
:example_id,
|
42
|
+
{ :quantity => :amount },
|
43
|
+
:time,
|
44
|
+
]
|
45
|
+
|
46
|
+
if example.alternate_condition?
|
47
|
+
alternate_output = Controls::Event::AlternateOutput.follow(input, copy: attributes)
|
48
|
+
alternate_output.processed_time = time
|
49
|
+
alternate_output.sequence = sequence
|
50
|
+
|
51
|
+
write.(alternate_output, stream_name, expected_version: version)
|
52
|
+
|
53
|
+
return
|
54
|
+
end
|
55
|
+
|
56
|
+
output = Controls::Event::Output.follow(input, copy: attributes)
|
57
|
+
output.processed_time = time
|
58
|
+
output.sequence = sequence
|
59
|
+
|
60
|
+
write.(output, stream_name, expected_version: version)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class Noop
|
65
|
+
include Messaging::Handle
|
66
|
+
|
67
|
+
def handle(*)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
__END__
|
75
|
+
|
76
|
+
handle Withdraw do |withdraw|
|
77
|
+
account_id = withdraw.account_id
|
78
|
+
|
79
|
+
account, version = store.fetch(account_id, include: :version)
|
80
|
+
|
81
|
+
sequence = withdraw.metadata.global_position
|
82
|
+
|
83
|
+
if account.processed?(sequence)
|
84
|
+
logger.info(tag: :ignored) { "Command ignored (Command: #{withdraw.message_type}, Account ID: #{account_id}, Account Sequence: #{account.sequence}, Withdrawal Sequence: #{sequence})" }
|
85
|
+
return
|
86
|
+
end
|
87
|
+
|
88
|
+
time = clock.iso8601
|
89
|
+
|
90
|
+
stream_name = stream_name(account_id)
|
91
|
+
|
92
|
+
unless account.sufficient_funds?(withdraw.amount)
|
93
|
+
withdrawal_rejected = WithdrawalRejected.follow(withdraw)
|
94
|
+
withdrawal_rejected.time = time
|
95
|
+
withdrawal_rejected.sequence = sequence
|
96
|
+
|
97
|
+
write.(withdrawal_rejected, stream_name, expected_version: version)
|
98
|
+
|
99
|
+
return
|
100
|
+
end
|
101
|
+
|
102
|
+
withdrawn = Withdrawn.follow(withdraw)
|
103
|
+
withdrawn.processed_time = time
|
104
|
+
withdrawn.sequence = sequence
|
105
|
+
|
106
|
+
write.(withdrawn, stream_name, expected_version: version)
|
107
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Messaging
|
2
|
+
module Fixtures
|
3
|
+
module Controls
|
4
|
+
module Message
|
5
|
+
class Input
|
6
|
+
include Messaging::Message
|
7
|
+
|
8
|
+
attribute :example_id, String
|
9
|
+
attribute :quantity, Integer
|
10
|
+
attribute :time, String
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.example
|
14
|
+
input = Input.new
|
15
|
+
|
16
|
+
input.example_id = example_id
|
17
|
+
input.quantity = quantity
|
18
|
+
input.time = time
|
19
|
+
|
20
|
+
input.metadata = metadata
|
21
|
+
|
22
|
+
input
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.example_id
|
26
|
+
Entity.id
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.quantity
|
30
|
+
1
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.time
|
34
|
+
Time::Effective.example
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.metadata
|
38
|
+
Metadata.example
|
39
|
+
end
|
40
|
+
|
41
|
+
module Metadata
|
42
|
+
def self.example
|
43
|
+
metadata = Messaging::Message::Metadata.new
|
44
|
+
|
45
|
+
metadata.stream_name = stream_name
|
46
|
+
metadata.position = position
|
47
|
+
metadata.global_position = global_position
|
48
|
+
|
49
|
+
metadata
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.stream_name
|
53
|
+
"example:command-#{Entity.id}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.position
|
57
|
+
1
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.global_position
|
61
|
+
111
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Messaging
|
2
|
+
module Fixtures
|
3
|
+
module Controls
|
4
|
+
module Store
|
5
|
+
module Projection
|
6
|
+
class Example
|
7
|
+
include EntityProjection
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Reader
|
12
|
+
class Example
|
13
|
+
include MessageStore::Read
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Example
|
18
|
+
include EntityStore
|
19
|
+
|
20
|
+
category :example
|
21
|
+
entity Entity::Example
|
22
|
+
projection Store::Projection::Example
|
23
|
+
reader Store::Reader::Example
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module Messaging
|
2
|
+
module Fixtures
|
3
|
+
class Handler
|
4
|
+
include TestBench::Fixture
|
5
|
+
include Initializer
|
6
|
+
|
7
|
+
def entity_sequence
|
8
|
+
return nil if entity.nil?
|
9
|
+
entity.sequence
|
10
|
+
end
|
11
|
+
|
12
|
+
initializer :handler, :input_message, :entity, :entity_version, :time, :uuid, :action
|
13
|
+
|
14
|
+
def self.build(handler, input_message, entity=nil, entity_version=nil, time: nil, uuid: nil, &action)
|
15
|
+
instance = new(handler, input_message, entity, entity_version, time, uuid, action)
|
16
|
+
|
17
|
+
set_store_entity(handler, entity, entity_version)
|
18
|
+
set_clock_time(handler, time)
|
19
|
+
set_identifier_uuid(handler, uuid)
|
20
|
+
|
21
|
+
instance
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.set_store_entity(handler, entity, entity_version)
|
25
|
+
return if entity.nil?
|
26
|
+
|
27
|
+
handler.store.add(entity.id, entity, entity_version)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.set_clock_time(handler, time)
|
31
|
+
if time.nil?
|
32
|
+
if handler.respond_to?(:clock)
|
33
|
+
handler.clock.now = Defaults.time
|
34
|
+
end
|
35
|
+
else
|
36
|
+
handler.clock.now = time
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.set_identifier_uuid(handler, uuid)
|
41
|
+
if uuid.nil?
|
42
|
+
if handler.respond_to?(:identifier)
|
43
|
+
handler.identifier.set(Defaults.uuid)
|
44
|
+
end
|
45
|
+
else
|
46
|
+
handler.identifier.set(uuid)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def call
|
51
|
+
context "Handler: #{handler.class.name.split('::').last}" do
|
52
|
+
detail "Handler Class: #{handler.class.name}"
|
53
|
+
|
54
|
+
detail "Entity Class: #{entity.class.name}"
|
55
|
+
detail "Entity Data: #{entity&.attributes}"
|
56
|
+
|
57
|
+
handler.(input_message)
|
58
|
+
|
59
|
+
if not action.nil?
|
60
|
+
action.call(self)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def assert_write(message_class, &action)
|
66
|
+
fixture = fixture(Write, handler.write, message_class, &action)
|
67
|
+
|
68
|
+
output_message = fixture.message
|
69
|
+
|
70
|
+
if not output_message.nil?
|
71
|
+
TestBench::Fixture.build(WrittenMessage, output_message, input_message, session: test_session)
|
72
|
+
else
|
73
|
+
Mimic.(WrittenMessage)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def refute_write(message_class=nil)
|
78
|
+
writer = handler.write
|
79
|
+
|
80
|
+
context_title = "No Write"
|
81
|
+
if not message_class.nil?
|
82
|
+
write_telemetry_data = Write.get_data(writer, message_class)
|
83
|
+
written = !write_telemetry_data.nil?
|
84
|
+
context_title = "#{context_title}: #{message_class.message_type}"
|
85
|
+
else
|
86
|
+
written = writer.written?
|
87
|
+
end
|
88
|
+
|
89
|
+
context context_title do
|
90
|
+
detail "Message Class: #{message_class.inspect}"
|
91
|
+
test "Not written" do
|
92
|
+
refute(written)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def assert_input_message(attributes=nil, &action)
|
98
|
+
fixture = fixture(InputMessage, input_message, &action)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Messaging
|
2
|
+
module Fixtures
|
3
|
+
class InputMessage
|
4
|
+
Error = Class.new(RuntimeError)
|
5
|
+
|
6
|
+
include TestBench::Fixture
|
7
|
+
include Initializer
|
8
|
+
|
9
|
+
initializer :input_message, :action
|
10
|
+
|
11
|
+
def self.build(input_message, &action)
|
12
|
+
new(input_message, action)
|
13
|
+
end
|
14
|
+
|
15
|
+
def call
|
16
|
+
input_message_class = input_message.class
|
17
|
+
|
18
|
+
context "Input Message: #{input_message_class.message_type}" do
|
19
|
+
detail "Input Message Class: #{input_message_class.name}"
|
20
|
+
|
21
|
+
if not action.nil?
|
22
|
+
action.call(self)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def assert_attributes_assigned(attribute_names=nil)
|
28
|
+
fixture(
|
29
|
+
Schema::Fixtures::Assignment,
|
30
|
+
input_message,
|
31
|
+
attribute_names,
|
32
|
+
print_title_context: false,
|
33
|
+
attributes_context_name: "Attributes Assigned"
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def assert_metadata_attributes_assigned(attribute_names=nil)
|
38
|
+
attribute_names = [:stream_name, :position, :global_position]
|
39
|
+
|
40
|
+
metadata = input_message.metadata
|
41
|
+
|
42
|
+
fixture(
|
43
|
+
Schema::Fixtures::Assignment,
|
44
|
+
metadata,
|
45
|
+
attribute_names,
|
46
|
+
print_title_context: false,
|
47
|
+
attributes_context_name: "Metadata Attributes Assigned"
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Messaging
|
2
|
+
module Fixtures
|
3
|
+
class Write
|
4
|
+
Error = Class.new(RuntimeError)
|
5
|
+
|
6
|
+
include TestBench::Fixture
|
7
|
+
include Initializer
|
8
|
+
|
9
|
+
initializer :message, :stream_name, :expected_version, :reply_stream_name, :action
|
10
|
+
|
11
|
+
def self.build(writer, message_class, &action)
|
12
|
+
data = get_data(writer, message_class)
|
13
|
+
|
14
|
+
message = data&.message
|
15
|
+
stream_name = data&.stream_name
|
16
|
+
expected_version = data&.expected_version
|
17
|
+
reply_stream_name = data&.reply_stream_name
|
18
|
+
|
19
|
+
new(message, stream_name, expected_version, reply_stream_name, action)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.get_data(writer, message_class)
|
23
|
+
sink = writer.sink
|
24
|
+
|
25
|
+
records = sink.written_records.select do |record|
|
26
|
+
record.data.message.class == message_class
|
27
|
+
end
|
28
|
+
|
29
|
+
if records.length > 1
|
30
|
+
raise Error, "More than one message written (Message Class: #{message_class})"
|
31
|
+
end
|
32
|
+
|
33
|
+
if records.empty?
|
34
|
+
return nil
|
35
|
+
end
|
36
|
+
|
37
|
+
records.first.data
|
38
|
+
end
|
39
|
+
|
40
|
+
def call
|
41
|
+
message_class = message&.class
|
42
|
+
|
43
|
+
context "Write: #{message_class&.message_type || 'nil'}" do
|
44
|
+
detail "Message Class: #{message_class.inspect}"
|
45
|
+
|
46
|
+
written = !message.nil?
|
47
|
+
|
48
|
+
test "Written" do
|
49
|
+
assert(written)
|
50
|
+
end
|
51
|
+
|
52
|
+
return if !written || action.nil?
|
53
|
+
|
54
|
+
if not action.nil?
|
55
|
+
action.call(self)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
message
|
60
|
+
end
|
61
|
+
|
62
|
+
def assert_stream_name(stream_name)
|
63
|
+
test "Stream name" do
|
64
|
+
detail "Stream Name: #{stream_name}"
|
65
|
+
detail "Written Stream Name: #{self.stream_name}"
|
66
|
+
|
67
|
+
assert(stream_name == self.stream_name)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def assert_expected_version(expected_version)
|
72
|
+
test "Expected version" do
|
73
|
+
detail "Expected Version: #{expected_version}"
|
74
|
+
detail "Written Expected Version: #{self.expected_version}"
|
75
|
+
|
76
|
+
assert(expected_version == self.expected_version)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def assert_reply_stream_name(reply_stream_name)
|
81
|
+
test "Reply stream name" do
|
82
|
+
detail "Reply stream Name: #{reply_stream_name}"
|
83
|
+
detail "Written reply stream Name: #{self.reply_stream_name}"
|
84
|
+
|
85
|
+
assert(reply_stream_name == self.reply_stream_name)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Messaging
|
2
|
+
module Fixtures
|
3
|
+
class WrittenMessage
|
4
|
+
Error = Class.new(RuntimeError)
|
5
|
+
|
6
|
+
include TestBench::Fixture
|
7
|
+
include Initializer
|
8
|
+
|
9
|
+
initializer :output_message, :input_message
|
10
|
+
|
11
|
+
def self.build(output_message, input_message)
|
12
|
+
new(output_message, input_message)
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(&action)
|
16
|
+
input_message_class = input_message.class
|
17
|
+
output_message_class = output_message.class
|
18
|
+
|
19
|
+
context "Written Message: #{output_message_class.message_type}" do
|
20
|
+
detail "Input Message Class: #{input_message_class.name}"
|
21
|
+
detail "Written Message Class: #{output_message_class.name}"
|
22
|
+
|
23
|
+
if not action.nil?
|
24
|
+
action.call(self)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def assert_follows
|
30
|
+
input_message_type = input_message.class.message_type
|
31
|
+
output_message_type = output_message.class.message_type
|
32
|
+
|
33
|
+
test "Follows: #{input_message_type}" do
|
34
|
+
detail "#{input_message_type} Stream Name: #{input_message.metadata.stream_name.inspect}"
|
35
|
+
detail "#{output_message_type} Causation Stream Name: #{output_message.metadata.causation_message_stream_name.inspect}"
|
36
|
+
|
37
|
+
detail "#{input_message_type} Position: #{input_message.metadata.position.inspect}"
|
38
|
+
detail "#{output_message_type} Causation Position: #{output_message.metadata.causation_message_position.inspect}"
|
39
|
+
|
40
|
+
detail "#{input_message_type} Global Position: #{input_message.metadata.global_position.inspect}"
|
41
|
+
detail "#{output_message_type} Causation Global Position: #{output_message.metadata.causation_message_global_position.inspect}"
|
42
|
+
|
43
|
+
detail "#{input_message_type} Reply Stream Name: #{input_message.metadata.reply_stream_name.inspect}"
|
44
|
+
detail "#{output_message_type} Reply Stream Name: #{output_message.metadata.reply_stream_name.inspect}"
|
45
|
+
|
46
|
+
assert(output_message.follows?(input_message))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def ___assert_attributes_copied(attribute_names=nil)
|
51
|
+
fixture(
|
52
|
+
Schema::Fixtures::Equality,
|
53
|
+
input_message,
|
54
|
+
output_message,
|
55
|
+
attribute_names,
|
56
|
+
ignore_class: true,
|
57
|
+
title_context_name: "Attributes Copied: #{input_message.class.message_type} => #{output_message.class.message_type}"
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
def assert_attributes_copied(attribute_names=nil)
|
62
|
+
fixture(
|
63
|
+
Schema::Fixtures::Equality,
|
64
|
+
input_message,
|
65
|
+
output_message,
|
66
|
+
attribute_names,
|
67
|
+
ignore_class: true,
|
68
|
+
print_title_context: false,
|
69
|
+
attributes_context_name: "Attributes Copied: #{input_message.class.message_type} => #{output_message.class.message_type}"
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
def assert_attributes_assigned(attribute_names=nil)
|
74
|
+
fixture(
|
75
|
+
Schema::Fixtures::Assignment,
|
76
|
+
output_message,
|
77
|
+
attribute_names,
|
78
|
+
print_title_context: false,
|
79
|
+
attributes_context_name: "Attributes Assigned: #{output_message.class.message_type}"
|
80
|
+
)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-messaging-fixtures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.0.
|
4
|
+
version: 0.0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: evt-
|
14
|
+
name: evt-entity_store
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: evt-schema-fixtures
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -60,11 +60,24 @@ extra_rdoc_files: []
|
|
60
60
|
files:
|
61
61
|
- lib/messaging/fixtures.rb
|
62
62
|
- lib/messaging/fixtures/controls.rb
|
63
|
+
- lib/messaging/fixtures/controls/entity.rb
|
64
|
+
- lib/messaging/fixtures/controls/event.rb
|
65
|
+
- lib/messaging/fixtures/controls/handler.rb
|
66
|
+
- lib/messaging/fixtures/controls/id.rb
|
67
|
+
- lib/messaging/fixtures/controls/message.rb
|
68
|
+
- lib/messaging/fixtures/controls/sequence.rb
|
69
|
+
- lib/messaging/fixtures/controls/store.rb
|
70
|
+
- lib/messaging/fixtures/controls/time.rb
|
71
|
+
- lib/messaging/fixtures/defaults.rb
|
72
|
+
- lib/messaging/fixtures/handler.rb
|
73
|
+
- lib/messaging/fixtures/input_message.rb
|
74
|
+
- lib/messaging/fixtures/write.rb
|
75
|
+
- lib/messaging/fixtures/written_message.rb
|
63
76
|
homepage: https://github.com/eventide-project/messaging-fixtures
|
64
77
|
licenses:
|
65
78
|
- MIT
|
66
79
|
metadata: {}
|
67
|
-
post_install_message:
|
80
|
+
post_install_message:
|
68
81
|
rdoc_options: []
|
69
82
|
require_paths:
|
70
83
|
- lib
|
@@ -79,8 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
92
|
- !ruby/object:Gem::Version
|
80
93
|
version: '0'
|
81
94
|
requirements: []
|
82
|
-
rubygems_version: 3.1.
|
83
|
-
signing_key:
|
95
|
+
rubygems_version: 3.1.2
|
96
|
+
signing_key:
|
84
97
|
specification_version: 4
|
85
98
|
summary: TestBench fixtures for the Messaging library
|
86
99
|
test_files: []
|