iotagent-node-lib 3.4.3 → 4.0.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.
- package/CHANGES_NEXT_RELEASE +0 -1
- package/README.md +4 -0
- package/doc/admin.md +1 -13
- package/doc/api.md +118 -14
- package/doc/devel/architecture.md +0 -12
- package/doc/index.md +1 -1
- package/doc/roadmap.md +22 -10
- package/lib/commonConfig.js +0 -11
- package/lib/model/Device.js +2 -1
- package/lib/model/Group.js +2 -1
- package/lib/model/dbConn.js +22 -11
- package/lib/plugins/expressionPlugin.js +0 -5
- package/lib/plugins/jexlParser.js +15 -31
- package/lib/services/common/genericMiddleware.js +14 -2
- package/lib/services/common/iotManagerService.js +2 -1
- package/lib/services/devices/deviceRegistryMongoDB.js +3 -1
- package/lib/services/devices/deviceService.js +16 -21
- package/lib/services/devices/devices-NGSI-LD.js +5 -98
- package/lib/services/devices/devices-NGSI-mixed.js +0 -14
- package/lib/services/devices/devices-NGSI-v2.js +3 -0
- package/lib/services/groups/groupRegistryMemory.js +0 -25
- package/lib/services/groups/groupRegistryMongoDB.js +20 -19
- package/lib/services/groups/groupService.js +3 -14
- package/lib/services/ngsi/entities-NGSI-LD.js +81 -6
- package/lib/services/ngsi/entities-NGSI-v2.js +304 -687
- package/lib/services/ngsi/ngsiUtils.js +0 -30
- package/lib/services/northBound/deviceProvisioningServer.js +6 -3
- package/lib/templates/createDevice.json +4 -0
- package/lib/templates/createDeviceLax.json +4 -0
- package/lib/templates/deviceGroup.json +4 -0
- package/lib/templates/updateDevice.json +4 -0
- package/lib/templates/updateDeviceLax.json +4 -0
- package/package.json +6 -2
- package/test/functional/README.md +378 -0
- package/test/functional/config-test.js +70 -0
- package/test/functional/functional-tests-runner.js +126 -0
- package/test/functional/functional-tests.js +241 -0
- package/test/functional/testCases.js +2944 -0
- package/test/functional/testUtils.js +251 -0
- package/test/tools/utils.js +25 -0
- package/test/unit/mongodb/mongodb-connectionoptions-test.js +35 -22
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +3 -34
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +8 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin7.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin8.json +1 -6
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +67 -87
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +7 -13
- package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +43 -43
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +19 -29
- package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +0 -1
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +35 -46
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +8 -9
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +96 -221
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +18 -27
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +8 -16
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +0 -13
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +4 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29b.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +0 -6
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34b.json +14 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +1 -11
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36b.json +13 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin37.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +1 -11
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10b.json +37 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +4 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +0 -3
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +10 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -5
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +8 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +0 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +7 -1
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +898 -28
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +188 -1
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +267 -0
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +19 -21
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +21 -24
- package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -21
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +4 -6
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +0 -438
- package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +0 -381
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +0 -311
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +0 -325
- package/test/unit/ngsiv2/ngsiService/geoproperties-test.js +0 -427
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +0 -217
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +0 -119
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -309
|
@@ -156,6 +156,52 @@ const iotAgentConfig = {
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
]
|
|
159
|
+
},
|
|
160
|
+
StupidDevice: {
|
|
161
|
+
type: 'StupidDevice',
|
|
162
|
+
commands: [],
|
|
163
|
+
lazy: [],
|
|
164
|
+
staticAttributes: [],
|
|
165
|
+
active: [
|
|
166
|
+
{
|
|
167
|
+
name: 'type',
|
|
168
|
+
object_id: 't',
|
|
169
|
+
type: 'text'
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: 'id',
|
|
173
|
+
object_id: 'i',
|
|
174
|
+
type: 'text'
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: 'meas',
|
|
178
|
+
object_id: 'm',
|
|
179
|
+
type: 'String'
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
StupidDevice2: {
|
|
184
|
+
type: 'StupidDevice2',
|
|
185
|
+
commands: [],
|
|
186
|
+
lazy: [],
|
|
187
|
+
staticAttributes: [],
|
|
188
|
+
active: [
|
|
189
|
+
{
|
|
190
|
+
name: 'type',
|
|
191
|
+
object_id: 'type',
|
|
192
|
+
type: 'text'
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: 'id',
|
|
196
|
+
object_id: 'id',
|
|
197
|
+
type: 'text'
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: 'meas',
|
|
201
|
+
object_id: 'meas',
|
|
202
|
+
type: 'String'
|
|
203
|
+
}
|
|
204
|
+
]
|
|
159
205
|
}
|
|
160
206
|
},
|
|
161
207
|
service: 'smartgondor',
|
|
@@ -331,7 +377,6 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
331
377
|
];
|
|
332
378
|
|
|
333
379
|
timekeeper.freeze(time);
|
|
334
|
-
|
|
335
380
|
nock.cleanAll();
|
|
336
381
|
|
|
337
382
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
@@ -856,6 +901,147 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
856
901
|
});
|
|
857
902
|
});
|
|
858
903
|
|
|
904
|
+
describe('When the IoT Agent receives autoprovisioned id and type measures', function () {
|
|
905
|
+
const valuesIdType = [
|
|
906
|
+
{
|
|
907
|
+
name: 'id',
|
|
908
|
+
type: 'text',
|
|
909
|
+
value: 'idIoTA'
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
name: 'type',
|
|
913
|
+
type: 'text',
|
|
914
|
+
value: 'typeIoTA'
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
name: 'm',
|
|
918
|
+
type: 'text',
|
|
919
|
+
value: 'measIoTA'
|
|
920
|
+
}
|
|
921
|
+
];
|
|
922
|
+
|
|
923
|
+
beforeEach(function (done) {
|
|
924
|
+
nock.cleanAll();
|
|
925
|
+
|
|
926
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
927
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
928
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
929
|
+
.post('/v2/entities?options=upsert', {
|
|
930
|
+
id: 'stupiddevice1',
|
|
931
|
+
type: 'StupidDevice',
|
|
932
|
+
meas: {
|
|
933
|
+
value: 'measIoTA',
|
|
934
|
+
type: 'String'
|
|
935
|
+
}
|
|
936
|
+
})
|
|
937
|
+
.reply(204);
|
|
938
|
+
|
|
939
|
+
iotAgentLib.activate(iotAgentConfig, done);
|
|
940
|
+
});
|
|
941
|
+
|
|
942
|
+
it('should not affect to the real ID and Type to store in the context broker', function (done) {
|
|
943
|
+
iotAgentLib.update('stupiddevice1', 'StupidDevice', '', valuesIdType, function (error) {
|
|
944
|
+
should.not.exist(error);
|
|
945
|
+
contextBrokerMock.done();
|
|
946
|
+
done();
|
|
947
|
+
});
|
|
948
|
+
});
|
|
949
|
+
});
|
|
950
|
+
|
|
951
|
+
describe('When the IoT Agent receives provisioned id and type measures with different object_id names', function () {
|
|
952
|
+
const valuesIdType2 = [
|
|
953
|
+
{
|
|
954
|
+
name: 'i',
|
|
955
|
+
type: 'text',
|
|
956
|
+
value: 'idIoTA2'
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
name: 't',
|
|
960
|
+
type: 'text',
|
|
961
|
+
value: 'typeIoTA2'
|
|
962
|
+
},
|
|
963
|
+
{
|
|
964
|
+
name: 'm',
|
|
965
|
+
type: 'text',
|
|
966
|
+
value: 'measIoTA2'
|
|
967
|
+
}
|
|
968
|
+
];
|
|
969
|
+
|
|
970
|
+
beforeEach(function (done) {
|
|
971
|
+
nock.cleanAll();
|
|
972
|
+
|
|
973
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
974
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
975
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
976
|
+
.post('/v2/entities?options=upsert', {
|
|
977
|
+
id: 'stupiddevice2',
|
|
978
|
+
type: 'StupidDevice',
|
|
979
|
+
meas: {
|
|
980
|
+
value: 'measIoTA2',
|
|
981
|
+
type: 'String'
|
|
982
|
+
}
|
|
983
|
+
})
|
|
984
|
+
.reply(204);
|
|
985
|
+
|
|
986
|
+
iotAgentLib.activate(iotAgentConfig, done);
|
|
987
|
+
});
|
|
988
|
+
|
|
989
|
+
it('should not affect to the real ID and Type to store in the context broker', function (done) {
|
|
990
|
+
iotAgentLib.update('stupiddevice2', 'StupidDevice', '', valuesIdType2, function (error) {
|
|
991
|
+
should.not.exist(error);
|
|
992
|
+
contextBrokerMock.done();
|
|
993
|
+
done();
|
|
994
|
+
});
|
|
995
|
+
});
|
|
996
|
+
});
|
|
997
|
+
|
|
998
|
+
describe('When the IoT Agent receives provisioned id and type measures with the same object_id name', function () {
|
|
999
|
+
const valuesIdType3 = [
|
|
1000
|
+
{
|
|
1001
|
+
name: 'id',
|
|
1002
|
+
type: 'text',
|
|
1003
|
+
value: 'idIoTA'
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
name: 'type',
|
|
1007
|
+
type: 'text',
|
|
1008
|
+
value: 'typeIoTA'
|
|
1009
|
+
},
|
|
1010
|
+
{
|
|
1011
|
+
name: 'meas',
|
|
1012
|
+
type: 'text',
|
|
1013
|
+
value: 'measIoTA'
|
|
1014
|
+
}
|
|
1015
|
+
];
|
|
1016
|
+
|
|
1017
|
+
beforeEach(function (done) {
|
|
1018
|
+
nock.cleanAll();
|
|
1019
|
+
|
|
1020
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1021
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1022
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1023
|
+
.post('/v2/entities?options=upsert', {
|
|
1024
|
+
id: 'stupiddevice3',
|
|
1025
|
+
type: 'StupidDevice2',
|
|
1026
|
+
meas: {
|
|
1027
|
+
value: 'measIoTA',
|
|
1028
|
+
type: 'String'
|
|
1029
|
+
}
|
|
1030
|
+
})
|
|
1031
|
+
.reply(204);
|
|
1032
|
+
|
|
1033
|
+
iotAgentLib.activate(iotAgentConfig, done);
|
|
1034
|
+
});
|
|
1035
|
+
|
|
1036
|
+
it('should not affect to the real ID and Type to store in the context broker', function (done) {
|
|
1037
|
+
iotAgentLib.update('stupiddevice3', 'StupidDevice2', '', valuesIdType3, function (error) {
|
|
1038
|
+
should.not.exist(error);
|
|
1039
|
+
contextBrokerMock.done();
|
|
1040
|
+
done();
|
|
1041
|
+
});
|
|
1042
|
+
});
|
|
1043
|
+
});
|
|
1044
|
+
|
|
859
1045
|
describe('When the IoT Agent receives new information from a device and CBis defined using environment variables', function () {
|
|
860
1046
|
beforeEach(function (done) {
|
|
861
1047
|
process.env.IOTA_CB_HOST = 'cbhost';
|
|
@@ -873,6 +1059,7 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
873
1059
|
|
|
874
1060
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
875
1061
|
});
|
|
1062
|
+
|
|
876
1063
|
it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
877
1064
|
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
878
1065
|
should.not.exist(error);
|
|
@@ -75,6 +75,102 @@ const iotAgentConfig = {
|
|
|
75
75
|
type: 'type4'
|
|
76
76
|
}
|
|
77
77
|
]
|
|
78
|
+
},
|
|
79
|
+
Light_Explicit_True: {
|
|
80
|
+
commands: [],
|
|
81
|
+
type: 'Light_Explicit_True',
|
|
82
|
+
explicitAttrs: true,
|
|
83
|
+
timestamp: false,
|
|
84
|
+
active: [
|
|
85
|
+
{
|
|
86
|
+
name: 'pressure',
|
|
87
|
+
type: 'Number'
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
staticAttributes: [
|
|
91
|
+
{
|
|
92
|
+
name: 'attr1',
|
|
93
|
+
type: 'Text',
|
|
94
|
+
value: 'Static Text'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'attr2',
|
|
98
|
+
type: 'Number',
|
|
99
|
+
value: 123
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
Light_Explicit_False: {
|
|
104
|
+
commands: [],
|
|
105
|
+
type: 'Light_Explicit_False',
|
|
106
|
+
explicitAttrs: false,
|
|
107
|
+
timestamp: false,
|
|
108
|
+
active: [
|
|
109
|
+
{
|
|
110
|
+
name: 'pressure',
|
|
111
|
+
type: 'Number'
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
staticAttributes: [
|
|
115
|
+
{
|
|
116
|
+
name: 'attr1',
|
|
117
|
+
type: 'Text',
|
|
118
|
+
value: 'Static Text'
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'attr2',
|
|
122
|
+
type: 'Number',
|
|
123
|
+
value: 123
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
Light_Explicit_Array: {
|
|
128
|
+
commands: [],
|
|
129
|
+
type: 'Light_Explicit_Array',
|
|
130
|
+
explicitAttrs: '[ "pressure", "attr1" ]',
|
|
131
|
+
timestamp: false,
|
|
132
|
+
active: [
|
|
133
|
+
{
|
|
134
|
+
name: 'pressure',
|
|
135
|
+
type: 'Number'
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
staticAttributes: [
|
|
139
|
+
{
|
|
140
|
+
name: 'attr1',
|
|
141
|
+
type: 'Text',
|
|
142
|
+
value: 'Static Text'
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: 'attr2',
|
|
146
|
+
type: 'Number',
|
|
147
|
+
value: 123
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
Light_Explicit_Expression: {
|
|
152
|
+
commands: [],
|
|
153
|
+
type: 'Light_Explicit_Expression',
|
|
154
|
+
explicitAttrs: ' pressure ? [ "pressure", "attr1" ] : [ "attr2" ] ',
|
|
155
|
+
timestamp: false,
|
|
156
|
+
active: [
|
|
157
|
+
{
|
|
158
|
+
name: 'pressure',
|
|
159
|
+
type: 'Number'
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
staticAttributes: [
|
|
163
|
+
{
|
|
164
|
+
name: 'attr1',
|
|
165
|
+
type: 'Text',
|
|
166
|
+
value: 'Static Text'
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: 'attr2',
|
|
170
|
+
type: 'Number',
|
|
171
|
+
value: 123
|
|
172
|
+
}
|
|
173
|
+
]
|
|
78
174
|
}
|
|
79
175
|
},
|
|
80
176
|
timestamp: true,
|
|
@@ -146,4 +242,175 @@ describe('NGSI-v2 - Static attributes test', function () {
|
|
|
146
242
|
);
|
|
147
243
|
});
|
|
148
244
|
});
|
|
245
|
+
|
|
246
|
+
describe('When using explicitAttrs true', function () {
|
|
247
|
+
const newValues = [
|
|
248
|
+
{
|
|
249
|
+
name: 'pressure',
|
|
250
|
+
type: 'Number',
|
|
251
|
+
value: 321
|
|
252
|
+
}
|
|
253
|
+
];
|
|
254
|
+
|
|
255
|
+
beforeEach(function (done) {
|
|
256
|
+
nock.cleanAll();
|
|
257
|
+
|
|
258
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
259
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
260
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
261
|
+
.post('/v2/entities?options=upsert', {
|
|
262
|
+
id: 'light2',
|
|
263
|
+
type: 'Light_Explicit_True',
|
|
264
|
+
pressure: {
|
|
265
|
+
value: 321,
|
|
266
|
+
type: 'Number'
|
|
267
|
+
},
|
|
268
|
+
attr1: {
|
|
269
|
+
value: 'Static Text',
|
|
270
|
+
type: 'Text'
|
|
271
|
+
},
|
|
272
|
+
attr2: {
|
|
273
|
+
value: 123,
|
|
274
|
+
type: 'Number'
|
|
275
|
+
}
|
|
276
|
+
})
|
|
277
|
+
.reply(204);
|
|
278
|
+
|
|
279
|
+
iotAgentLib.activate(iotAgentConfig, done);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('should include all the statics', function (done) {
|
|
283
|
+
iotAgentLib.update('light2', 'Light_Explicit_True', '', newValues, function (error) {
|
|
284
|
+
should.not.exist(error);
|
|
285
|
+
contextBrokerMock.done();
|
|
286
|
+
done();
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
describe('When using explicitAttrs false', function () {
|
|
292
|
+
const newValues = [
|
|
293
|
+
{
|
|
294
|
+
name: 'pressure',
|
|
295
|
+
type: 'Number',
|
|
296
|
+
value: 321
|
|
297
|
+
}
|
|
298
|
+
];
|
|
299
|
+
|
|
300
|
+
beforeEach(function (done) {
|
|
301
|
+
nock.cleanAll();
|
|
302
|
+
|
|
303
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
304
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
305
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
306
|
+
.post('/v2/entities?options=upsert', {
|
|
307
|
+
id: 'light2',
|
|
308
|
+
type: 'Light_Explicit_True',
|
|
309
|
+
pressure: {
|
|
310
|
+
value: 321,
|
|
311
|
+
type: 'Number'
|
|
312
|
+
},
|
|
313
|
+
attr1: {
|
|
314
|
+
value: 'Static Text',
|
|
315
|
+
type: 'Text'
|
|
316
|
+
},
|
|
317
|
+
attr2: {
|
|
318
|
+
value: 123,
|
|
319
|
+
type: 'Number'
|
|
320
|
+
}
|
|
321
|
+
})
|
|
322
|
+
.reply(204);
|
|
323
|
+
|
|
324
|
+
iotAgentLib.activate(iotAgentConfig, done);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('should include all the statics', function (done) {
|
|
328
|
+
iotAgentLib.update('light2', 'Light_Explicit_True', '', newValues, function (error) {
|
|
329
|
+
should.not.exist(error);
|
|
330
|
+
contextBrokerMock.done();
|
|
331
|
+
done();
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
describe('When using explicitAttrs as array', function () {
|
|
337
|
+
const newValues = [
|
|
338
|
+
{
|
|
339
|
+
name: 'pressure',
|
|
340
|
+
type: 'Number',
|
|
341
|
+
value: 321
|
|
342
|
+
}
|
|
343
|
+
];
|
|
344
|
+
|
|
345
|
+
beforeEach(function (done) {
|
|
346
|
+
nock.cleanAll();
|
|
347
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
348
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
349
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
350
|
+
.post('/v2/entities?options=upsert', {
|
|
351
|
+
id: 'light2',
|
|
352
|
+
type: 'Light_Explicit_Array',
|
|
353
|
+
pressure: {
|
|
354
|
+
value: 321,
|
|
355
|
+
type: 'Number'
|
|
356
|
+
},
|
|
357
|
+
attr1: {
|
|
358
|
+
value: 'Static Text',
|
|
359
|
+
type: 'Text'
|
|
360
|
+
}
|
|
361
|
+
})
|
|
362
|
+
.reply(204);
|
|
363
|
+
|
|
364
|
+
iotAgentLib.activate(iotAgentConfig, done);
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
it('should include only statics defined into the array', function (done) {
|
|
368
|
+
iotAgentLib.update('light2', 'Light_Explicit_Array', '', newValues, function (error) {
|
|
369
|
+
should.not.exist(error);
|
|
370
|
+
contextBrokerMock.done();
|
|
371
|
+
done();
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
describe('When using explicitAttrs as expression', function () {
|
|
377
|
+
const newValues = [
|
|
378
|
+
{
|
|
379
|
+
name: 'pressure',
|
|
380
|
+
type: 'Number',
|
|
381
|
+
value: 321
|
|
382
|
+
}
|
|
383
|
+
];
|
|
384
|
+
|
|
385
|
+
beforeEach(function (done) {
|
|
386
|
+
nock.cleanAll();
|
|
387
|
+
|
|
388
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
389
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
390
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
391
|
+
.post('/v2/entities?options=upsert', {
|
|
392
|
+
id: 'light2',
|
|
393
|
+
type: 'Light_Explicit_Expression',
|
|
394
|
+
pressure: {
|
|
395
|
+
value: 321,
|
|
396
|
+
type: 'Number'
|
|
397
|
+
},
|
|
398
|
+
attr1: {
|
|
399
|
+
value: 'Static Text',
|
|
400
|
+
type: 'Text'
|
|
401
|
+
}
|
|
402
|
+
})
|
|
403
|
+
.reply(204);
|
|
404
|
+
|
|
405
|
+
iotAgentLib.activate(iotAgentConfig, done);
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
it('should include statics as the result on the expression', function (done) {
|
|
409
|
+
iotAgentLib.update('light2', 'Light_Explicit_Expression', '', newValues, function (error) {
|
|
410
|
+
should.not.exist(error);
|
|
411
|
+
contextBrokerMock.done();
|
|
412
|
+
done();
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
});
|
|
149
416
|
});
|
|
@@ -32,7 +32,6 @@ const logger = require('logops');
|
|
|
32
32
|
const nock = require('nock');
|
|
33
33
|
let contextBrokerMock;
|
|
34
34
|
const iotAgentConfig = {
|
|
35
|
-
autocast: true,
|
|
36
35
|
contextBroker: {
|
|
37
36
|
host: '192.168.1.1',
|
|
38
37
|
port: '1026',
|
|
@@ -90,7 +89,8 @@ const iotAgentConfig = {
|
|
|
90
89
|
{
|
|
91
90
|
object_id: 'al',
|
|
92
91
|
name: 'keep_alive',
|
|
93
|
-
type: 'None'
|
|
92
|
+
type: 'None',
|
|
93
|
+
skipValue: 'null passes'
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
object_id: 'ta',
|
|
@@ -113,7 +113,6 @@ const iotAgentConfig = {
|
|
|
113
113
|
describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
114
114
|
beforeEach(function (done) {
|
|
115
115
|
logger.setLevel('FATAL');
|
|
116
|
-
|
|
117
116
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
118
117
|
iotAgentLib.clearAll(function () {
|
|
119
118
|
done();
|
|
@@ -131,7 +130,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
131
130
|
{
|
|
132
131
|
name: 't',
|
|
133
132
|
type: 'centigrades',
|
|
134
|
-
value:
|
|
133
|
+
value: 52
|
|
135
134
|
},
|
|
136
135
|
{
|
|
137
136
|
name: 'p',
|
|
@@ -153,7 +152,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
153
152
|
.reply(204);
|
|
154
153
|
});
|
|
155
154
|
|
|
156
|
-
it('should rename the attributes as expected by the alias mappings
|
|
155
|
+
it('should rename the attributes as expected by the alias mappings', function (done) {
|
|
157
156
|
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
158
157
|
should.not.exist(error);
|
|
159
158
|
contextBrokerMock.done();
|
|
@@ -166,7 +165,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
166
165
|
{
|
|
167
166
|
name: 'l',
|
|
168
167
|
type: 'lums',
|
|
169
|
-
value:
|
|
168
|
+
value: 9
|
|
170
169
|
}
|
|
171
170
|
];
|
|
172
171
|
|
|
@@ -183,7 +182,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
183
182
|
.reply(204);
|
|
184
183
|
});
|
|
185
184
|
|
|
186
|
-
it('should rename the attributes as expected by the alias mappings
|
|
185
|
+
it('should rename the attributes as expected by the alias mappings', function (done) {
|
|
187
186
|
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
188
187
|
should.not.exist(error);
|
|
189
188
|
contextBrokerMock.done();
|
|
@@ -196,7 +195,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
196
195
|
{
|
|
197
196
|
name: 'ut',
|
|
198
197
|
type: 'Number',
|
|
199
|
-
value:
|
|
198
|
+
value: 99823423
|
|
200
199
|
}
|
|
201
200
|
];
|
|
202
201
|
|
|
@@ -227,7 +226,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
227
226
|
{
|
|
228
227
|
name: 'ut',
|
|
229
228
|
type: 'Number',
|
|
230
|
-
value:
|
|
229
|
+
value: 99823423
|
|
231
230
|
}
|
|
232
231
|
];
|
|
233
232
|
|
|
@@ -244,7 +243,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
244
243
|
.reply(204);
|
|
245
244
|
});
|
|
246
245
|
|
|
247
|
-
it('should rename the attributes as expected by the alias mappings
|
|
246
|
+
it('should rename the attributes as expected by the alias mappings', function (done) {
|
|
248
247
|
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
249
248
|
should.not.exist(error);
|
|
250
249
|
contextBrokerMock.done();
|
|
@@ -258,7 +257,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
258
257
|
{
|
|
259
258
|
name: 'ap',
|
|
260
259
|
type: 'Number',
|
|
261
|
-
value:
|
|
260
|
+
value: 0.45
|
|
262
261
|
}
|
|
263
262
|
];
|
|
264
263
|
|
|
@@ -275,7 +274,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
275
274
|
.reply(204);
|
|
276
275
|
});
|
|
277
276
|
|
|
278
|
-
it('should rename the attributes as expected by the alias mappings
|
|
277
|
+
it('should rename the attributes as expected by the alias mappings', function (done) {
|
|
279
278
|
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
280
279
|
should.not.exist(error);
|
|
281
280
|
contextBrokerMock.done();
|
|
@@ -306,7 +305,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
306
305
|
.reply(204);
|
|
307
306
|
});
|
|
308
307
|
|
|
309
|
-
it('should rename the attributes as expected by the alias mappings
|
|
308
|
+
it('should rename the attributes as expected by the alias mappings', function (done) {
|
|
310
309
|
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
311
310
|
should.not.exist(error);
|
|
312
311
|
contextBrokerMock.done();
|
|
@@ -320,13 +319,12 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
320
319
|
{
|
|
321
320
|
name: 'al',
|
|
322
321
|
type: 'None',
|
|
323
|
-
value:
|
|
322
|
+
value: null
|
|
324
323
|
}
|
|
325
324
|
];
|
|
326
325
|
|
|
327
326
|
beforeEach(function () {
|
|
328
327
|
nock.cleanAll();
|
|
329
|
-
|
|
330
328
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
331
329
|
.matchHeader('fiware-service', 'smartgondor')
|
|
332
330
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
@@ -337,7 +335,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
337
335
|
.reply(204);
|
|
338
336
|
});
|
|
339
337
|
|
|
340
|
-
it('should rename the attributes as expected by the alias mappings
|
|
338
|
+
it('should rename the attributes as expected by the alias mappings', function (done) {
|
|
341
339
|
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
342
340
|
should.not.exist(error);
|
|
343
341
|
contextBrokerMock.done();
|
|
@@ -351,7 +349,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
351
349
|
{
|
|
352
350
|
name: 'ta',
|
|
353
351
|
type: 'Array',
|
|
354
|
-
value: '
|
|
352
|
+
value: ['iot', 'device']
|
|
355
353
|
}
|
|
356
354
|
];
|
|
357
355
|
|
|
@@ -368,7 +366,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
368
366
|
.reply(204);
|
|
369
367
|
});
|
|
370
368
|
|
|
371
|
-
it('should rename the attributes as expected by the alias mappings
|
|
369
|
+
it('should rename the attributes as expected by the alias mappings', function (done) {
|
|
372
370
|
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
373
371
|
should.not.exist(error);
|
|
374
372
|
contextBrokerMock.done();
|
|
@@ -382,7 +380,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
382
380
|
{
|
|
383
381
|
name: 'c',
|
|
384
382
|
type: 'Object',
|
|
385
|
-
value:
|
|
383
|
+
value: { firmware: { version: '1.1.0', hash: 'cf23df2207d99a74fbe169e3eba035e633b65d94' } }
|
|
386
384
|
}
|
|
387
385
|
];
|
|
388
386
|
|
|
@@ -399,7 +397,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
399
397
|
.reply(204);
|
|
400
398
|
});
|
|
401
399
|
|
|
402
|
-
it('should rename the attributes as expected by the alias mappings
|
|
400
|
+
it('should rename the attributes as expected by the alias mappings', function (done) {
|
|
403
401
|
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
404
402
|
should.not.exist(error);
|
|
405
403
|
contextBrokerMock.done();
|
|
@@ -430,7 +428,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
430
428
|
.reply(204);
|
|
431
429
|
});
|
|
432
430
|
|
|
433
|
-
it('should rename the attributes as expected by the alias mappings
|
|
431
|
+
it('should rename the attributes as expected by the alias mappings', function (done) {
|
|
434
432
|
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
435
433
|
should.not.exist(error);
|
|
436
434
|
contextBrokerMock.done();
|