rsmp_schemer 0.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -8
- data/lib/rsmp_schemer/schemer.rb +2 -2
- data/lib/rsmp_schemer/version.rb +1 -1
- data/schemas/core_3.1.5/.gitignore +1 -0
- data/schemas/core_3.1.5/schema/core/alarm.json +36 -40
- data/schemas/core_3.1.5/schema/core/alarm_issue.json +44 -0
- data/schemas/core_3.1.5/schema/core/alarm_suspend_resume.json +3 -0
- data/schemas/core_3.1.5/schema/core/alarm_suspended_resumed.json +44 -0
- data/schemas/core_3.1.5/schema/core/command_response.json +1 -1
- data/schemas/core_3.1.5/schema/core/status_response.json +1 -1
- data/schemas/core_3.1.5/schema/core/status_update.json +1 -1
- data/schemas/core_3.1.5/spec/core/alarm_issue_spec.rb +299 -0
- data/schemas/core_3.1.5/spec/core/alarm_resume_spec.rb +93 -0
- data/schemas/core_3.1.5/spec/core/alarm_resumed_spec.rb +277 -0
- data/schemas/core_3.1.5/spec/core/alarm_suspend_spec.rb +93 -0
- data/schemas/core_3.1.5/spec/core/alarm_suspended_spec.rb +277 -0
- data/schemas/core_3.1.5/spec/core/version_spec.rb +3 -2
- data/schemas/tlc_1.0.10/schema/tlc/statuses/S0001.json +1 -1
- data/schemas/tlc_1.0.10/schema/tlc/statuses/statuses.json +1 -257
- data/schemas/tlc_1.0.13/schema/tlc/statuses/S0001.json +1 -1
- data/schemas/tlc_1.0.13/schema/tlc/statuses/S0023.json +1 -1
- data/schemas/tlc_1.0.13/schema/tlc/statuses/statuses.json +1 -99
- data/schemas/tlc_1.0.13/spec/tlc/S0023_spec.rb +96 -0
- data/schemas/tlc_1.0.14/schema/tlc/statuses/S0001.json +1 -1
- data/schemas/tlc_1.0.14/schema/tlc/statuses/S0023.json +1 -1
- data/schemas/tlc_1.0.14/schema/tlc/statuses/statuses.json +0 -34
- data/schemas/tlc_1.0.14/spec/tlc/S0023_spec.rb +96 -0
- data/schemas/tlc_1.0.15/schema/tlc/statuses/S0001.json +1 -1
- data/schemas/tlc_1.0.15/schema/tlc/statuses/S0023.json +1 -1
- data/schemas/tlc_1.0.15/spec/tlc/S0023_spec.rb +96 -0
- data/schemas/tlc_1.0.7/schema/tlc/statuses/S0001.json +1 -1
- data/schemas/tlc_1.0.7/schema/tlc/statuses/statuses.json +1 -77
- data/schemas/tlc_1.0.8/schema/tlc/statuses/S0001.json +1 -1
- data/schemas/tlc_1.0.8/schema/tlc/statuses/statuses.json +1 -77
- data/schemas/tlc_1.0.9/schema/tlc/statuses/S0001.json +1 -1
- data/schemas/tlc_1.0.9/schema/tlc/statuses/statuses.json +1 -77
- metadata +15 -6
- data/schemas/core_3.1.5/examples/validate.rb +0 -35
- data/schemas/core_3.1.5/spec/core/alarm_request_spec.rb +0 -72
- data/schemas/core_3.1.5/spec/core/alarm_spec.rb +0 -298
@@ -26,7 +26,7 @@
|
|
26
26
|
"s" : {
|
27
27
|
"description" : "Dynamic bands.\nEach dynamic band are written as pp-dd-ee where:\npp=Time plan\ndd=Dynamic band number (from 1-10)\nee=Extension in seconds in this band\n\nEach dynamic band is separated with a comma.\n\nE.g.\npp-dd-ee,pp-dd-ee",
|
28
28
|
"type" : "string",
|
29
|
-
"pattern" : "
|
29
|
+
"pattern" : "(^$)|(^(?<item>(\\d{1,2})\\-\\d{1,2}-\\d{1,2})(,\\g<item>)*$)"
|
30
30
|
}
|
31
31
|
}
|
32
32
|
}
|
@@ -0,0 +1,96 @@
|
|
1
|
+
RSpec.describe "Traffic Light Controller RSMP SXL Schema validation" do
|
2
|
+
let(:message) {{
|
3
|
+
"mType" => "rSMsg",
|
4
|
+
"mId" => "4173c2c8-a933-43cb-9425-66d4613731ed",
|
5
|
+
"type" => "StatusResponse",
|
6
|
+
"cId" => "O+14439=481WA001",
|
7
|
+
"sTs" => "2015-06-08T09:15:18.266Z",
|
8
|
+
"sS" => [
|
9
|
+
{ "sCI" => "S0023", "n" => "status", "s" => "", "q" => "recent" }
|
10
|
+
]
|
11
|
+
}}
|
12
|
+
|
13
|
+
it 'accepts empty list' do
|
14
|
+
message["sS"][0]['s'] = ''
|
15
|
+
expect( validate(message) ).to be_nil
|
16
|
+
end
|
17
|
+
it 'accepts one digit' do
|
18
|
+
message["sS"][0]['s'] = '1-1-0'
|
19
|
+
expect( validate(message) ).to be_nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'accepts two digits' do
|
23
|
+
message["sS"][0]['s'] = '01-01-20'
|
24
|
+
expect( validate(message) ).to be_nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'rejects three digits or more' do
|
28
|
+
message["sS"][0]['s'] = '01-01-100'
|
29
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
30
|
+
|
31
|
+
message["sS"][0]['s'] = '100-01-01'
|
32
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'accepts comma-separated items' do
|
36
|
+
message["sS"][0]['s'] = '1-1-0,1-2-0'
|
37
|
+
expect( validate(message) ).to be_nil
|
38
|
+
|
39
|
+
message["sS"][0]['s'] = '1-1-0,1-2-0,2-4-5'
|
40
|
+
expect( validate(message) ).to be_nil
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'rejects comma-separated lists with spaces' do
|
44
|
+
message["sS"][0]['s'] = '1-1-0, 1-2-0'
|
45
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
46
|
+
|
47
|
+
message["sS"][0]['s'] = '1-1-0 ,1-2-0'
|
48
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'rejects comma-separated lists with trailing comma' do
|
52
|
+
message["sS"][0]['s'] = '1-1-0,'
|
53
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'rejects comma-separated lists with leading comma' do
|
57
|
+
message["sS"][0]['s'] = ',1-1-0'
|
58
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'rejects comma-separated lists with empty items' do
|
62
|
+
message["sS"][0]['s'] = '1-1-0,,1-2-0'
|
63
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'rejects negatives' do
|
67
|
+
message["sS"][0]['s'] = '-1-2-3'
|
68
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
69
|
+
|
70
|
+
message["sS"][0]['s'] = '1--2-3'
|
71
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
72
|
+
|
73
|
+
message["sS"][0]['s'] = '1-2--3'
|
74
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'rejects floats' do
|
78
|
+
message["sS"][0]['s'] = '.1-2-3'
|
79
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
80
|
+
|
81
|
+
message["sS"][0]['s'] = '1-.2-3'
|
82
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
83
|
+
|
84
|
+
message["sS"][0]['s'] = '1-2-.3'
|
85
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
86
|
+
|
87
|
+
message["sS"][0]['s'] = '1.-2-3'
|
88
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
89
|
+
|
90
|
+
message["sS"][0]['s'] = '1-2.-3'
|
91
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
92
|
+
|
93
|
+
message["sS"][0]['s'] = '1-2-3.'
|
94
|
+
expect( validate(message) ).to eq([["/sS/0/s", "pattern"]])
|
95
|
+
end
|
96
|
+
end
|
@@ -28,30 +28,14 @@
|
|
28
28
|
"S0019",
|
29
29
|
"S0020",
|
30
30
|
"S0021",
|
31
|
-
"S0022",
|
32
|
-
"S0023",
|
33
|
-
"S0024",
|
34
|
-
"S0025",
|
35
|
-
"S0026",
|
36
|
-
"S0027",
|
37
|
-
"S0028",
|
38
|
-
"S0029",
|
39
|
-
"S0030",
|
40
|
-
"S0031",
|
41
31
|
"S0091",
|
42
32
|
"S0092",
|
43
33
|
"S0095",
|
44
34
|
"S0096",
|
45
|
-
"S0097",
|
46
|
-
"S0098",
|
47
35
|
"S0201",
|
48
36
|
"S0202",
|
49
37
|
"S0203",
|
50
|
-
"S0204"
|
51
|
-
"S0205",
|
52
|
-
"S0206",
|
53
|
-
"S0207",
|
54
|
-
"S0208"
|
38
|
+
"S0204"
|
55
39
|
]
|
56
40
|
}
|
57
41
|
}
|
@@ -670,66 +654,6 @@
|
|
670
654
|
"then" : {
|
671
655
|
"$ref" : "S0204.json"
|
672
656
|
}
|
673
|
-
},
|
674
|
-
{
|
675
|
-
"if" : {
|
676
|
-
"required" : [
|
677
|
-
"sCI"
|
678
|
-
],
|
679
|
-
"properties" : {
|
680
|
-
"sCI" : {
|
681
|
-
"const" : "S0205"
|
682
|
-
}
|
683
|
-
}
|
684
|
-
},
|
685
|
-
"then" : {
|
686
|
-
"$ref" : "S0205.json"
|
687
|
-
}
|
688
|
-
},
|
689
|
-
{
|
690
|
-
"if" : {
|
691
|
-
"required" : [
|
692
|
-
"sCI"
|
693
|
-
],
|
694
|
-
"properties" : {
|
695
|
-
"sCI" : {
|
696
|
-
"const" : "S0206"
|
697
|
-
}
|
698
|
-
}
|
699
|
-
},
|
700
|
-
"then" : {
|
701
|
-
"$ref" : "S0206.json"
|
702
|
-
}
|
703
|
-
},
|
704
|
-
{
|
705
|
-
"if" : {
|
706
|
-
"required" : [
|
707
|
-
"sCI"
|
708
|
-
],
|
709
|
-
"properties" : {
|
710
|
-
"sCI" : {
|
711
|
-
"const" : "S0207"
|
712
|
-
}
|
713
|
-
}
|
714
|
-
},
|
715
|
-
"then" : {
|
716
|
-
"$ref" : "S0207.json"
|
717
|
-
}
|
718
|
-
},
|
719
|
-
{
|
720
|
-
"if" : {
|
721
|
-
"required" : [
|
722
|
-
"sCI"
|
723
|
-
],
|
724
|
-
"properties" : {
|
725
|
-
"sCI" : {
|
726
|
-
"const" : "S0208"
|
727
|
-
}
|
728
|
-
}
|
729
|
-
},
|
730
|
-
"then" : {
|
731
|
-
"$ref" : "S0208.json"
|
732
|
-
}
|
733
657
|
}
|
734
658
|
]
|
735
659
|
}
|
@@ -28,30 +28,14 @@
|
|
28
28
|
"S0019",
|
29
29
|
"S0020",
|
30
30
|
"S0021",
|
31
|
-
"S0022",
|
32
|
-
"S0023",
|
33
|
-
"S0024",
|
34
|
-
"S0025",
|
35
|
-
"S0026",
|
36
|
-
"S0027",
|
37
|
-
"S0028",
|
38
|
-
"S0029",
|
39
|
-
"S0030",
|
40
|
-
"S0031",
|
41
31
|
"S0091",
|
42
32
|
"S0092",
|
43
33
|
"S0095",
|
44
34
|
"S0096",
|
45
|
-
"S0097",
|
46
|
-
"S0098",
|
47
35
|
"S0201",
|
48
36
|
"S0202",
|
49
37
|
"S0203",
|
50
|
-
"S0204"
|
51
|
-
"S0205",
|
52
|
-
"S0206",
|
53
|
-
"S0207",
|
54
|
-
"S0208"
|
38
|
+
"S0204"
|
55
39
|
]
|
56
40
|
}
|
57
41
|
}
|
@@ -670,66 +654,6 @@
|
|
670
654
|
"then" : {
|
671
655
|
"$ref" : "S0204.json"
|
672
656
|
}
|
673
|
-
},
|
674
|
-
{
|
675
|
-
"if" : {
|
676
|
-
"required" : [
|
677
|
-
"sCI"
|
678
|
-
],
|
679
|
-
"properties" : {
|
680
|
-
"sCI" : {
|
681
|
-
"const" : "S0205"
|
682
|
-
}
|
683
|
-
}
|
684
|
-
},
|
685
|
-
"then" : {
|
686
|
-
"$ref" : "S0205.json"
|
687
|
-
}
|
688
|
-
},
|
689
|
-
{
|
690
|
-
"if" : {
|
691
|
-
"required" : [
|
692
|
-
"sCI"
|
693
|
-
],
|
694
|
-
"properties" : {
|
695
|
-
"sCI" : {
|
696
|
-
"const" : "S0206"
|
697
|
-
}
|
698
|
-
}
|
699
|
-
},
|
700
|
-
"then" : {
|
701
|
-
"$ref" : "S0206.json"
|
702
|
-
}
|
703
|
-
},
|
704
|
-
{
|
705
|
-
"if" : {
|
706
|
-
"required" : [
|
707
|
-
"sCI"
|
708
|
-
],
|
709
|
-
"properties" : {
|
710
|
-
"sCI" : {
|
711
|
-
"const" : "S0207"
|
712
|
-
}
|
713
|
-
}
|
714
|
-
},
|
715
|
-
"then" : {
|
716
|
-
"$ref" : "S0207.json"
|
717
|
-
}
|
718
|
-
},
|
719
|
-
{
|
720
|
-
"if" : {
|
721
|
-
"required" : [
|
722
|
-
"sCI"
|
723
|
-
],
|
724
|
-
"properties" : {
|
725
|
-
"sCI" : {
|
726
|
-
"const" : "S0208"
|
727
|
-
}
|
728
|
-
}
|
729
|
-
},
|
730
|
-
"then" : {
|
731
|
-
"$ref" : "S0208.json"
|
732
|
-
}
|
733
657
|
}
|
734
658
|
]
|
735
659
|
}
|
@@ -28,30 +28,14 @@
|
|
28
28
|
"S0019",
|
29
29
|
"S0020",
|
30
30
|
"S0021",
|
31
|
-
"S0022",
|
32
|
-
"S0023",
|
33
|
-
"S0024",
|
34
|
-
"S0025",
|
35
|
-
"S0026",
|
36
|
-
"S0027",
|
37
|
-
"S0028",
|
38
|
-
"S0029",
|
39
|
-
"S0030",
|
40
|
-
"S0031",
|
41
31
|
"S0091",
|
42
32
|
"S0092",
|
43
33
|
"S0095",
|
44
34
|
"S0096",
|
45
|
-
"S0097",
|
46
|
-
"S0098",
|
47
35
|
"S0201",
|
48
36
|
"S0202",
|
49
37
|
"S0203",
|
50
|
-
"S0204"
|
51
|
-
"S0205",
|
52
|
-
"S0206",
|
53
|
-
"S0207",
|
54
|
-
"S0208"
|
38
|
+
"S0204"
|
55
39
|
]
|
56
40
|
}
|
57
41
|
}
|
@@ -670,66 +654,6 @@
|
|
670
654
|
"then" : {
|
671
655
|
"$ref" : "S0204.json"
|
672
656
|
}
|
673
|
-
},
|
674
|
-
{
|
675
|
-
"if" : {
|
676
|
-
"required" : [
|
677
|
-
"sCI"
|
678
|
-
],
|
679
|
-
"properties" : {
|
680
|
-
"sCI" : {
|
681
|
-
"const" : "S0205"
|
682
|
-
}
|
683
|
-
}
|
684
|
-
},
|
685
|
-
"then" : {
|
686
|
-
"$ref" : "S0205.json"
|
687
|
-
}
|
688
|
-
},
|
689
|
-
{
|
690
|
-
"if" : {
|
691
|
-
"required" : [
|
692
|
-
"sCI"
|
693
|
-
],
|
694
|
-
"properties" : {
|
695
|
-
"sCI" : {
|
696
|
-
"const" : "S0206"
|
697
|
-
}
|
698
|
-
}
|
699
|
-
},
|
700
|
-
"then" : {
|
701
|
-
"$ref" : "S0206.json"
|
702
|
-
}
|
703
|
-
},
|
704
|
-
{
|
705
|
-
"if" : {
|
706
|
-
"required" : [
|
707
|
-
"sCI"
|
708
|
-
],
|
709
|
-
"properties" : {
|
710
|
-
"sCI" : {
|
711
|
-
"const" : "S0207"
|
712
|
-
}
|
713
|
-
}
|
714
|
-
},
|
715
|
-
"then" : {
|
716
|
-
"$ref" : "S0207.json"
|
717
|
-
}
|
718
|
-
},
|
719
|
-
{
|
720
|
-
"if" : {
|
721
|
-
"required" : [
|
722
|
-
"sCI"
|
723
|
-
],
|
724
|
-
"properties" : {
|
725
|
-
"sCI" : {
|
726
|
-
"const" : "S0208"
|
727
|
-
}
|
728
|
-
}
|
729
|
-
},
|
730
|
-
"then" : {
|
731
|
-
"$ref" : "S0208.json"
|
732
|
-
}
|
733
657
|
}
|
734
658
|
]
|
735
659
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsmp_schemer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Tin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_schemer
|
@@ -297,15 +297,18 @@ files:
|
|
297
297
|
- schemas/core_3.1.4/spec/core/watchdog_spec.rb
|
298
298
|
- schemas/core_3.1.4/spec/schemer_helper.rb
|
299
299
|
- schemas/core_3.1.4/spec/spec_helper.rb
|
300
|
+
- schemas/core_3.1.5/.gitignore
|
300
301
|
- schemas/core_3.1.5/.rspec
|
301
302
|
- schemas/core_3.1.5/Gemfile
|
302
303
|
- schemas/core_3.1.5/Gemfile.lock
|
303
304
|
- schemas/core_3.1.5/LICENSE
|
304
305
|
- schemas/core_3.1.5/README.md
|
305
|
-
- schemas/core_3.1.5/examples/validate.rb
|
306
306
|
- schemas/core_3.1.5/schema/core/aggregated_status.json
|
307
307
|
- schemas/core_3.1.5/schema/core/aggregated_status_request.json
|
308
308
|
- schemas/core_3.1.5/schema/core/alarm.json
|
309
|
+
- schemas/core_3.1.5/schema/core/alarm_issue.json
|
310
|
+
- schemas/core_3.1.5/schema/core/alarm_suspend_resume.json
|
311
|
+
- schemas/core_3.1.5/schema/core/alarm_suspended_resumed.json
|
309
312
|
- schemas/core_3.1.5/schema/core/command_request.json
|
310
313
|
- schemas/core_3.1.5/schema/core/command_response.json
|
311
314
|
- schemas/core_3.1.5/schema/core/core.json
|
@@ -322,8 +325,11 @@ files:
|
|
322
325
|
- schemas/core_3.1.5/schema/core/version.json
|
323
326
|
- schemas/core_3.1.5/schema/core/watchdog.json
|
324
327
|
- schemas/core_3.1.5/spec/core/aggregated_status_spec.rb
|
325
|
-
- schemas/core_3.1.5/spec/core/
|
326
|
-
- schemas/core_3.1.5/spec/core/
|
328
|
+
- schemas/core_3.1.5/spec/core/alarm_issue_spec.rb
|
329
|
+
- schemas/core_3.1.5/spec/core/alarm_resume_spec.rb
|
330
|
+
- schemas/core_3.1.5/spec/core/alarm_resumed_spec.rb
|
331
|
+
- schemas/core_3.1.5/spec/core/alarm_suspend_spec.rb
|
332
|
+
- schemas/core_3.1.5/spec/core/alarm_suspended_spec.rb
|
327
333
|
- schemas/core_3.1.5/spec/core/command_request_spec.rb
|
328
334
|
- schemas/core_3.1.5/spec/core/command_response_spec.rb
|
329
335
|
- schemas/core_3.1.5/spec/core/core_spec.rb
|
@@ -501,6 +507,7 @@ files:
|
|
501
507
|
- schemas/tlc_1.0.13/spec/spec_helper.rb
|
502
508
|
- schemas/tlc_1.0.13/spec/tlc/M0001_spec.rb
|
503
509
|
- schemas/tlc_1.0.13/spec/tlc/S0007_spec.rb
|
510
|
+
- schemas/tlc_1.0.13/spec/tlc/S0023_spec.rb
|
504
511
|
- schemas/tlc_1.0.14/.gitignore
|
505
512
|
- schemas/tlc_1.0.14/.rspec
|
506
513
|
- schemas/tlc_1.0.14/Gemfile
|
@@ -593,6 +600,7 @@ files:
|
|
593
600
|
- schemas/tlc_1.0.14/spec/spec_helper.rb
|
594
601
|
- schemas/tlc_1.0.14/spec/tlc/M0001_spec.rb
|
595
602
|
- schemas/tlc_1.0.14/spec/tlc/S0007_spec.rb
|
603
|
+
- schemas/tlc_1.0.14/spec/tlc/S0023_spec.rb
|
596
604
|
- schemas/tlc_1.0.15/.gitignore
|
597
605
|
- schemas/tlc_1.0.15/.rspec
|
598
606
|
- schemas/tlc_1.0.15/Gemfile
|
@@ -692,6 +700,7 @@ files:
|
|
692
700
|
- schemas/tlc_1.0.15/spec/spec_helper.rb
|
693
701
|
- schemas/tlc_1.0.15/spec/tlc/M0001_spec.rb
|
694
702
|
- schemas/tlc_1.0.15/spec/tlc/S0007_spec.rb
|
703
|
+
- schemas/tlc_1.0.15/spec/tlc/S0023_spec.rb
|
695
704
|
- schemas/tlc_1.0.7/.gitignore
|
696
705
|
- schemas/tlc_1.0.7/.rspec
|
697
706
|
- schemas/tlc_1.0.7/Gemfile
|
@@ -936,7 +945,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
936
945
|
- !ruby/object:Gem::Version
|
937
946
|
version: '0'
|
938
947
|
requirements: []
|
939
|
-
rubygems_version: 3.2.
|
948
|
+
rubygems_version: 3.2.32
|
940
949
|
signing_key:
|
941
950
|
specification_version: 4
|
942
951
|
summary: Validate RSMP message against RSMP JSON Schema.
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'json_schemer'
|
2
|
-
|
3
|
-
message = {
|
4
|
-
"mType" => "rSMsg",
|
5
|
-
"mId" => "4173c2c8-a933-43cb-9425-66d4613731ed",
|
6
|
-
"type" => "CommandRequest",
|
7
|
-
"siteId" => [
|
8
|
-
{ "sId" => "RN+SI0001" }
|
9
|
-
],
|
10
|
-
"cId" => "O+14439=481WA001",
|
11
|
-
"arg" => [
|
12
|
-
{
|
13
|
-
"n" => "timeplan",
|
14
|
-
"cO" => "setPlan",
|
15
|
-
"v" => "1"
|
16
|
-
}
|
17
|
-
]
|
18
|
-
}
|
19
|
-
|
20
|
-
# try validating a message against our schema
|
21
|
-
schema_core = Pathname.new('schema/core/rsmp.json')
|
22
|
-
schemer_core = JSONSchemer.schema(schema_core)
|
23
|
-
|
24
|
-
def validate message, schemer
|
25
|
-
if schemer.valid? message
|
26
|
-
'ok'
|
27
|
-
else
|
28
|
-
schemer.validate(message).map do |item|
|
29
|
-
[item['data_pointer'],item['type'],item['details']].compact.join(' ')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
puts "core: #{validate message, schemer_core}"
|
35
|
-
|
@@ -1,72 +0,0 @@
|
|
1
|
-
RSpec.describe "Traffic Light Controller RSMP SXL Schema validation" do
|
2
|
-
let(:message) {{
|
3
|
-
"mType" => "rSMsg",
|
4
|
-
"type" => "Alarm",
|
5
|
-
"mId" => "E68A0010-C336-41ac-BD58-5C80A72C7092",
|
6
|
-
"cId" => "AB+84001=860SG001",
|
7
|
-
"aCId" => "A0001",
|
8
|
-
"aSp" => "Request"
|
9
|
-
}}
|
10
|
-
|
11
|
-
it 'accepts valid alarm request' do
|
12
|
-
expect( validate(message) ).to be_nil
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
it 'catches missing component id' do
|
17
|
-
invalid = message.dup
|
18
|
-
invalid.delete 'cId'
|
19
|
-
expect( validate(invalid) ).to eq([
|
20
|
-
["", "required", {"missing_keys"=>["cId"]}]
|
21
|
-
])
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'catches missing alarm code id' do
|
25
|
-
invalid = message.dup
|
26
|
-
invalid.delete 'aCId'
|
27
|
-
expect( validate(invalid) ).to eq([
|
28
|
-
["", "required", {"missing_keys"=>["aCId"]}]
|
29
|
-
])
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'catches bad alarm code id' do
|
33
|
-
invalid = message.dup
|
34
|
-
invalid['aCId'] = "001"
|
35
|
-
expect( validate(invalid) ).to eq([
|
36
|
-
["/aCId", "pattern"]
|
37
|
-
])
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'catches wrong alarm code id type' do
|
41
|
-
invalid = message.dup
|
42
|
-
invalid['aCId'] = 123
|
43
|
-
expect( validate(invalid) ).to eq([
|
44
|
-
["/aCId", "string"]
|
45
|
-
])
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'catches missing extended alarm code id' do
|
49
|
-
invalid = message.dup
|
50
|
-
invalid.delete 'xACId'
|
51
|
-
expect( validate(invalid) ).to eq([
|
52
|
-
["", "required", {"missing_keys"=>["xACId"]}]
|
53
|
-
])
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'catches wrong extended alarm code id type' do
|
57
|
-
invalid = message.dup
|
58
|
-
invalid['xACId'] = 123
|
59
|
-
expect( validate(invalid) ).to eq([
|
60
|
-
["/xACId", "string"]
|
61
|
-
])
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'catches extraneous alarm code id' do
|
65
|
-
invalid = message.dup
|
66
|
-
invalid['aS'] = 'Active'
|
67
|
-
expect( validate(invalid) ).to eq([
|
68
|
-
["", "required", {"missing_keys"=>["aS"]}]
|
69
|
-
])
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|