rsmp_schemer 0.3.2 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5ded20247c8a17c4c9408c1936de71fe1782041241280ea9e0dcc352e67649f
4
- data.tar.gz: 85829fef328b91fa96068d01f6b8410370ec34393a2cf631f67f37c2901c9f8d
3
+ metadata.gz: 5f23ae0165f3b4dc8d68e61df4478eb60871487273f3f17af3a0903373fc889b
4
+ data.tar.gz: 94ebfc23355613e74959648481b6edac1cce6c22a5339c94651f3e86f9e9428f
5
5
  SHA512:
6
- metadata.gz: e670455f64901cb3cff4b9445309f57f143865dbd67a08f628f0d541aa0b1f934914829d7d85f2f4e5c19a8db8968599ca29005c8ab1f7a8522988b4846b3863
7
- data.tar.gz: 1fcabd99fd4dcff846fa372e1f6c928a1edeacfc06a0c25014a676e7c5369052f0b502fc21b91aa6ad504981052f080b053b8c78726bc48ab912e86e701eb25f
6
+ metadata.gz: b17100f32895d3d7542bf93bff1da5a2bfd89ac869c5e9fb77bf9e3cfe3710452448893c96885c1f9e4eb7f3ea06c7ce7860be55969fe9721586a975f01a4b5e
7
+ data.tar.gz: 6025a9a9cf344aa20fdfd728eeb2ea5e8af8c73b694a472201771daa49b022453067e1353888cd854e3bca04e704f41912d0785d10605d402c890ddeef5345d0
data/Gemfile.lock CHANGED
@@ -1,23 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp_schemer (0.3.2)
4
+ rsmp_schemer (0.4.0)
5
5
  json_schemer (~> 0.2.18)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- diff-lcs (1.4.4)
11
- ecma-re-validator (0.3.0)
12
- regexp_parser (~> 2.0)
10
+ diff-lcs (1.5.0)
11
+ ecma-re-validator (0.4.0)
12
+ regexp_parser (~> 2.2)
13
13
  hana (1.3.7)
14
- json_schemer (0.2.18)
14
+ json_schemer (0.2.20)
15
15
  ecma-re-validator (~> 0.3)
16
16
  hana (~> 1.3)
17
17
  regexp_parser (~> 2.0)
18
18
  uri_template (~> 0.7)
19
- rake (13.0.3)
20
- regexp_parser (2.1.1)
19
+ rake (13.0.6)
20
+ regexp_parser (2.2.1)
21
21
  rspec (3.9.0)
22
22
  rspec-core (~> 3.9.0)
23
23
  rspec-expectations (~> 3.9.0)
@@ -35,6 +35,7 @@ GEM
35
35
 
36
36
  PLATFORMS
37
37
  x86_64-darwin-20
38
+ x86_64-darwin-21
38
39
 
39
40
  DEPENDENCIES
40
41
  rake (~> 13.0)
@@ -43,4 +44,4 @@ DEPENDENCIES
43
44
  rspec-expectations (~> 3.9.1)
44
45
 
45
46
  BUNDLED WITH
46
- 2.2.15
47
+ 2.3.5
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSMP
4
4
  module Schemer
5
- VERSION = "0.3.2"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
@@ -0,0 +1 @@
1
+ .DS_Store
@@ -7,49 +7,45 @@
7
7
  "aCId" : { "$ref": "definitions.json#/alarm_code" },
8
8
  "xACId" : { "description" : "External alarm code id", "type" : "string" },
9
9
  "aSp" : {
10
- "description" : "Alarm message variant",
10
+ "description" : "Alarm specialization",
11
11
  "type" : "string",
12
12
  "enum" : [ "Issue", "Acknowledge", "Suspend", "Resume", "Request" ]
13
+ }
14
+ },
15
+ "required" : [ "aSp"],
16
+ "allOf" : [
17
+ {
18
+ "if": {
19
+ "required" : [ "aSp" ],
20
+ "properties" : { "aSp" : { "const" : "Issue" } }
21
+ },
22
+ "then": { "$ref": "alarm_issue.json" }
13
23
  },
14
- "ack" : {
15
- "description" : "Acknowledgement",
16
- "type" : "string",
17
- "enum" : [ "Acknowledged", "notAcknowledged" ]
18
- },
19
- "aS" : {
20
- "description" : "Status",
21
- "type" : "string",
22
- "enum" : [ "inActive", "Active" ]
23
- },
24
- "sS" : {
25
- "description" : "Suspended",
26
- "type" : "string",
27
- "enum" : [ "suspended", "notSuspended" ]
28
- },
29
- "aTs" : { "$ref": "definitions.json#/timestamp" },
30
- "cat" : {
31
- "description" : "Category",
32
- "type" : "string",
33
- "enum" : [ "T", "D" ]
34
- },
35
- "pri" : {
36
- "description" : "Priority",
37
- "type" : "string",
38
- "enum" : [ "1", "2", "3" ]
24
+ {
25
+ "if": {
26
+ "allOf" : [
27
+ {
28
+ "required" : [ "aSp" ],
29
+ "properties" : {
30
+ "aSp" : { "enum" : [ "Suspend","Resume"] }
31
+ }
32
+ },
33
+ {
34
+ "not": { "required" : [ "sS" ] }
35
+ }
36
+ ]
37
+ },
38
+ "then": { "$ref": "alarm_suspend_resume.json" }
39
39
  },
40
- "rvs" : {
41
- "description" : "Return values",
42
- "type" : "array",
43
- "items" : {
44
- "type" : "object",
45
- "properties": {
46
- "n" : { "description" : "Unique reference of the value", "type" : "string" },
47
- "v" : { "description" : "Value", "type" : "string" }
48
- },
49
- "required" : [ "n", "v" ],
50
- "additionProperties": false
51
- }
40
+ {
41
+ "if": {
42
+ "required" : [ "aSp", "sS" ],
43
+ "properties" : {
44
+ "aSp" : { "const" : "Suspend" },
45
+ "sS" : { "enum" : [ "suspended", "notSuspended" ] }
46
+ }
47
+ },
48
+ "then": { "$ref": "alarm_suspended_resumed.json" }
52
49
  }
53
- },
54
- "required" : [ "mId", "cId", "aCId", "xACId", "aSp", "ack", "aS", "aTs", "sS", "cat", "pri", "rvs" ]
50
+ ]
55
51
  }
@@ -0,0 +1,44 @@
1
+ {
2
+ "properties" : {
3
+ "ack" : {
4
+ "description" : "Acknowledgement",
5
+ "type" : "string",
6
+ "enum" : [ "Acknowledged", "notAcknowledged" ]
7
+ },
8
+ "aS" : {
9
+ "description" : "Active status",
10
+ "type" : "string",
11
+ "enum" : [ "inActive", "Active" ]
12
+ },
13
+ "sS" : {
14
+ "description" : "Suspend status",
15
+ "type" : "string",
16
+ "enum" : [ "suspended", "notSuspended" ]
17
+ },
18
+ "aTs" : { "$ref": "definitions.json#/timestamp" },
19
+ "cat" : {
20
+ "description" : "Category",
21
+ "type" : "string",
22
+ "enum" : [ "T", "D" ]
23
+ },
24
+ "pri" : {
25
+ "description" : "Priority",
26
+ "type" : "string",
27
+ "enum" : [ "1", "2", "3" ]
28
+ },
29
+ "rvs" : {
30
+ "description" : "Return values",
31
+ "type" : "array",
32
+ "items" : {
33
+ "type" : "object",
34
+ "properties": {
35
+ "n" : { "description" : "Unique reference of the value", "type" : "string" },
36
+ "v" : { "description" : "Value", "type" : "string" }
37
+ },
38
+ "required" : [ "n", "v" ],
39
+ "additionalProperties": false
40
+ }
41
+ }
42
+ },
43
+ "required" : [ "mId", "cId", "aCId", "xACId", "aSp", "ack", "aS", "aTs", "sS", "cat", "pri", "rvs" ]
44
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "required" : [ "mId", "cId", "aCId", "xACId", "aSp" ]
3
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "properties" : {
3
+ "ack" : {
4
+ "description" : "Acknowledgement",
5
+ "type" : "string",
6
+ "enum" : [ "Acknowledged", "notAcknowledged" ]
7
+ },
8
+ "aS" : {
9
+ "description" : "Active status",
10
+ "type" : "string",
11
+ "enum" : [ "inActive", "Active" ]
12
+ },
13
+ "sS" : {
14
+ "description" : "Suspend status",
15
+ "type" : "string",
16
+ "enum" : [ "suspended", "notSuspended" ]
17
+ },
18
+ "aTs" : { "$ref": "definitions.json#/timestamp" },
19
+ "cat" : {
20
+ "description" : "Category",
21
+ "type" : "string",
22
+ "enum" : [ "T", "D" ]
23
+ },
24
+ "pri" : {
25
+ "description" : "Priority",
26
+ "type" : "string",
27
+ "enum" : [ "1", "2", "3" ]
28
+ },
29
+ "rvs" : {
30
+ "description" : "Return values",
31
+ "type" : "array",
32
+ "items" : {
33
+ "type" : "object",
34
+ "properties": {
35
+ "n" : { "description" : "Unique reference of the value", "type" : "string" },
36
+ "v" : { "description" : "Value", "type" : "string" }
37
+ },
38
+ "required" : [ "n", "v" ],
39
+ "additionalProperties": false
40
+ }
41
+ }
42
+ },
43
+ "required" : [ "mId", "cId", "aCId", "xACId", "aSp", "ack", "aS", "aTs", "sS", "cat", "pri", "rvs" ]
44
+ }
@@ -26,7 +26,7 @@
26
26
  }
27
27
  },
28
28
  "required" : [ "cCI", "n", "v", "age" ],
29
- "additionProperties": false
29
+ "additionalProperties": false
30
30
  }
31
31
  }
32
32
  },
@@ -22,7 +22,7 @@
22
22
  }
23
23
  },
24
24
  "required" : [ "sCI", "n", "s", "q" ],
25
- "additionProperties": false
25
+ "additionalProperties": false
26
26
  }
27
27
  }
28
28
  },
@@ -22,7 +22,7 @@
22
22
  }
23
23
  },
24
24
  "required" : [ "sCI", "n", "s", "q" ],
25
- "additionProperties": false
25
+ "additionalProperties": false
26
26
  }
27
27
  }
28
28
  },
@@ -0,0 +1,299 @@
1
+ RSpec.describe "Traffic Light Controller RSMP SXL Schema validation" do
2
+ describe 'Alarm Issue' do
3
+ let(:message) {{
4
+ "mType" => "rSMsg",
5
+ "type" => "Alarm",
6
+ "mId" => "E68A0010-C336-41ac-BD58-5C80A72C7092",
7
+ "cId" => "AB+84001=860SG001",
8
+ "aCId" => "A0001",
9
+ "xACId" => "Serious lamp error",
10
+ "aSp" => "Issue",
11
+ "ack" => "notAcknowledged",
12
+ "aS" => "Active",
13
+ "sS" => "notSuspended",
14
+ "aTs" => "2009-10-01T11:59:31.571Z",
15
+ "cat" => "D",
16
+ "pri" => "2",
17
+ "rvs" => [
18
+ {
19
+ "n" => "color",
20
+ "v" => "red"
21
+ }
22
+ ]
23
+ }}
24
+
25
+ it 'accepts valid alarm' do
26
+ expect( validate(message) ).to be_nil
27
+ end
28
+
29
+ it 'catches missing component id' do
30
+ invalid = message.dup
31
+ invalid.delete 'cId'
32
+ expect( validate(invalid) ).to eq([
33
+ ["", "required", {"missing_keys"=>["cId"]}]
34
+ ])
35
+ end
36
+
37
+ it 'catches missing alarm code id' do
38
+ invalid = message.dup
39
+ invalid.delete 'aCId'
40
+ expect( validate(invalid) ).to eq([
41
+ ["", "required", {"missing_keys"=>["aCId"]}]
42
+ ])
43
+ end
44
+
45
+ it 'catches bad alarm code id' do
46
+ invalid = message.dup
47
+ invalid['aCId'] = "001"
48
+ expect( validate(invalid) ).to eq([
49
+ ["/aCId", "pattern"]
50
+ ])
51
+ end
52
+
53
+ it 'catches wrong alarm code id type' do
54
+ invalid = message.dup
55
+ invalid['aCId'] = 123
56
+ expect( validate(invalid) ).to eq([
57
+ ["/aCId", "string"]
58
+ ])
59
+ end
60
+
61
+ it 'catches missing extended alarm code id' do
62
+ invalid = message.dup
63
+ invalid.delete 'xACId'
64
+ expect( validate(invalid) ).to eq([
65
+ ["", "required", {"missing_keys"=>["xACId"]}]
66
+ ])
67
+ end
68
+
69
+ it 'catches wrong extended alarm code id type' do
70
+ invalid = message.dup
71
+ invalid['xACId'] = 123
72
+ expect( validate(invalid) ).to eq([
73
+ ["/xACId", "string"]
74
+ ])
75
+ end
76
+
77
+ it 'catches missing specialization' do
78
+ invalid = message.dup
79
+ invalid.delete 'aSp'
80
+ expect( validate(invalid) ).to eq([
81
+ ["", "required", {"missing_keys"=>["aSp"]}]
82
+ ])
83
+ end
84
+
85
+ it 'catches bad specialization' do
86
+ invalid = message.dup
87
+ invalid['aSp'] = "Bad"
88
+ expect( validate(invalid) ).to eq([
89
+ ["/aSp", "enum"]
90
+ ])
91
+ end
92
+
93
+ it 'catches wrong specialization type' do
94
+ invalid = message.dup
95
+ invalid['aSp'] = 123
96
+ expect( validate(invalid) ).to eq([
97
+ ["/aSp", "enum"],
98
+ ["/aSp", "string"]
99
+ ])
100
+ end
101
+
102
+ it 'catches missing alarm active status' do
103
+ invalid = message.dup
104
+ invalid.delete 'aS'
105
+ expect( validate(invalid) ).to eq([
106
+ ["", "required", {"missing_keys"=>["aS"]}]
107
+ ])
108
+ end
109
+
110
+ it 'catches bad alarm active status' do
111
+ invalid = message.dup
112
+ invalid['aS'] = "Bad"
113
+ expect( validate(invalid) ).to eq([
114
+ ["/aS", "enum"]
115
+ ])
116
+ end
117
+
118
+ it 'catches wrong alarm active status' do
119
+ invalid = message.dup
120
+ invalid['aS'] = 123
121
+ expect( validate(invalid) ).to eq([
122
+ ["/aS", "enum"],
123
+ ["/aS", "string"]
124
+ ])
125
+ end
126
+
127
+ it 'catches missing alarm suspend status' do
128
+ invalid = message.dup
129
+ invalid.delete 'sS'
130
+ expect( validate(invalid) ).to eq([
131
+ ["", "required", {"missing_keys"=>["sS"]}]
132
+ ])
133
+ end
134
+
135
+ it 'catches bad alarm code id' do
136
+ invalid = message.dup
137
+ invalid['sS'] = "Bad"
138
+ expect( validate(invalid) ).to eq([
139
+ ["/sS", "enum"]
140
+ ])
141
+ end
142
+
143
+ it 'catches wrong alarm code id type' do
144
+ invalid = message.dup
145
+ invalid['sS'] = 123
146
+ expect( validate(invalid) ).to eq([
147
+ ["/sS", "enum"],
148
+ ["/sS", "string"]
149
+ ])
150
+ end
151
+
152
+ it 'catches missing alarm code id' do
153
+ invalid = message.dup
154
+ invalid.delete 'ack'
155
+ expect( validate(invalid) ).to eq([
156
+ ["", "required", {"missing_keys"=>["ack"]}]
157
+ ])
158
+ end
159
+
160
+ it 'catches bad alarm code id' do
161
+ invalid = message.dup
162
+ invalid['ack'] = "Bad"
163
+ expect( validate(invalid) ).to eq([
164
+ ["/ack", "enum"]
165
+ ])
166
+ end
167
+
168
+ it 'catches wrong alarm code id type' do
169
+ invalid = message.dup
170
+ invalid['ack'] = 123
171
+ expect( validate(invalid) ).to eq([
172
+ ["/ack", "enum"],
173
+ ["/ack", "string"]
174
+ ])
175
+ end
176
+
177
+ it 'catches missing category' do
178
+ invalid = message.dup
179
+ invalid.delete 'cat'
180
+ expect( validate(invalid) ).to eq([
181
+ ["", "required", {"missing_keys"=>["cat"]}]
182
+ ])
183
+ end
184
+
185
+ it 'catches bad category' do
186
+ invalid = message.dup
187
+ invalid['cat'] = "A"
188
+ expect( validate(invalid) ).to eq([
189
+ ["/cat", "enum"]
190
+ ])
191
+ end
192
+
193
+ it 'catches wrong category' do
194
+ invalid = message.dup
195
+ invalid['cat'] = 123
196
+ expect( validate(invalid) ).to eq([
197
+ ["/cat", "enum"],
198
+ ["/cat", "string"]
199
+ ])
200
+ end
201
+
202
+ it 'catches missing priority' do
203
+ invalid = message.dup
204
+ invalid.delete 'pri'
205
+ expect( validate(invalid) ).to eq([
206
+ ["", "required", {"missing_keys"=>["pri"]}]
207
+ ])
208
+ end
209
+
210
+ it 'catches bad priority' do
211
+ invalid = message.dup
212
+ invalid['pri'] = "4"
213
+ expect( validate(invalid) ).to eq([
214
+ ["/pri", "enum"]
215
+ ])
216
+ end
217
+
218
+ it 'catches wrong priority' do
219
+ invalid = message.dup
220
+ invalid['pri'] = 1
221
+ expect( validate(invalid) ).to eq([
222
+ ["/pri", "enum"],
223
+ ["/pri", "string"]
224
+ ])
225
+ end
226
+
227
+ it 'catches missing timestamp' do
228
+ invalid = message.dup
229
+ invalid.delete 'aTs'
230
+ expect( validate(invalid) ).to eq([
231
+ ["", "required", {"missing_keys"=>["aTs"]}]
232
+ ])
233
+ end
234
+
235
+ it 'catches bad timestamp' do
236
+ invalid = message.dup
237
+ invalid['aTs'] = "yesterday"
238
+ expect( validate(invalid) ).to eq([
239
+ ["/aTs", "pattern"]
240
+ ])
241
+ end
242
+
243
+ it 'catches wrong timestamp type' do
244
+ invalid = message.dup
245
+ invalid['aTs'] = 123
246
+ expect( validate(invalid) ).to eq([
247
+ ["/aTs", "string"]
248
+ ])
249
+ end
250
+
251
+ it 'catches missing rvs' do
252
+ invalid = message.dup
253
+ invalid.delete 'rvs'
254
+ expect( validate(invalid) ).to eq([
255
+ ["", "required", {"missing_keys"=>["rvs"]}]
256
+ ])
257
+ end
258
+
259
+ it 'catches bad rvs type' do
260
+ invalid = message.dup
261
+ invalid["rvs"] = {}
262
+ expect( validate(invalid) ).to eq([
263
+ ["/rvs", "array"]
264
+ ])
265
+ end
266
+
267
+ it 'catches missing alarm name' do
268
+ invalid = message.dup
269
+ invalid["rvs"].first.delete 'n'
270
+ expect( validate(invalid) ).to eq([
271
+ ["/rvs/0", "required", {"missing_keys"=>["n"]}]
272
+ ])
273
+ end
274
+
275
+ it 'catches bad alarm name' do
276
+ invalid = message.dup
277
+ invalid["rvs"].first['n'] = 3
278
+ expect( validate(invalid) ).to eq([
279
+ ["/rvs/0/n", "string"]
280
+ ])
281
+ end
282
+
283
+ it 'catches missing alarm value' do
284
+ invalid = message.dup
285
+ invalid["rvs"].first.delete 'v'
286
+ expect( validate(invalid) ).to eq([
287
+ ["/rvs/0", "required", {"missing_keys"=>["v"]}]
288
+ ])
289
+ end
290
+
291
+ it 'catches bad alarm value' do
292
+ invalid = message.dup
293
+ invalid["rvs"].first['v'] = 3
294
+ expect( validate(invalid) ).to eq([
295
+ ["/rvs/0/v", "string"]
296
+ ])
297
+ end
298
+ end
299
+ end
@@ -0,0 +1,93 @@
1
+ RSpec.describe "Traffic Light Controller RSMP SXL Schema validation" do
2
+ describe 'Alarm Resume' do
3
+ let(:message) {{
4
+ "mType" => "rSMsg",
5
+ "type" => "Alarm",
6
+ "mId" => "2a744145-403a-423f-ba80-f38e283a778e",
7
+ "ntsOId" => "",
8
+ "xNId" => "",
9
+ "cId" => "AB+84001=860VA001",
10
+ "aCId" => "A0004",
11
+ "xACId" => "",
12
+ "xNACId" => "",
13
+ "aSp" => "Resume"
14
+ }}
15
+
16
+ it 'accepts valid alarm resume' do
17
+ expect( validate(message) ).to be_nil
18
+ end
19
+
20
+ it 'catches missing component id' do
21
+ invalid = message.dup
22
+ invalid.delete 'cId'
23
+ expect( validate(invalid) ).to eq([
24
+ ["", "required", {"missing_keys"=>["cId"]}]
25
+ ])
26
+ end
27
+
28
+ it 'catches missing alarm code id' do
29
+ invalid = message.dup
30
+ invalid.delete 'aCId'
31
+ expect( validate(invalid) ).to eq([
32
+ ["", "required", {"missing_keys"=>["aCId"]}]
33
+ ])
34
+ end
35
+
36
+ it 'catches bad alarm code id' do
37
+ invalid = message.dup
38
+ invalid['aCId'] = "001"
39
+ expect( validate(invalid) ).to eq([
40
+ ["/aCId", "pattern"]
41
+ ])
42
+ end
43
+
44
+ it 'catches wrong alarm code id type' do
45
+ invalid = message.dup
46
+ invalid['aCId'] = 123
47
+ expect( validate(invalid) ).to eq([
48
+ ["/aCId", "string"]
49
+ ])
50
+ end
51
+
52
+ it 'catches missing extended alarm code id' do
53
+ invalid = message.dup
54
+ invalid.delete 'xACId'
55
+ expect( validate(invalid) ).to eq([
56
+ ["", "required", {"missing_keys"=>["xACId"]}]
57
+ ])
58
+ end
59
+
60
+ it 'catches wrong extended alarm code id type' do
61
+ invalid = message.dup
62
+ invalid['xACId'] = 123
63
+ expect( validate(invalid) ).to eq([
64
+ ["/xACId", "string"]
65
+ ])
66
+ end
67
+
68
+ it 'catches missing specialization' do
69
+ invalid = message.dup
70
+ invalid.delete 'aSp'
71
+ expect( validate(invalid) ).to eq([
72
+ ["", "required", {"missing_keys"=>["aSp"]}]
73
+ ])
74
+ end
75
+
76
+ it 'catches bad specialization' do
77
+ invalid = message.dup
78
+ invalid['aSp'] = "Bad"
79
+ expect( validate(invalid) ).to eq([
80
+ ["/aSp", "enum"]
81
+ ])
82
+ end
83
+
84
+ it 'catches wrong specialization type' do
85
+ invalid = message.dup
86
+ invalid['aSp'] = 123
87
+ expect( validate(invalid) ).to eq([
88
+ ["/aSp", "enum"],
89
+ ["/aSp", "string"]
90
+ ])
91
+ end
92
+ end
93
+ end