iotagent-node-lib 3.2.0 → 3.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.
- package/.github/ISSUE_TEMPLATE/bug_report.yml +134 -0
- package/.github/ISSUE_TEMPLATE/config.yml +16 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +55 -0
- package/.github/advanced-issue-labeler.yml +30 -0
- package/.github/workflows/issue-labeler.yml +43 -0
- package/README.md +10 -11
- package/doc/README.md +16 -0
- package/doc/admin.md +565 -0
- package/doc/api.md +32 -85
- package/doc/deprecated.md +16 -10
- package/doc/{architecture.md → devel/architecture.md} +3 -3
- package/doc/{Contribution.md → devel/contribution-guidelines.md} +43 -35
- package/doc/devel/development.md +1879 -0
- package/doc/{northboundinteractions.md → devel/northboundinteractions.md} +18 -33
- package/doc/index.md +3 -5
- package/doc/requirements.txt +1 -1
- package/docker/Mosquitto/Dockerfile +1 -1
- package/docker/Mosquitto/README.md +1 -0
- package/lib/commonConfig.js +0 -5
- package/lib/fiware-iotagent-lib.js +1 -1
- package/lib/jexlTranformsMap.js +2 -1
- package/lib/model/Device.js +0 -1
- package/lib/model/Group.js +0 -1
- package/lib/model/dbConn.js +1 -7
- package/lib/plugins/jexlParser.js +1 -1
- package/lib/request-shim.js +2 -2
- package/lib/services/commands/commandService.js +1 -1
- package/lib/services/common/genericMiddleware.js +1 -1
- package/lib/services/common/iotManagerService.js +0 -1
- package/lib/services/devices/deviceRegistryMemory.js +2 -2
- package/lib/services/devices/deviceRegistryMongoDB.js +32 -19
- package/lib/services/devices/deviceService.js +44 -43
- package/lib/services/devices/devices-NGSI-LD.js +14 -2
- package/lib/services/devices/devices-NGSI-mixed.js +0 -2
- package/lib/services/devices/devices-NGSI-v2.js +23 -104
- package/lib/services/groups/groupService.js +1 -1
- package/lib/services/ngsi/entities-NGSI-LD.js +3 -3
- package/lib/services/ngsi/entities-NGSI-v2.js +28 -19
- package/lib/services/northBound/deviceProvisioningServer.js +14 -8
- package/lib/templates/createDevice.json +0 -4
- package/lib/templates/createDeviceLax.json +0 -4
- package/lib/templates/deviceGroup.json +1 -5
- package/lib/templates/updateDevice.json +4 -0
- package/lib/templates/updateDeviceLax.json +11 -0
- package/mkdocs.yml +6 -11
- package/package.json +3 -3
- package/scripts/legacy_expression_tool/README.md +280 -0
- package/scripts/legacy_expression_tool/legacy_expression_tool.py +423 -0
- package/scripts/legacy_expression_tool/requirements.txt +3 -0
- package/test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice4.json +0 -1
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +5 -15
- package/test/unit/mongodb/mongodb-registry-test.js +1 -1
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +66 -65
- package/test/unit/ngsi-ld/general/https-support-test.js +1 -1
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +8 -7
- package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +31 -30
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +12 -11
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +41 -39
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +122 -122
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +28 -28
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +18 -17
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +7 -7
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +8 -7
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +33 -37
- package/test/unit/ngsiv2/examples/contextRequests/updateContext.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext1.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext4.json +4 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContext5.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext6.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin2.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin4.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin5.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin6.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin7.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin9.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast1.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast2.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast3.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast4.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast5.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast6.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast7.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandError.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandExpired.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandFinish.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus2.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp1.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp2.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +2 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +2 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +2 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json +1 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +1 -10
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +2 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionSkip.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityJexlExpressionPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin17.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +2 -6
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin9.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributes.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestamp.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalse.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalseTimeInstant.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampTimezone.json +3 -1
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +144 -85
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +20 -53
- package/test/unit/ngsiv2/general/https-support-test.js +2 -6
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +4 -10
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +8 -24
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +146 -65
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +14 -21
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +3 -5
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +11 -20
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +20 -30
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +4 -6
- package/test/unit/ngsiv2/plugins/custom-plugin_test.js +1 -2
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +3 -5
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -3
- package/test/unit/ngsiv2/provisioning/device-group-api-test.js +2 -3
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +13 -156
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +9 -13
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +4 -10
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -11
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +0 -8
- package/test/unit/plugins/capture-provision-inPlugins_test.js +0 -6
- package/.nyc_output/33364de2-1199-4ec2-b33c-cae063ef8cc4.json +0 -1
- package/.nyc_output/processinfo/33364de2-1199-4ec2-b33c-cae063ef8cc4.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/doc/config-basic-example.js +0 -20
- package/doc/development.md +0 -285
- package/doc/howto.md +0 -645
- package/doc/installationguide.md +0 -370
- package/doc/operations.md +0 -127
- package/doc/usermanual.md +0 -900
- package/lib/plugins/bidirectionalData.js +0 -356
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +0 -697
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +0 -599
- /package/doc/{NorthboundInteractions.postman_collection → devel/NorthboundInteractions.postman_collection} +0 -0
- /package/doc/{echo.js → devel/echo.js} +0 -0
- /package/doc/{finalResult.js → devel/finalResult.js} +0 -0
|
@@ -60,6 +60,23 @@ const iotAgentConfig = {
|
|
|
60
60
|
}
|
|
61
61
|
]
|
|
62
62
|
},
|
|
63
|
+
LightNoTimestamp: {
|
|
64
|
+
commands: [],
|
|
65
|
+
type: 'Light',
|
|
66
|
+
lazy: [
|
|
67
|
+
{
|
|
68
|
+
name: 'temperature',
|
|
69
|
+
type: 'centigrades'
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
timestamp: false,
|
|
73
|
+
active: [
|
|
74
|
+
{
|
|
75
|
+
name: 'pressure',
|
|
76
|
+
type: 'Hgmm'
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
63
80
|
BrokenLight: {
|
|
64
81
|
commands: [],
|
|
65
82
|
lazy: [
|
|
@@ -175,11 +192,10 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
175
192
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
176
193
|
.matchHeader('fiware-service', 'smartgondor')
|
|
177
194
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
178
|
-
.
|
|
179
|
-
'/v2/entities
|
|
195
|
+
.post(
|
|
196
|
+
'/v2/entities?options=upsert',
|
|
180
197
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json')
|
|
181
198
|
)
|
|
182
|
-
.query({ type: 'Light' })
|
|
183
199
|
.reply(204);
|
|
184
200
|
|
|
185
201
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -192,22 +208,53 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
192
208
|
done();
|
|
193
209
|
});
|
|
194
210
|
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
describe('When the IoT Agent receives new information and the timestamp flag is on', function () {
|
|
214
|
+
let modifiedValues;
|
|
195
215
|
|
|
196
|
-
|
|
197
|
-
const
|
|
216
|
+
beforeEach(function (done) {
|
|
217
|
+
const time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00
|
|
218
|
+
|
|
219
|
+
modifiedValues = [
|
|
198
220
|
{
|
|
199
|
-
name: '
|
|
200
|
-
type: '
|
|
201
|
-
value:
|
|
221
|
+
name: 'state',
|
|
222
|
+
type: 'boolean',
|
|
223
|
+
value: true
|
|
202
224
|
},
|
|
203
225
|
{
|
|
204
|
-
name: '
|
|
205
|
-
type: '
|
|
206
|
-
value:
|
|
226
|
+
name: 'dimming',
|
|
227
|
+
type: 'number',
|
|
228
|
+
value: 87
|
|
207
229
|
}
|
|
208
230
|
];
|
|
209
231
|
|
|
210
|
-
|
|
232
|
+
timekeeper.freeze(time);
|
|
233
|
+
|
|
234
|
+
nock.cleanAll();
|
|
235
|
+
|
|
236
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
237
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
238
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
239
|
+
.post(
|
|
240
|
+
'/v2/entities?options=upsert',
|
|
241
|
+
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextTimestamp.json')
|
|
242
|
+
)
|
|
243
|
+
.reply(204);
|
|
244
|
+
|
|
245
|
+
iotAgentConfig.timestamp = true;
|
|
246
|
+
iotAgentLib.activate(iotAgentConfig, done);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
afterEach(function (done) {
|
|
250
|
+
delete iotAgentConfig.timestamp;
|
|
251
|
+
timekeeper.reset();
|
|
252
|
+
|
|
253
|
+
done();
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('should add the timestamp to the entity and all the attributes', function (done) {
|
|
257
|
+
iotAgentLib.update('light1', 'Light', '', modifiedValues, function (error) {
|
|
211
258
|
should.not.exist(error);
|
|
212
259
|
contextBrokerMock.done();
|
|
213
260
|
done();
|
|
@@ -215,12 +262,10 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
215
262
|
});
|
|
216
263
|
});
|
|
217
264
|
|
|
218
|
-
describe('When the IoT Agent receives new information and the timestamp flag is
|
|
265
|
+
describe('When the IoT Agent receives new information and the timestamp flag is false', function () {
|
|
219
266
|
let modifiedValues;
|
|
220
267
|
|
|
221
268
|
beforeEach(function (done) {
|
|
222
|
-
const time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00
|
|
223
|
-
|
|
224
269
|
modifiedValues = [
|
|
225
270
|
{
|
|
226
271
|
name: 'state',
|
|
@@ -234,6 +279,57 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
234
279
|
}
|
|
235
280
|
];
|
|
236
281
|
|
|
282
|
+
nock.cleanAll();
|
|
283
|
+
|
|
284
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
285
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
286
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
287
|
+
.post(
|
|
288
|
+
'/v2/entities?options=upsert',
|
|
289
|
+
utils.readExampleFile(
|
|
290
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalse.json'
|
|
291
|
+
)
|
|
292
|
+
)
|
|
293
|
+
.reply(204);
|
|
294
|
+
|
|
295
|
+
iotAgentConfig.timestamp = false;
|
|
296
|
+
iotAgentLib.activate(iotAgentConfig, done);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
afterEach(function (done) {
|
|
300
|
+
delete iotAgentConfig.timestamp;
|
|
301
|
+
|
|
302
|
+
done();
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
it('should not add the timestamp to the entity and the attributes', function (done) {
|
|
306
|
+
iotAgentLib.update('lightNoTimestamp1', 'LightNoTimestamp', '', modifiedValues, function (error) {
|
|
307
|
+
should.not.exist(error);
|
|
308
|
+
contextBrokerMock.done();
|
|
309
|
+
done();
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
describe('When the IoT Agent receives new information and the timestamp flag is false but the measure contains timeInstant', function () {
|
|
315
|
+
let modifiedValues;
|
|
316
|
+
|
|
317
|
+
beforeEach(function (done) {
|
|
318
|
+
const time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00
|
|
319
|
+
|
|
320
|
+
modifiedValues = [
|
|
321
|
+
{
|
|
322
|
+
name: 'state',
|
|
323
|
+
type: 'boolean',
|
|
324
|
+
value: true
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
name: 'TimeInstant',
|
|
328
|
+
type: 'DateTime',
|
|
329
|
+
value: '2015-12-14T08:06:01.468Z'
|
|
330
|
+
}
|
|
331
|
+
];
|
|
332
|
+
|
|
237
333
|
timekeeper.freeze(time);
|
|
238
334
|
|
|
239
335
|
nock.cleanAll();
|
|
@@ -241,14 +337,15 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
241
337
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
242
338
|
.matchHeader('fiware-service', 'smartgondor')
|
|
243
339
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
244
|
-
.
|
|
245
|
-
'/v2/entities
|
|
246
|
-
utils.readExampleFile(
|
|
340
|
+
.post(
|
|
341
|
+
'/v2/entities?options=upsert',
|
|
342
|
+
utils.readExampleFile(
|
|
343
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalseTimeInstant.json'
|
|
344
|
+
)
|
|
247
345
|
)
|
|
248
|
-
.query({ type: 'Light' })
|
|
249
346
|
.reply(204);
|
|
250
347
|
|
|
251
|
-
iotAgentConfig.timestamp =
|
|
348
|
+
iotAgentConfig.timestamp = false;
|
|
252
349
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
253
350
|
});
|
|
254
351
|
|
|
@@ -259,8 +356,8 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
259
356
|
done();
|
|
260
357
|
});
|
|
261
358
|
|
|
262
|
-
it('should add the timestamp to the entity
|
|
263
|
-
iotAgentLib.update('
|
|
359
|
+
it('should add the timestamp attribute to the entity but not as attribute metadata', function (done) {
|
|
360
|
+
iotAgentLib.update('lightNoTimestamp1', 'LightNoTimestamp', '', modifiedValues, function (error) {
|
|
264
361
|
should.not.exist(error);
|
|
265
362
|
contextBrokerMock.done();
|
|
266
363
|
done();
|
|
@@ -332,13 +429,12 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
332
429
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
333
430
|
.matchHeader('fiware-service', 'smartgondor')
|
|
334
431
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
335
|
-
.
|
|
336
|
-
'/v2/entities
|
|
432
|
+
.post(
|
|
433
|
+
'/v2/entities?options=upsert',
|
|
337
434
|
utils.readExampleFile(
|
|
338
435
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json'
|
|
339
436
|
)
|
|
340
437
|
)
|
|
341
|
-
.query({ type: 'Light' })
|
|
342
438
|
.reply(204);
|
|
343
439
|
|
|
344
440
|
iotAgentConfig.timestamp = true;
|
|
@@ -361,7 +457,7 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
361
457
|
});
|
|
362
458
|
});
|
|
363
459
|
|
|
364
|
-
describe('When the IoT Agent receives new information, the timestamp flag is
|
|
460
|
+
describe('When the IoT Agent receives new information, the timestamp flag is on and timezone is defined', function () {
|
|
365
461
|
let modifiedValues;
|
|
366
462
|
|
|
367
463
|
beforeEach(function (done) {
|
|
@@ -387,13 +483,12 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
387
483
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
388
484
|
.matchHeader('fiware-service', 'smartgondor')
|
|
389
485
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
390
|
-
.
|
|
391
|
-
'/v2/entities
|
|
486
|
+
.post(
|
|
487
|
+
'/v2/entities?options=upsert',
|
|
392
488
|
utils.readExampleFile(
|
|
393
489
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextTimestampTimezone.json'
|
|
394
490
|
)
|
|
395
491
|
)
|
|
396
|
-
.query({ type: 'Light' })
|
|
397
492
|
.reply(204);
|
|
398
493
|
|
|
399
494
|
iotAgentConfig.timestamp = true;
|
|
@@ -444,13 +539,12 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
444
539
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
445
540
|
.matchHeader('fiware-service', 'smartgondor')
|
|
446
541
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
447
|
-
.
|
|
448
|
-
'/v2/entities
|
|
542
|
+
.post(
|
|
543
|
+
'/v2/entities?options=upsert',
|
|
449
544
|
utils.readExampleFile(
|
|
450
545
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json'
|
|
451
546
|
)
|
|
452
547
|
)
|
|
453
|
-
.query({ type: 'Light' })
|
|
454
548
|
.reply(204);
|
|
455
549
|
|
|
456
550
|
iotAgentConfig.timestamp = true;
|
|
@@ -499,13 +593,12 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
499
593
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
500
594
|
.matchHeader('fiware-service', 'smartgondor')
|
|
501
595
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
502
|
-
.
|
|
503
|
-
'/v2/entities
|
|
596
|
+
.post(
|
|
597
|
+
'/v2/entities?options=upsert',
|
|
504
598
|
utils.readExampleFile(
|
|
505
599
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json'
|
|
506
600
|
)
|
|
507
601
|
)
|
|
508
|
-
.query({ type: 'Light' })
|
|
509
602
|
.reply(204);
|
|
510
603
|
|
|
511
604
|
iotAgentConfig.timestamp = true;
|
|
@@ -554,11 +647,10 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
554
647
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
555
648
|
.matchHeader('fiware-service', 'smartgondor')
|
|
556
649
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
557
|
-
.
|
|
558
|
-
'/v2/entities
|
|
650
|
+
.post(
|
|
651
|
+
'/v2/entities?options=upsert',
|
|
559
652
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json')
|
|
560
653
|
)
|
|
561
|
-
.query({ type: 'Light' })
|
|
562
654
|
.reply(
|
|
563
655
|
413,
|
|
564
656
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextResponses/updateContext1Failed.json')
|
|
@@ -587,11 +679,10 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
587
679
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
588
680
|
.matchHeader('fiware-service', 'smartgondor')
|
|
589
681
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
590
|
-
.
|
|
591
|
-
'/v2/entities
|
|
682
|
+
.post(
|
|
683
|
+
'/v2/entities?options=upsert',
|
|
592
684
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json')
|
|
593
685
|
)
|
|
594
|
-
.query({ type: 'Light' })
|
|
595
686
|
.reply(
|
|
596
687
|
400,
|
|
597
688
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextResponses/updateContext2Failed.json')
|
|
@@ -617,11 +708,10 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
617
708
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
618
709
|
.matchHeader('fiware-service', 'smartgondor')
|
|
619
710
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
620
|
-
.
|
|
621
|
-
'/v2/entities
|
|
711
|
+
.post(
|
|
712
|
+
'/v2/entities?options=upsert',
|
|
622
713
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json')
|
|
623
714
|
)
|
|
624
|
-
.query({ type: 'Light' })
|
|
625
715
|
.reply(
|
|
626
716
|
500,
|
|
627
717
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextResponses/updateContext2Failed.json')
|
|
@@ -650,11 +740,10 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
650
740
|
contextBrokerMock = nock('http://192.168.1.1:3024')
|
|
651
741
|
.matchHeader('fiware-service', 'smartgondor')
|
|
652
742
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
653
|
-
.
|
|
654
|
-
'/v2/entities
|
|
655
|
-
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/
|
|
743
|
+
.post(
|
|
744
|
+
'/v2/entities?options=upsert',
|
|
745
|
+
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext5.json')
|
|
656
746
|
)
|
|
657
|
-
.query({ type: 'Humidity' })
|
|
658
747
|
.reply(204);
|
|
659
748
|
|
|
660
749
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -684,13 +773,12 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
684
773
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
685
774
|
.matchHeader('fiware-service', 'smartgondor')
|
|
686
775
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
687
|
-
.
|
|
688
|
-
'/v2/entities
|
|
776
|
+
.post(
|
|
777
|
+
'/v2/entities?options=upsert',
|
|
689
778
|
utils.readExampleFile(
|
|
690
779
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributes.json'
|
|
691
780
|
)
|
|
692
781
|
)
|
|
693
|
-
.query({ type: 'Motion' })
|
|
694
782
|
.reply(204);
|
|
695
783
|
|
|
696
784
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -720,13 +808,12 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
720
808
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
721
809
|
.matchHeader('fiware-service', 'smartgondor')
|
|
722
810
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
723
|
-
.
|
|
724
|
-
'/v2/entities
|
|
811
|
+
.post(
|
|
812
|
+
'/v2/entities?options=upsert',
|
|
725
813
|
utils.readExampleFile(
|
|
726
814
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json'
|
|
727
815
|
)
|
|
728
816
|
)
|
|
729
|
-
.query({ type: 'Lamp' })
|
|
730
817
|
.reply(204);
|
|
731
818
|
|
|
732
819
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -740,7 +827,7 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
740
827
|
});
|
|
741
828
|
});
|
|
742
829
|
|
|
743
|
-
describe('When the IoT Agent receives new information from a device
|
|
830
|
+
describe('When the IoT Agent receives new information from a device', function () {
|
|
744
831
|
beforeEach(function (done) {
|
|
745
832
|
nock.cleanAll();
|
|
746
833
|
|
|
@@ -748,19 +835,15 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
748
835
|
.matchHeader('fiware-service', 'smartgondor')
|
|
749
836
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
750
837
|
.post(
|
|
751
|
-
'/v2/entities
|
|
838
|
+
'/v2/entities?options=upsert',
|
|
752
839
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext.json')
|
|
753
840
|
)
|
|
754
|
-
.query({ type: 'Light' })
|
|
755
841
|
.reply(204);
|
|
756
842
|
|
|
757
|
-
iotAgentConfig.appendMode = true;
|
|
758
843
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
759
844
|
});
|
|
760
845
|
|
|
761
846
|
afterEach(function (done) {
|
|
762
|
-
iotAgentConfig.appendMode = false;
|
|
763
|
-
|
|
764
847
|
done();
|
|
765
848
|
});
|
|
766
849
|
|
|
@@ -782,16 +865,14 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
782
865
|
contextBrokerMock = nock('http://cbhost:1026')
|
|
783
866
|
.matchHeader('fiware-service', 'smartgondor')
|
|
784
867
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
785
|
-
.
|
|
786
|
-
'/v2/entities
|
|
787
|
-
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/
|
|
868
|
+
.post(
|
|
869
|
+
'/v2/entities?options=upsert',
|
|
870
|
+
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext6.json')
|
|
788
871
|
)
|
|
789
|
-
.query({ type: 'Light' })
|
|
790
872
|
.reply(204);
|
|
791
873
|
|
|
792
874
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
793
875
|
});
|
|
794
|
-
|
|
795
876
|
it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
796
877
|
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
797
878
|
should.not.exist(error);
|
|
@@ -107,11 +107,10 @@ describe('NGSI-v2 - JSON native types autocast test', function () {
|
|
|
107
107
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
108
108
|
.matchHeader('fiware-service', 'smartgondor')
|
|
109
109
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
110
|
-
.
|
|
111
|
-
'/v2/entities
|
|
110
|
+
.post(
|
|
111
|
+
'/v2/entities?options=upsert',
|
|
112
112
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast1.json')
|
|
113
113
|
)
|
|
114
|
-
.query({ type: 'Light' })
|
|
115
114
|
.reply(204);
|
|
116
115
|
|
|
117
116
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -141,11 +140,10 @@ describe('NGSI-v2 - JSON native types autocast test', function () {
|
|
|
141
140
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
142
141
|
.matchHeader('fiware-service', 'smartgondor')
|
|
143
142
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
144
|
-
.
|
|
145
|
-
'/v2/entities
|
|
143
|
+
.post(
|
|
144
|
+
'/v2/entities?options=upsert',
|
|
146
145
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast2.json')
|
|
147
146
|
)
|
|
148
|
-
.query({ type: 'Light' })
|
|
149
147
|
.reply(204);
|
|
150
148
|
|
|
151
149
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -175,11 +173,10 @@ describe('NGSI-v2 - JSON native types autocast test', function () {
|
|
|
175
173
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
176
174
|
.matchHeader('fiware-service', 'smartgondor')
|
|
177
175
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
178
|
-
.
|
|
179
|
-
'/v2/entities
|
|
176
|
+
.post(
|
|
177
|
+
'/v2/entities?options=upsert',
|
|
180
178
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast3.json')
|
|
181
179
|
)
|
|
182
|
-
.query({ type: 'Light' })
|
|
183
180
|
.reply(204);
|
|
184
181
|
|
|
185
182
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -209,11 +206,10 @@ describe('NGSI-v2 - JSON native types autocast test', function () {
|
|
|
209
206
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
210
207
|
.matchHeader('fiware-service', 'smartgondor')
|
|
211
208
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
212
|
-
.
|
|
213
|
-
'/v2/entities
|
|
209
|
+
.post(
|
|
210
|
+
'/v2/entities?options=upsert',
|
|
214
211
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast4.json')
|
|
215
212
|
)
|
|
216
|
-
.query({ type: 'Light' })
|
|
217
213
|
.reply(204);
|
|
218
214
|
|
|
219
215
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -243,11 +239,10 @@ describe('NGSI-v2 - JSON native types autocast test', function () {
|
|
|
243
239
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
244
240
|
.matchHeader('fiware-service', 'smartgondor')
|
|
245
241
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
246
|
-
.
|
|
247
|
-
'/v2/entities
|
|
242
|
+
.post(
|
|
243
|
+
'/v2/entities?options=upsert',
|
|
248
244
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast5.json')
|
|
249
245
|
)
|
|
250
|
-
.query({ type: 'Light' })
|
|
251
246
|
.reply(204);
|
|
252
247
|
|
|
253
248
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -277,11 +272,10 @@ describe('NGSI-v2 - JSON native types autocast test', function () {
|
|
|
277
272
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
278
273
|
.matchHeader('fiware-service', 'smartgondor')
|
|
279
274
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
280
|
-
.
|
|
281
|
-
'/v2/entities
|
|
275
|
+
.post(
|
|
276
|
+
'/v2/entities?options=upsert',
|
|
282
277
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast6.json')
|
|
283
278
|
)
|
|
284
|
-
.query({ type: 'Light' })
|
|
285
279
|
.reply(204);
|
|
286
280
|
|
|
287
281
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -311,11 +305,10 @@ describe('NGSI-v2 - JSON native types autocast test', function () {
|
|
|
311
305
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
312
306
|
.matchHeader('fiware-service', 'smartgondor')
|
|
313
307
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
314
|
-
.
|
|
315
|
-
'/v2/entities
|
|
308
|
+
.post(
|
|
309
|
+
'/v2/entities?options=upsert',
|
|
316
310
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAutocast7.json')
|
|
317
311
|
)
|
|
318
|
-
.query({ type: 'Light' })
|
|
319
312
|
.reply(204);
|
|
320
313
|
|
|
321
314
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -112,20 +112,18 @@ describe('NGSI-v2 - Static attributes test', function () {
|
|
|
112
112
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
113
113
|
.matchHeader('fiware-service', 'smartgondor')
|
|
114
114
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
115
|
-
.
|
|
116
|
-
.query({ type: 'Light' })
|
|
115
|
+
.post('/v2/entities?options=upsert')
|
|
117
116
|
.times(4)
|
|
118
117
|
.reply(204)
|
|
119
|
-
.
|
|
118
|
+
.post('/v2/entities?options=upsert', function (body) {
|
|
120
119
|
let metadatas = 0;
|
|
121
120
|
for (const i in body) {
|
|
122
121
|
if (body[i].metadata) {
|
|
123
122
|
metadatas += Object.keys(body[i].metadata).length;
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
|
-
return metadatas === Object.keys(body).length - 1;
|
|
125
|
+
return metadatas === Object.keys(body).length - 1 - 2;
|
|
127
126
|
})
|
|
128
|
-
.query({ type: 'Light' })
|
|
129
127
|
.reply(204);
|
|
130
128
|
|
|
131
129
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -64,16 +64,7 @@ describe('NGSI-v2 - Subscription tests', function () {
|
|
|
64
64
|
nock.cleanAll();
|
|
65
65
|
|
|
66
66
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
67
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
68
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
69
|
-
.matchHeader('fiware-servicepath', '/gardens')
|
|
70
|
-
.post(
|
|
71
|
-
'/v2/entities?options=upsert',
|
|
72
|
-
utils.readExampleFile(
|
|
73
|
-
'./test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json'
|
|
74
|
-
)
|
|
75
|
-
)
|
|
76
|
-
.reply(204);
|
|
67
|
+
contextBrokerMock = nock('http://192.168.1.1:1026');
|
|
77
68
|
|
|
78
69
|
contextBrokerMock
|
|
79
70
|
.matchHeader('fiware-service', 'smartgondor')
|
|
@@ -104,7 +95,7 @@ describe('NGSI-v2 - Subscription tests', function () {
|
|
|
104
95
|
|
|
105
96
|
describe('When a client invokes the subscribe() function for device', function () {
|
|
106
97
|
it('should send the appropriate request to the Context Broker', function (done) {
|
|
107
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
98
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
108
99
|
iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
|
|
109
100
|
should.not.exist(error);
|
|
110
101
|
|
|
@@ -115,9 +106,9 @@ describe('NGSI-v2 - Subscription tests', function () {
|
|
|
115
106
|
});
|
|
116
107
|
});
|
|
117
108
|
it('should store the subscription ID in the Device Registry', function (done) {
|
|
118
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
109
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
119
110
|
iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
|
|
120
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
111
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
121
112
|
should.not.exist(error);
|
|
122
113
|
should.exist(device);
|
|
123
114
|
should.exist(device.subscriptions);
|
|
@@ -141,10 +132,10 @@ describe('NGSI-v2 - Subscription tests', function () {
|
|
|
141
132
|
done();
|
|
142
133
|
});
|
|
143
134
|
it('should delete the subscription from the CB', function (done) {
|
|
144
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
135
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
145
136
|
iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
|
|
146
137
|
iotAgentLib.unsubscribe(device, '51c0ac9ed714fb3b37d7d5a8', function (error) {
|
|
147
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
138
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
148
139
|
contextBrokerMock.done();
|
|
149
140
|
done();
|
|
150
141
|
});
|
|
@@ -153,10 +144,10 @@ describe('NGSI-v2 - Subscription tests', function () {
|
|
|
153
144
|
});
|
|
154
145
|
});
|
|
155
146
|
it('should remove the id from the subscriptions array', function (done) {
|
|
156
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
147
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
157
148
|
iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
|
|
158
149
|
iotAgentLib.unsubscribe(device, '51c0ac9ed714fb3b37d7d5a8', function (error) {
|
|
159
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
150
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
160
151
|
should.not.exist(error);
|
|
161
152
|
should.exist(device);
|
|
162
153
|
should.exist(device.subscriptions);
|
|
@@ -180,9 +171,9 @@ describe('NGSI-v2 - Subscription tests', function () {
|
|
|
180
171
|
});
|
|
181
172
|
|
|
182
173
|
it('should delete the subscription from the CB', function (done) {
|
|
183
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
174
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
184
175
|
iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
|
|
185
|
-
iotAgentLib.unregister(device.id, 'smartgondor', '/gardens', function (error) {
|
|
176
|
+
iotAgentLib.unregister(device.id, null, 'smartgondor', '/gardens', function (error) {
|
|
186
177
|
contextBrokerMock.done();
|
|
187
178
|
done();
|
|
188
179
|
});
|
|
@@ -192,7 +183,7 @@ describe('NGSI-v2 - Subscription tests', function () {
|
|
|
192
183
|
});
|
|
193
184
|
describe('When a new notification comes to the IoTAgent', function () {
|
|
194
185
|
beforeEach(function (done) {
|
|
195
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
186
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
196
187
|
iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
|
|
197
188
|
done();
|
|
198
189
|
});
|