iotagent-node-lib 2.26.0 → 3.1.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/workflows/ci.yml +1 -0
- package/CHANGES_NEXT_RELEASE +2 -0
- package/docker-compose-dev.yml +1 -1
- package/lib/fiware-iotagent-lib.js +0 -5
- package/lib/plugins/compressTimestamp.js +2 -7
- package/lib/plugins/expressionParser.js +0 -47
- package/lib/plugins/expressionPlugin.js +6 -78
- package/lib/plugins/jexlParser.js +0 -36
- package/lib/plugins/pluginUtils.js +0 -119
- package/lib/services/ngsi/entities-NGSI-LD.js +586 -199
- package/lib/services/ngsi/entities-NGSI-v2.js +607 -297
- package/lib/services/ngsi/ngsiUtils.js +15 -22
- package/package.json +2 -2
- package/test/unit/general/config-multi-core-test.js +2 -1
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +2 -1
- package/test/unit/general/deviceService-test.js +2 -1
- package/test/unit/general/loglevel-api_test.js +2 -3
- package/test/unit/general/startup-test.js +2 -1
- package/test/unit/general/statistics-persistence_test.js +1 -0
- package/test/unit/general/statistics-service_test.js +1 -0
- package/test/unit/lazyAndCommands/commandRegistry_test.js +1 -0
- package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +1 -0
- package/test/unit/mongodb/mongodb-connectionoptions-test.js +1 -0
- package/test/unit/mongodb/mongodb-group-registry-test.js +1 -0
- package/test/unit/mongodb/mongodb-registry-test.js +2 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin1.json +0 -5
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast10.json +1 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast8.json +1 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast9.json +1 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +16 -15
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4.json +8 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4a.json +34 -34
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin5.json +8 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin6.json +0 -20
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin7.json +0 -5
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin8.json +10 -10
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +8 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +5 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextProcessTimestamp.json +4 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextTimestampOverride.json +4 -3
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +4 -3
- package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +4 -6
- package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +1 -7
- package/test/unit/ngsi-ld/general/config-jsonld-contexts-test.js +2 -1
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +2 -1
- package/test/unit/ngsi-ld/general/deviceService-test.js +2 -1
- package/test/unit/ngsi-ld/general/https-support-test.js +2 -1
- package/test/unit/ngsi-ld/general/iotam-autoregistration-test.js +2 -1
- package/test/unit/ngsi-ld/general/startup-test.js +3 -2
- package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +2 -1
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +5 -7
- package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +8 -6
- package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +18 -22
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +17 -4
- package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +32 -34
- package/test/unit/ngsi-ld/ngsiService/staticAttributes-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/unsupported-endpoints-test.js +11 -15
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +2 -3
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +2 -1
- package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +2 -32
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +20 -19
- package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +21 -7
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +2 -1
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +15 -12
- package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +1 -0
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +13 -7
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json +2 -2
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +4 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +0 -16
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +8 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +42 -42
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +7 -7
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +0 -5
- package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +6 -6
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +7 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +7 -1
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +2 -4
- package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +4 -8
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +5 -9
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +2 -1
- package/test/unit/ngsiv2/general/deviceService-test.js +2 -1
- package/test/unit/ngsiv2/general/https-support-test.js +2 -1
- package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +2 -1
- package/test/unit/ngsiv2/general/startup-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +8 -6
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +2 -1
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +3 -2
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +2 -1
- package/test/unit/ngsiv2/ngsiService/queryDeviceInformationInCb-test.js +2 -1
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +2 -1
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +2 -1
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +2 -3
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +2 -5
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +2 -33
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +7 -16
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +3 -2
- package/test/unit/ngsiv2/provisioning/device-group-api-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +1 -0
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +2 -1
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +15 -12
- package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +1 -0
- package/test/unit/plugins/capture-configuration-inPlugins_test.js +2 -1
- package/test/unit/plugins/capture-provision-inPlugins_test.js +2 -1
- package/lib/plugins/addEvent.js +0 -32
- package/lib/plugins/attributeAlias.js +0 -107
- package/lib/plugins/multiEntity.js +0 -255
- package/lib/plugins/timestampProcessPlugin.js +0 -95
- package/test/unit/ngsi-ld/plugins/event-plugin_test.js +0 -116
- package/test/unit/ngsiv2/plugins/event-plugin_test.js +0 -118
- package/test/unit/ngsiv2/plugins/translation-inPlugins_test.js +0 -262
|
@@ -39,7 +39,8 @@ const iotAgentConfig = {
|
|
|
39
39
|
ngsiVersion: 'v2'
|
|
40
40
|
},
|
|
41
41
|
server: {
|
|
42
|
-
port: 4041
|
|
42
|
+
port: 4041,
|
|
43
|
+
host: 'localhost'
|
|
43
44
|
},
|
|
44
45
|
types: {
|
|
45
46
|
Light: {
|
|
@@ -197,9 +198,6 @@ describe('NGSI-v2 - Expression-based transformations plugin', function () {
|
|
|
197
198
|
|
|
198
199
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
199
200
|
iotAgentLib.clearAll(function () {
|
|
200
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
201
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
202
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
203
201
|
done();
|
|
204
202
|
});
|
|
205
203
|
});
|
|
@@ -38,7 +38,8 @@ const iotAgentConfigJexl = {
|
|
|
38
38
|
ngsiVersion: 'v2'
|
|
39
39
|
},
|
|
40
40
|
server: {
|
|
41
|
-
port: 4041
|
|
41
|
+
port: 4041,
|
|
42
|
+
host: 'localhost'
|
|
42
43
|
},
|
|
43
44
|
defaultExpressionLanguage: 'jexl',
|
|
44
45
|
types: {
|
|
@@ -83,7 +84,8 @@ const iotAgentConfigLegacy = {
|
|
|
83
84
|
ngsiVersion: 'v2'
|
|
84
85
|
},
|
|
85
86
|
server: {
|
|
86
|
-
port: 4041
|
|
87
|
+
port: 4041,
|
|
88
|
+
host: 'localhost'
|
|
87
89
|
},
|
|
88
90
|
types: {
|
|
89
91
|
WeatherStationLegacy: {
|
|
@@ -127,9 +129,6 @@ describe('Combine Jexl and legacy expressions (default JEXL) - NGSI v2', functio
|
|
|
127
129
|
|
|
128
130
|
iotAgentLib.activate(iotAgentConfigJexl, function () {
|
|
129
131
|
iotAgentLib.clearAll(function () {
|
|
130
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
131
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
132
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
133
132
|
done();
|
|
134
133
|
});
|
|
135
134
|
});
|
|
@@ -216,9 +215,6 @@ describe('Combine Jexl and legacy expressions (default Legacy) - NGSI v2', funct
|
|
|
216
215
|
|
|
217
216
|
iotAgentLib.activate(iotAgentConfigLegacy, function () {
|
|
218
217
|
iotAgentLib.clearAll(function () {
|
|
219
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
220
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
221
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
222
218
|
done();
|
|
223
219
|
});
|
|
224
220
|
});
|
|
@@ -41,7 +41,8 @@ const iotAgentConfig = {
|
|
|
41
41
|
},
|
|
42
42
|
defaultExpressionLanguage: 'jexl',
|
|
43
43
|
server: {
|
|
44
|
-
port: 4041
|
|
44
|
+
port: 4041,
|
|
45
|
+
host: 'localhost'
|
|
45
46
|
},
|
|
46
47
|
types: {
|
|
47
48
|
Light: {
|
|
@@ -346,7 +347,7 @@ const iotAgentConfig = {
|
|
|
346
347
|
expression: "{coordinates: [lon,lat], type: 'Point'}"
|
|
347
348
|
}
|
|
348
349
|
],
|
|
349
|
-
explicitAttrs: true
|
|
350
|
+
explicitAttrs: 'TimeInstant == null ? [] : true' // which is true
|
|
350
351
|
},
|
|
351
352
|
GPS7: {
|
|
352
353
|
commands: [],
|
|
@@ -389,7 +390,8 @@ const iotAgentConfigTS = {
|
|
|
389
390
|
},
|
|
390
391
|
defaultExpressionLanguage: 'jexl',
|
|
391
392
|
server: {
|
|
392
|
-
port: 4041
|
|
393
|
+
port: 4041,
|
|
394
|
+
host: 'localhost'
|
|
393
395
|
},
|
|
394
396
|
types: {
|
|
395
397
|
GPS: {
|
|
@@ -418,9 +420,6 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
418
420
|
|
|
419
421
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
420
422
|
iotAgentLib.clearAll(function () {
|
|
421
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
422
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
423
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
424
423
|
done();
|
|
425
424
|
});
|
|
426
425
|
});
|
|
@@ -1316,9 +1315,6 @@ describe('Java expression language (JEXL) based transformations plugin - Timesta
|
|
|
1316
1315
|
|
|
1317
1316
|
iotAgentLib.activate(iotAgentConfigTS, function () {
|
|
1318
1317
|
iotAgentLib.clearAll(function () {
|
|
1319
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
1320
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
1321
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
1322
1318
|
done();
|
|
1323
1319
|
});
|
|
1324
1320
|
});
|
|
@@ -45,7 +45,8 @@ const iotAgentConfig = {
|
|
|
45
45
|
ngsiVersion: 'v2'
|
|
46
46
|
},
|
|
47
47
|
server: {
|
|
48
|
-
port: 4041
|
|
48
|
+
port: 4041,
|
|
49
|
+
host: 'localhost'
|
|
49
50
|
},
|
|
50
51
|
types: {
|
|
51
52
|
Light: {
|
|
@@ -343,11 +344,12 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
343
344
|
.post('/v2/entities?options=upsert')
|
|
344
345
|
.reply(204);
|
|
345
346
|
|
|
346
|
-
async.series(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
347
|
+
async.series(
|
|
348
|
+
[apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)],
|
|
349
|
+
function (error) {
|
|
350
|
+
done();
|
|
351
|
+
}
|
|
352
|
+
);
|
|
351
353
|
});
|
|
352
354
|
|
|
353
355
|
it('should not give any error', function (done) {
|
|
@@ -40,7 +40,8 @@ const iotAgentConfig = {
|
|
|
40
40
|
ngsiVersion: 'v2'
|
|
41
41
|
},
|
|
42
42
|
server: {
|
|
43
|
-
port: 4041
|
|
43
|
+
port: 4041,
|
|
44
|
+
host: 'localhost'
|
|
44
45
|
},
|
|
45
46
|
types: {
|
|
46
47
|
Light: {
|
|
@@ -463,7 +464,7 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
463
464
|
done();
|
|
464
465
|
});
|
|
465
466
|
|
|
466
|
-
it('should not override the received instant and should
|
|
467
|
+
it('should not override the received instant and should add metadatas for this request', function (done) {
|
|
467
468
|
iotAgentLib.update('light1', 'Light', '', modifiedValues, function (error) {
|
|
468
469
|
should.not.exist(error);
|
|
469
470
|
contextBrokerMock.done();
|
|
@@ -39,7 +39,8 @@ const iotAgentConfig = {
|
|
|
39
39
|
ngsiVersion: 'v2'
|
|
40
40
|
},
|
|
41
41
|
server: {
|
|
42
|
-
port: 4041
|
|
42
|
+
port: 4041,
|
|
43
|
+
host: 'localhost'
|
|
43
44
|
},
|
|
44
45
|
types: {
|
|
45
46
|
Light: {
|
|
@@ -115,8 +116,6 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
115
116
|
|
|
116
117
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
117
118
|
iotAgentLib.clearAll(function () {
|
|
118
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
119
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
120
119
|
done();
|
|
121
120
|
});
|
|
122
121
|
});
|
|
@@ -40,7 +40,8 @@ const iotAgentConfig = {
|
|
|
40
40
|
ngsiVersion: 'v2'
|
|
41
41
|
},
|
|
42
42
|
server: {
|
|
43
|
-
port: 4041
|
|
43
|
+
port: 4041,
|
|
44
|
+
host: 'localhost'
|
|
44
45
|
},
|
|
45
46
|
types: {},
|
|
46
47
|
service: 'smartgondor',
|
|
@@ -241,7 +242,6 @@ describe('NGSI-v2 - Bidirectional data plugin', function () {
|
|
|
241
242
|
let transformedHandler = false;
|
|
242
243
|
|
|
243
244
|
function mockedHandler(device, values, callback) {
|
|
244
|
-
|
|
245
245
|
let latitudeFound = false;
|
|
246
246
|
let longitudeFound = false;
|
|
247
247
|
|
|
@@ -271,7 +271,6 @@ describe('NGSI-v2 - Bidirectional data plugin', function () {
|
|
|
271
271
|
});
|
|
272
272
|
});
|
|
273
273
|
|
|
274
|
-
|
|
275
274
|
describe('When a notification with metadata arrives for a bidirectional attribute', function () {
|
|
276
275
|
const notificationOptions = {
|
|
277
276
|
url: 'http://localhost:' + iotAgentConfig.server.port + '/notify',
|
|
@@ -314,7 +313,6 @@ describe('NGSI-v2 - Bidirectional data plugin', function () {
|
|
|
314
313
|
|
|
315
314
|
it('should execute the original handler', function (done) {
|
|
316
315
|
function mockedHandler(device, notification, callback) {
|
|
317
|
-
|
|
318
316
|
notification[0].name.should.equal('location');
|
|
319
317
|
notification[0].value.should.equal('12.4, -9.6');
|
|
320
318
|
notification[0].metadata.qos.value.should.equal(1);
|
|
@@ -384,7 +382,6 @@ describe('NGSI-v2 - Bidirectional data plugin', function () {
|
|
|
384
382
|
});
|
|
385
383
|
});
|
|
386
384
|
|
|
387
|
-
|
|
388
385
|
describe('When a new Group provisioning request arrives with bidirectional attributes', function () {
|
|
389
386
|
const provisionGroup = {
|
|
390
387
|
url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/services',
|
|
@@ -36,7 +36,8 @@ const iotAgentConfig = {
|
|
|
36
36
|
ngsiVersion: 'v2'
|
|
37
37
|
},
|
|
38
38
|
server: {
|
|
39
|
-
port: 4041
|
|
39
|
+
port: 4041,
|
|
40
|
+
host: 'localhost'
|
|
40
41
|
},
|
|
41
42
|
types: {
|
|
42
43
|
Light: {
|
|
@@ -122,8 +123,6 @@ describe('NGSI-v2 - Timestamp compression plugin', function () {
|
|
|
122
123
|
logger.setLevel('FATAL');
|
|
123
124
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
124
125
|
iotAgentLib.clearAll(function () {
|
|
125
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.compressTimestamp.updateNgsi2);
|
|
126
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.compressTimestamp.queryNgsi2);
|
|
127
126
|
done();
|
|
128
127
|
});
|
|
129
128
|
});
|
|
@@ -217,34 +216,4 @@ describe('NGSI-v2 - Timestamp compression plugin', function () {
|
|
|
217
216
|
});
|
|
218
217
|
});
|
|
219
218
|
});
|
|
220
|
-
|
|
221
|
-
describe('When a query comes for a timestamp through the plugin', function () {
|
|
222
|
-
const values = ['state', 'TheTargetValue'];
|
|
223
|
-
|
|
224
|
-
beforeEach(function () {
|
|
225
|
-
nock.cleanAll();
|
|
226
|
-
|
|
227
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
228
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
229
|
-
.matchHeader('fiware-servicepath', 'gardens')
|
|
230
|
-
.get('/v2/entities/light1/attrs?attrs=state,TheTargetValue&type=Light')
|
|
231
|
-
.reply(
|
|
232
|
-
200,
|
|
233
|
-
utils.readExampleFile(
|
|
234
|
-
'./test/unit/ngsiv2/examples/contextResponses/queryContextCompressTimestamp1Success.json'
|
|
235
|
-
)
|
|
236
|
-
);
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
it('should return an entity with all its timestamps without separators (basic format)', function (done) {
|
|
240
|
-
iotAgentLib.query('light1', 'Light', '', values, function (error, response) {
|
|
241
|
-
should.not.exist(error);
|
|
242
|
-
should.exist(response);
|
|
243
|
-
should.exist(response.TheTargetValue);
|
|
244
|
-
should.exist(response.TheTargetValue.value);
|
|
245
|
-
response.TheTargetValue.value.should.equal('20071103T131805');
|
|
246
|
-
done();
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
219
|
});
|
|
@@ -41,7 +41,8 @@ const iotAgentConfig = {
|
|
|
41
41
|
ngsiVersion: 'v2'
|
|
42
42
|
},
|
|
43
43
|
server: {
|
|
44
|
-
port: 4041
|
|
44
|
+
port: 4041,
|
|
45
|
+
host: 'localhost'
|
|
45
46
|
},
|
|
46
47
|
types: {
|
|
47
48
|
WeatherStation: {
|
|
@@ -573,10 +574,6 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
|
|
|
573
574
|
|
|
574
575
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
575
576
|
iotAgentLib.clearAll(function () {
|
|
576
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
577
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
578
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
579
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.multiEntity.update);
|
|
580
577
|
done();
|
|
581
578
|
});
|
|
582
579
|
});
|
|
@@ -1117,6 +1114,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
|
|
|
1117
1114
|
.post(
|
|
1118
1115
|
'/v2/op/update',
|
|
1119
1116
|
utils.readExampleFile(
|
|
1117
|
+
// Updated test same case that updateContextMultientityPlugin4.json
|
|
1120
1118
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json'
|
|
1121
1119
|
)
|
|
1122
1120
|
)
|
|
@@ -1423,10 +1421,6 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu
|
|
|
1423
1421
|
iotAgentConfig.timestamp = true;
|
|
1424
1422
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
1425
1423
|
iotAgentLib.clearAll(function () {
|
|
1426
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
1427
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
1428
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.multiEntity.update);
|
|
1429
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.timestampProcess.update);
|
|
1430
1424
|
done();
|
|
1431
1425
|
});
|
|
1432
1426
|
});
|
|
@@ -1507,7 +1501,7 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu
|
|
|
1507
1501
|
});
|
|
1508
1502
|
});
|
|
1509
1503
|
|
|
1510
|
-
it('should send two context elements, one for each entity', function (done) {
|
|
1504
|
+
it('should send two context elements, one for each entity bis', function (done) {
|
|
1511
1505
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1512
1506
|
.matchHeader('fiware-service', 'smartgondor')
|
|
1513
1507
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
@@ -1589,10 +1583,6 @@ describe('NGSI-v2 - Multi-entity plugin is executed for a command update for a r
|
|
|
1589
1583
|
timekeeper.freeze(time);
|
|
1590
1584
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
1591
1585
|
iotAgentLib.clearAll(function () {
|
|
1592
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
1593
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
1594
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.multiEntity.update);
|
|
1595
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.timestampProcess.update);
|
|
1596
1586
|
done();
|
|
1597
1587
|
});
|
|
1598
1588
|
});
|
|
@@ -1609,8 +1599,9 @@ describe('NGSI-v2 - Multi-entity plugin is executed for a command update for a r
|
|
|
1609
1599
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1610
1600
|
.matchHeader('fiware-service', 'smartgondor')
|
|
1611
1601
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
1612
|
-
.
|
|
1613
|
-
'/v2/op/update',
|
|
1602
|
+
.patch(
|
|
1603
|
+
//'/v2/op/update',
|
|
1604
|
+
'/v2/entities/sensorCommand/attrs?type=SensorCommand',
|
|
1614
1605
|
utils.readExampleFile(
|
|
1615
1606
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json'
|
|
1616
1607
|
)
|
|
@@ -36,7 +36,8 @@ const iotAgentConfig = {
|
|
|
36
36
|
ngsiVersion: 'v2'
|
|
37
37
|
},
|
|
38
38
|
server: {
|
|
39
|
-
port: 4041
|
|
39
|
+
port: 4041,
|
|
40
|
+
host: 'localhost'
|
|
40
41
|
},
|
|
41
42
|
types: {
|
|
42
43
|
Light: {
|
|
@@ -67,7 +68,6 @@ describe('NGSI-v2 - Timestamp processing plugin', function () {
|
|
|
67
68
|
|
|
68
69
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
69
70
|
iotAgentLib.clearAll(function () {
|
|
70
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.timestampProcess.update);
|
|
71
71
|
done();
|
|
72
72
|
});
|
|
73
73
|
});
|
|
@@ -100,6 +100,7 @@ describe('NGSI-v2 - Timestamp processing plugin', function () {
|
|
|
100
100
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
101
101
|
.patch(
|
|
102
102
|
'/v2/entities/light1/attrs',
|
|
103
|
+
// this tests breaks jexlBasedTransformation-test with uses updateContextExpressionPlugin32 which do not includes Timestamp in metadata attributes
|
|
103
104
|
utils.readExampleFile(
|
|
104
105
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json'
|
|
105
106
|
)
|
|
@@ -39,7 +39,8 @@ const iotAgentConfig = {
|
|
|
39
39
|
ngsiVersion: 'v2'
|
|
40
40
|
},
|
|
41
41
|
server: {
|
|
42
|
-
port: 4041
|
|
42
|
+
port: 4041,
|
|
43
|
+
host: 'localhost'
|
|
43
44
|
},
|
|
44
45
|
types: {
|
|
45
46
|
Light: {
|
|
@@ -268,17 +269,19 @@ describe('NGSI-v2 - IoT Agent Device Update Registration', function () {
|
|
|
268
269
|
});
|
|
269
270
|
it('should store the new values in the registry', function (done) {
|
|
270
271
|
iotAgentLib.updateRegister(deviceCommandUpdated, false, function (error, data) {
|
|
271
|
-
iotAgentLib.getDevice(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
272
|
+
iotAgentLib.getDevice(
|
|
273
|
+
deviceCommandUpdated.id,
|
|
274
|
+
'smartgondor',
|
|
275
|
+
'gardens',
|
|
276
|
+
function (error, deviceResult) {
|
|
277
|
+
should.not.exist(error);
|
|
278
|
+
should.exist(deviceResult);
|
|
279
|
+
deviceResult.internalId.should.equal(deviceUpdated.internalId);
|
|
280
|
+
deviceResult.commands[0].name.should.equal('move');
|
|
281
|
+
deviceResult.active[0].name.should.equal('temperature');
|
|
282
|
+
done();
|
|
283
|
+
}
|
|
284
|
+
);
|
|
282
285
|
});
|
|
283
286
|
});
|
|
284
287
|
});
|