evt-messaging-fixtures 1.0.0.0 → 1.1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/messaging/fixtures.rb +1 -1
- data/lib/messaging/fixtures/controls/handler.rb +0 -34
- data/lib/messaging/fixtures/controls/message.rb +8 -0
- data/lib/messaging/fixtures/handler.rb +12 -12
- data/lib/messaging/fixtures/message.rb +9 -8
- data/lib/messaging/fixtures/metadata.rb +6 -6
- data/lib/messaging/fixtures/{write.rb → writer.rb} +9 -14
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85e9f2c72d37fc952f66845c220b61ef07bbbf20b104a349c8b5ac00664e5951
|
4
|
+
data.tar.gz: 1d4dcad3c3c19e475b01539f6086725993051d4449402b2e9ee6e0ea85d174f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f2f55094442e66f12523930363ba14e9b39f08602d3e4869b34e4914301dbe03b78dfc9ad2420b62e26fb5143c69c9b1a11a417c4a30318af49fb25f798a7a8
|
7
|
+
data.tar.gz: d67172e081b097e53d85efb55f894e02f80494222794f7976c79e860c3a0fba931c04fd2af247336099aee160784c2dbdb579af65a511ea220a93b22dc0760e2
|
data/lib/messaging/fixtures.rb
CHANGED
@@ -79,37 +79,3 @@ module Messaging
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
82
|
-
__END__
|
83
|
-
|
84
|
-
handle Withdraw do |withdraw|
|
85
|
-
account_id = withdraw.account_id
|
86
|
-
|
87
|
-
account, version = store.fetch(account_id, include: :version)
|
88
|
-
|
89
|
-
sequence = withdraw.metadata.global_position
|
90
|
-
|
91
|
-
if account.processed?(sequence)
|
92
|
-
logger.info(tag: :ignored) { "Command ignored (Command: #{withdraw.message_type}, Account ID: #{account_id}, Account Sequence: #{account.sequence}, Withdrawal Sequence: #{sequence})" }
|
93
|
-
return
|
94
|
-
end
|
95
|
-
|
96
|
-
time = clock.iso8601
|
97
|
-
|
98
|
-
stream_name = stream_name(account_id)
|
99
|
-
|
100
|
-
unless account.sufficient_funds?(withdraw.amount)
|
101
|
-
withdrawal_rejected = WithdrawalRejected.follow(withdraw)
|
102
|
-
withdrawal_rejected.time = time
|
103
|
-
withdrawal_rejected.sequence = sequence
|
104
|
-
|
105
|
-
write.(withdrawal_rejected, stream_name, expected_version: version)
|
106
|
-
|
107
|
-
return
|
108
|
-
end
|
109
|
-
|
110
|
-
withdrawn = Withdrawn.follow(withdraw)
|
111
|
-
withdrawn.processed_time = time
|
112
|
-
withdrawn.sequence = sequence
|
113
|
-
|
114
|
-
write.(withdrawn, stream_name, expected_version: version)
|
115
|
-
end
|
@@ -11,10 +11,10 @@ module Messaging
|
|
11
11
|
entity.sequence
|
12
12
|
end
|
13
13
|
|
14
|
-
initializer :handler, :input_message, :entity, :entity_version, :clock_time, :identifier_uuid, :
|
14
|
+
initializer :handler, :input_message, :entity, :entity_version, :clock_time, :identifier_uuid, :test_block
|
15
15
|
|
16
|
-
def self.build(handler, input_message, entity=nil, entity_version=nil, clock_time: nil, identifier_uuid: nil, &
|
17
|
-
instance = new(handler, input_message, entity, entity_version, clock_time, identifier_uuid,
|
16
|
+
def self.build(handler, input_message, entity=nil, entity_version=nil, clock_time: nil, identifier_uuid: nil, &test_block)
|
17
|
+
instance = new(handler, input_message, entity, entity_version, clock_time, identifier_uuid, test_block)
|
18
18
|
|
19
19
|
set_store_entity(handler, entity, entity_version)
|
20
20
|
set_clock_time(handler, clock_time)
|
@@ -53,7 +53,7 @@ module Messaging
|
|
53
53
|
context "Handler: #{handler.class.name.split('::').last}" do
|
54
54
|
detail "Handler Class: #{handler.class.name}"
|
55
55
|
|
56
|
-
if
|
56
|
+
if test_block.nil?
|
57
57
|
raise Error, "Handler fixture must be executed with a block"
|
58
58
|
end
|
59
59
|
|
@@ -70,30 +70,30 @@ module Messaging
|
|
70
70
|
|
71
71
|
handler.(input_message)
|
72
72
|
|
73
|
-
|
73
|
+
test_block.call(self)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
def assert_input_message(&
|
77
|
+
def assert_input_message(&test_block)
|
78
78
|
context_name = "Input Message"
|
79
79
|
if not input_message.nil?
|
80
80
|
context_name = "#{context_name}: #{input_message.class.message_type}"
|
81
81
|
end
|
82
82
|
|
83
|
-
fixture(Message, input_message, title_context_name: context_name, &
|
83
|
+
fixture(Message, input_message, title_context_name: context_name, &test_block)
|
84
84
|
end
|
85
85
|
|
86
|
-
def assert_written_message(written_message, &
|
86
|
+
def assert_written_message(written_message, &test_block)
|
87
87
|
context_name = "Written Message"
|
88
88
|
if not written_message.nil?
|
89
89
|
context_name = "#{context_name}: #{written_message.class.message_type}"
|
90
90
|
end
|
91
91
|
|
92
|
-
fixture(Message, written_message, input_message, title_context_name: context_name, &
|
92
|
+
fixture(Message, written_message, input_message, title_context_name: context_name, &test_block)
|
93
93
|
end
|
94
94
|
|
95
|
-
def assert_write(message_class, &
|
96
|
-
fixture = fixture(
|
95
|
+
def assert_write(message_class, &test_block)
|
96
|
+
fixture = fixture(Writer, handler.write, message_class, &test_block)
|
97
97
|
fixture.message
|
98
98
|
end
|
99
99
|
|
@@ -102,7 +102,7 @@ module Messaging
|
|
102
102
|
|
103
103
|
context_name = "No Write"
|
104
104
|
if not message_class.nil?
|
105
|
-
write_telemetry_data =
|
105
|
+
write_telemetry_data = Writer.get_data(writer, message_class)
|
106
106
|
written = !write_telemetry_data.nil?
|
107
107
|
context_name = "#{context_name}: #{message_class.message_type}"
|
108
108
|
else
|
@@ -23,20 +23,20 @@ module Messaging
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def title_context_name
|
26
|
-
@title_context_name ||= "Message"
|
26
|
+
@title_context_name ||= "Message: #{message_type}"
|
27
27
|
end
|
28
28
|
|
29
|
-
initializer :message, :source_message, na(:title_context_name), :
|
29
|
+
initializer :message, :source_message, na(:title_context_name), :test_block
|
30
30
|
|
31
|
-
def self.build(message, source_message=nil, title_context_name: nil, &
|
32
|
-
new(message, source_message, title_context_name,
|
31
|
+
def self.build(message, source_message=nil, title_context_name: nil, &test_block)
|
32
|
+
new(message, source_message, title_context_name, test_block)
|
33
33
|
end
|
34
34
|
|
35
35
|
def call
|
36
36
|
context_name = title_context_name
|
37
37
|
|
38
38
|
context context_name do
|
39
|
-
if
|
39
|
+
if test_block.nil?
|
40
40
|
raise Error, "Message fixture must be executed with a block"
|
41
41
|
end
|
42
42
|
|
@@ -55,7 +55,7 @@ module Messaging
|
|
55
55
|
detail "Source Message Class: #{source_message_class.name}"
|
56
56
|
end
|
57
57
|
|
58
|
-
|
58
|
+
test_block.call(self)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -68,6 +68,7 @@ module Messaging
|
|
68
68
|
attributes_context_name: "Attributes Assigned"
|
69
69
|
)
|
70
70
|
end
|
71
|
+
alias :assert_all_attributes_assigned :assert_attributes_assigned
|
71
72
|
|
72
73
|
def assert_attributes_copied(attribute_names=nil)
|
73
74
|
if source_message.nil?
|
@@ -89,12 +90,12 @@ module Messaging
|
|
89
90
|
)
|
90
91
|
end
|
91
92
|
|
92
|
-
def assert_metadata(&
|
93
|
+
def assert_metadata(&test_block)
|
93
94
|
fixture(
|
94
95
|
Metadata,
|
95
96
|
message.metadata,
|
96
97
|
source_message&.metadata,
|
97
|
-
&
|
98
|
+
&test_block
|
98
99
|
)
|
99
100
|
end
|
100
101
|
|
@@ -6,15 +6,15 @@ module Messaging
|
|
6
6
|
include TestBench::Fixture
|
7
7
|
include Initializer
|
8
8
|
|
9
|
-
initializer :metadata, :source_metadata, :
|
9
|
+
initializer :metadata, :source_metadata, :test_block
|
10
10
|
|
11
|
-
def self.build(metadata, source_metadata=nil, &
|
12
|
-
new(metadata, source_metadata,
|
11
|
+
def self.build(metadata, source_metadata=nil, &test_block)
|
12
|
+
new(metadata, source_metadata, test_block)
|
13
13
|
end
|
14
14
|
|
15
15
|
def call
|
16
16
|
context "Metadata" do
|
17
|
-
if
|
17
|
+
if test_block.nil?
|
18
18
|
raise Error, "Metadata fixture must be executed with a block"
|
19
19
|
end
|
20
20
|
|
@@ -22,7 +22,7 @@ module Messaging
|
|
22
22
|
test "Not nil" do
|
23
23
|
detail "Metadata: nil"
|
24
24
|
|
25
|
-
if not
|
25
|
+
if not test_block.nil?
|
26
26
|
detail "Remaining message tests are skipped"
|
27
27
|
end
|
28
28
|
|
@@ -31,7 +31,7 @@ module Messaging
|
|
31
31
|
return
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
test_block.call(self)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Messaging
|
2
2
|
module Fixtures
|
3
|
-
class
|
3
|
+
class Writer
|
4
4
|
Error = Class.new(RuntimeError)
|
5
5
|
|
6
6
|
include TestBench::Fixture
|
7
7
|
include Initializer
|
8
8
|
|
9
|
-
initializer :message, :stream_name, :expected_version, :reply_stream_name, :
|
9
|
+
initializer :message_class, :message, :stream_name, :expected_version, :reply_stream_name, :test_block
|
10
10
|
|
11
|
-
def self.build(writer, message_class, &
|
11
|
+
def self.build(writer, message_class, &test_block)
|
12
12
|
data = get_data(writer, message_class)
|
13
13
|
|
14
14
|
message = data&.message
|
@@ -16,7 +16,7 @@ module Messaging
|
|
16
16
|
expected_version = data&.expected_version
|
17
17
|
reply_stream_name = data&.reply_stream_name
|
18
18
|
|
19
|
-
new(message, stream_name, expected_version, reply_stream_name,
|
19
|
+
new(message_class, message, stream_name, expected_version, reply_stream_name, test_block)
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.get_data(writer, message_class)
|
@@ -38,15 +38,10 @@ module Messaging
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def call
|
41
|
-
|
42
|
-
|
43
|
-
context_name = 'Write'
|
44
|
-
if not message_class.nil?
|
45
|
-
context_name = "#{context_name}: #{message_class&.message_type}"
|
46
|
-
end
|
41
|
+
context_name = "Write: #{message_class.message_type}"
|
47
42
|
|
48
43
|
context context_name do
|
49
|
-
if
|
44
|
+
if test_block.nil?
|
50
45
|
raise Error, "Write fixture must be executed with a block"
|
51
46
|
end
|
52
47
|
|
@@ -55,16 +50,16 @@ module Messaging
|
|
55
50
|
written = !message.nil?
|
56
51
|
|
57
52
|
test "Written" do
|
58
|
-
if not
|
53
|
+
if not written
|
59
54
|
detail "Remaining message tests are skipped"
|
60
55
|
end
|
61
56
|
|
62
57
|
assert(written)
|
63
58
|
end
|
64
59
|
|
65
|
-
return if
|
60
|
+
return if not written
|
66
61
|
|
67
|
-
|
62
|
+
test_block.call(self)
|
68
63
|
end
|
69
64
|
|
70
65
|
message
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-messaging-fixtures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.2.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-08-
|
11
|
+
date: 2020-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-entity_store
|
@@ -74,12 +74,12 @@ files:
|
|
74
74
|
- lib/messaging/fixtures/handler.rb
|
75
75
|
- lib/messaging/fixtures/message.rb
|
76
76
|
- lib/messaging/fixtures/metadata.rb
|
77
|
-
- lib/messaging/fixtures/
|
77
|
+
- lib/messaging/fixtures/writer.rb
|
78
78
|
homepage: https://github.com/eventide-project/messaging-fixtures
|
79
79
|
licenses:
|
80
80
|
- MIT
|
81
81
|
metadata: {}
|
82
|
-
post_install_message:
|
82
|
+
post_install_message:
|
83
83
|
rdoc_options: []
|
84
84
|
require_paths:
|
85
85
|
- lib
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubygems_version: 3.1.2
|
98
|
-
signing_key:
|
98
|
+
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: TestBench fixtures for the Messaging library
|
101
101
|
test_files: []
|