iotagent-node-lib 3.0.0 → 3.2.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/config.js +5 -5
- package/doc/api.md +1540 -298
- package/doc/deprecated.md +3 -1
- package/doc/development.md +120 -0
- package/doc/installationguide.md +3 -6
- package/docker-compose-dev.yml +1 -1
- package/lib/commonConfig.js +7 -10
- package/lib/fiware-iotagent-lib.js +0 -10
- package/lib/jexlTranformsMap.js +2 -1
- package/lib/plugins/bidirectionalData.js +8 -26
- package/lib/plugins/expressionPlugin.js +8 -40
- package/lib/plugins/jexlParser.js +28 -0
- package/lib/services/commands/commandService.js +1 -1
- package/lib/services/devices/deviceService.js +2 -1
- package/lib/services/ngsi/entities-NGSI-LD.js +15 -73
- package/lib/services/ngsi/entities-NGSI-v2.js +149 -124
- package/lib/services/northBound/deviceProvisioningServer.js +17 -14
- package/lib/templates/createDevice.json +5 -2
- package/lib/templates/createDeviceLax.json +7 -5
- package/lib/templates/updateDevice.json +5 -2
- package/lib/templates/updateDeviceLax.json +3 -5
- package/package.json +2 -2
- package/test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json +5 -5
- package/test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice4.json +1 -0
- package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +4 -4
- 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 -1
- 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/expressions/jexlBasedTransformations-test.js +0 -2
- 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 +2 -1
- 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 -1
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +10 -9
- package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +2 -1
- package/test/unit/ngsi-ld/plugins/custom-plugin_test.js +152 -0
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +3 -2
- package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +2 -1
- 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/createMinimumProvisionedDevice4.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +0 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +20 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json +42 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +32 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +37 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +7 -1
- 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/jexlBasedTransformations-test.js +232 -8
- 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 +3 -3
- 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 -1
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +8 -7
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +2 -1
- package/test/unit/ngsiv2/plugins/custom-plugin_test.js +151 -0
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +87 -13
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -1
- 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 +12 -3
- 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/doc/advanced-topics.md +0 -626
- package/doc/expressionLanguage.md +0 -762
- package/lib/plugins/expressionParser.js +0 -205
- package/test/unit/expressions/expression-test.js +0 -197
- package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +0 -881
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +0 -950
- package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +0 -294
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"actionType": "update",
|
|
3
|
+
"entities": [
|
|
4
|
+
{
|
|
5
|
+
"id": "gps1",
|
|
6
|
+
"type": "GPS",
|
|
7
|
+
"explicit": {
|
|
8
|
+
"type": "number",
|
|
9
|
+
"value": 12
|
|
10
|
+
},
|
|
11
|
+
"expectedAtt": {
|
|
12
|
+
"type": "number",
|
|
13
|
+
"value": 13
|
|
14
|
+
},
|
|
15
|
+
"nonexpectedAtt": {
|
|
16
|
+
"type": "number",
|
|
17
|
+
"value": null
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"explicit": {
|
|
22
|
+
"type": "number",
|
|
23
|
+
"value": 52
|
|
24
|
+
},
|
|
25
|
+
"type": "GPS",
|
|
26
|
+
"id": "SO5"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"explicit": {
|
|
30
|
+
"type": "number",
|
|
31
|
+
"value": 13
|
|
32
|
+
},
|
|
33
|
+
"type": "GPS",
|
|
34
|
+
"id": "SO6"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
@@ -39,9 +39,9 @@ const iotAgentConfig = {
|
|
|
39
39
|
port: '1026',
|
|
40
40
|
ngsiVersion: 'v2'
|
|
41
41
|
},
|
|
42
|
-
defaultExpressionLanguage: 'jexl',
|
|
43
42
|
server: {
|
|
44
|
-
port: 4041
|
|
43
|
+
port: 4041,
|
|
44
|
+
host: 'localhost'
|
|
45
45
|
},
|
|
46
46
|
types: {
|
|
47
47
|
Light: {
|
|
@@ -125,7 +125,7 @@ const iotAgentConfig = {
|
|
|
125
125
|
{
|
|
126
126
|
name: 'weather',
|
|
127
127
|
type: 'Summary',
|
|
128
|
-
expression: '"Humidity " + (humidity / 2) + " and pressure " + (
|
|
128
|
+
expression: '"Humidity " + (humidity / 2) + " and pressure " + (p * 20)'
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
131
|
object_id: 'a',
|
|
@@ -249,6 +249,24 @@ const iotAgentConfig = {
|
|
|
249
249
|
],
|
|
250
250
|
explicitAttrs: true
|
|
251
251
|
},
|
|
252
|
+
GPS2b: {
|
|
253
|
+
commands: [],
|
|
254
|
+
type: 'GPS',
|
|
255
|
+
lazy: [],
|
|
256
|
+
active: [
|
|
257
|
+
{
|
|
258
|
+
name: 'location',
|
|
259
|
+
type: 'geo:json',
|
|
260
|
+
expression: "{coordinates: [lon,lat], type: 'Point'}"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: 'temperature',
|
|
264
|
+
type: 'Number',
|
|
265
|
+
expression: 't * 10'
|
|
266
|
+
}
|
|
267
|
+
],
|
|
268
|
+
explicitAttrs: true
|
|
269
|
+
},
|
|
252
270
|
GPS3: {
|
|
253
271
|
commands: [],
|
|
254
272
|
type: 'GPS',
|
|
@@ -320,8 +338,31 @@ const iotAgentConfig = {
|
|
|
320
338
|
}
|
|
321
339
|
],
|
|
322
340
|
explicitAttrs: "theLocation ? ['mylocation'] : []"
|
|
323
|
-
|
|
324
|
-
|
|
341
|
+
},
|
|
342
|
+
GPS5b: {
|
|
343
|
+
commands: [],
|
|
344
|
+
type: 'GPS',
|
|
345
|
+
lazy: [],
|
|
346
|
+
static: [
|
|
347
|
+
{
|
|
348
|
+
name: 'lat',
|
|
349
|
+
type: 'string',
|
|
350
|
+
value: '52'
|
|
351
|
+
}
|
|
352
|
+
],
|
|
353
|
+
active: [
|
|
354
|
+
{
|
|
355
|
+
name: 'price',
|
|
356
|
+
type: 'number'
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
object_id: 'theLocation',
|
|
360
|
+
name: 'mylocation',
|
|
361
|
+
type: 'geo:json',
|
|
362
|
+
expression: "{coordinates: [lon,lat], type: 'Point'}"
|
|
363
|
+
}
|
|
364
|
+
],
|
|
365
|
+
explicitAttrs: "theLocation ? [{object_id: 'theLocation'}] : []"
|
|
325
366
|
},
|
|
326
367
|
GPS6: {
|
|
327
368
|
commands: [],
|
|
@@ -387,9 +428,9 @@ const iotAgentConfigTS = {
|
|
|
387
428
|
port: '1026',
|
|
388
429
|
ngsiVersion: 'v2'
|
|
389
430
|
},
|
|
390
|
-
defaultExpressionLanguage: 'jexl',
|
|
391
431
|
server: {
|
|
392
|
-
port: 4041
|
|
432
|
+
port: 4041,
|
|
433
|
+
host: 'localhost'
|
|
393
434
|
},
|
|
394
435
|
types: {
|
|
395
436
|
GPS: {
|
|
@@ -404,6 +445,57 @@ const iotAgentConfigTS = {
|
|
|
404
445
|
}
|
|
405
446
|
],
|
|
406
447
|
explicitAttrs: true
|
|
448
|
+
},
|
|
449
|
+
WaterTank: {
|
|
450
|
+
commands: [],
|
|
451
|
+
type: 'WaterTank',
|
|
452
|
+
lazy: [],
|
|
453
|
+
active: [
|
|
454
|
+
{
|
|
455
|
+
object_id: 'cnt2',
|
|
456
|
+
name: 'contA',
|
|
457
|
+
type: 'Number'
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
object_id: 'cnt3',
|
|
461
|
+
name: 'contB',
|
|
462
|
+
type: 'Number'
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
object_id: 'false2',
|
|
466
|
+
name: 'waterLeavingTanks',
|
|
467
|
+
type: 'Number',
|
|
468
|
+
expression: 'cnt2*0.1',
|
|
469
|
+
entity_name: 'PA_A_0001',
|
|
470
|
+
entity_type: 'WaterTank'
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
object_id: 'false3',
|
|
474
|
+
name: 'waterLeavingTanks',
|
|
475
|
+
type: 'Number',
|
|
476
|
+
expression: 'cnt3*0.1',
|
|
477
|
+
entity_name: 'PA_B_0001',
|
|
478
|
+
entity_type: 'WaterTank'
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
object_id: 'foostatus2',
|
|
482
|
+
name: 'status',
|
|
483
|
+
type: 'Text',
|
|
484
|
+
expression: 'status',
|
|
485
|
+
entity_name: 'PA_A_0001',
|
|
486
|
+
entity_type: 'WaterTank'
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
object_id: 'foostatus3',
|
|
490
|
+
name: 'status',
|
|
491
|
+
type: 'Text',
|
|
492
|
+
expression: 'status',
|
|
493
|
+
entity_name: 'PA_B_0001',
|
|
494
|
+
entity_type: 'WaterTank'
|
|
495
|
+
}
|
|
496
|
+
],
|
|
497
|
+
explicitAttrs:
|
|
498
|
+
"contA&&contB?['TimeInstant','contA',{object_id:'false2'},'contB',{object_id:'false3'},'status']:contA?['TimeInstant','contA',{object_id:'false2'},{object_id:'foostatus2'}]:contB?['TimeInstant','contB',{object_id:'false3'},{object_id:'foostatus3'}]:[]"
|
|
407
499
|
}
|
|
408
500
|
},
|
|
409
501
|
timestamp: true,
|
|
@@ -1078,7 +1170,7 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
1078
1170
|
.patch(
|
|
1079
1171
|
'/v2/entities/gps1/attrs',
|
|
1080
1172
|
utils.readExampleFile(
|
|
1081
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
1173
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json'
|
|
1082
1174
|
)
|
|
1083
1175
|
)
|
|
1084
1176
|
.query({ type: 'GPS' })
|
|
@@ -1094,6 +1186,56 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
1094
1186
|
});
|
|
1095
1187
|
});
|
|
1096
1188
|
|
|
1189
|
+
describe('When there is an extra measure sent by the device to be removed', function () {
|
|
1190
|
+
// Case: Expression which results is sent as a new attribute
|
|
1191
|
+
const values = [
|
|
1192
|
+
{
|
|
1193
|
+
name: 'lat',
|
|
1194
|
+
type: 'Number',
|
|
1195
|
+
value: 52
|
|
1196
|
+
},
|
|
1197
|
+
{
|
|
1198
|
+
name: 'lon',
|
|
1199
|
+
type: 'Number',
|
|
1200
|
+
value: 13
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
name: 'another',
|
|
1204
|
+
type: 'Number',
|
|
1205
|
+
value: 99
|
|
1206
|
+
},
|
|
1207
|
+
{
|
|
1208
|
+
name: 'TimeInstant',
|
|
1209
|
+
type: 'DateTime',
|
|
1210
|
+
value: '2015-08-05T07:35:01.468+00:00'
|
|
1211
|
+
}
|
|
1212
|
+
];
|
|
1213
|
+
|
|
1214
|
+
beforeEach(function () {
|
|
1215
|
+
nock.cleanAll();
|
|
1216
|
+
|
|
1217
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1218
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1219
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1220
|
+
.patch(
|
|
1221
|
+
'/v2/entities/gps1/attrs',
|
|
1222
|
+
utils.readExampleFile(
|
|
1223
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json'
|
|
1224
|
+
)
|
|
1225
|
+
)
|
|
1226
|
+
.query({ type: 'GPS' })
|
|
1227
|
+
.reply(204);
|
|
1228
|
+
});
|
|
1229
|
+
|
|
1230
|
+
it('should calculate them and remove non-explicitAttrs from the payload', function (done) {
|
|
1231
|
+
iotAgentLib.update('gps1', 'GPS2b', '', values, function (error) {
|
|
1232
|
+
should.not.exist(error);
|
|
1233
|
+
contextBrokerMock.done();
|
|
1234
|
+
done();
|
|
1235
|
+
});
|
|
1236
|
+
});
|
|
1237
|
+
});
|
|
1238
|
+
|
|
1097
1239
|
describe('When there is an extra TimeInstant sent by the device to be removed by string', function () {
|
|
1098
1240
|
// Case: Expression which results is sent as a new attribute
|
|
1099
1241
|
const values = [
|
|
@@ -1234,6 +1376,46 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
1234
1376
|
});
|
|
1235
1377
|
});
|
|
1236
1378
|
|
|
1379
|
+
describe('When there is an extra TimeInstant sent by the device to be removed by jexl expression with context defined with object_id', function () {
|
|
1380
|
+
// Case: Expression which results is sent as a new attribute
|
|
1381
|
+
const values = [
|
|
1382
|
+
{
|
|
1383
|
+
name: 'lon',
|
|
1384
|
+
type: 'Number',
|
|
1385
|
+
value: 13
|
|
1386
|
+
},
|
|
1387
|
+
{
|
|
1388
|
+
name: 'TimeInstant',
|
|
1389
|
+
type: 'DateTime',
|
|
1390
|
+
value: '2015-08-05T07:35:01.468+00:00'
|
|
1391
|
+
}
|
|
1392
|
+
];
|
|
1393
|
+
|
|
1394
|
+
beforeEach(function () {
|
|
1395
|
+
nock.cleanAll();
|
|
1396
|
+
|
|
1397
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1398
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1399
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1400
|
+
.patch(
|
|
1401
|
+
'/v2/entities/gps1/attrs',
|
|
1402
|
+
utils.readExampleFile(
|
|
1403
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json'
|
|
1404
|
+
)
|
|
1405
|
+
)
|
|
1406
|
+
.query({ type: 'GPS' })
|
|
1407
|
+
.reply(204);
|
|
1408
|
+
});
|
|
1409
|
+
|
|
1410
|
+
it('should calculate them and remove non-explicitAttrs by jexl expression with context from the payload ', function (done) {
|
|
1411
|
+
iotAgentLib.update('gps1', 'GPS5b', '', values, function (error) {
|
|
1412
|
+
should.not.exist(error);
|
|
1413
|
+
contextBrokerMock.done();
|
|
1414
|
+
done();
|
|
1415
|
+
});
|
|
1416
|
+
});
|
|
1417
|
+
});
|
|
1418
|
+
|
|
1237
1419
|
describe('When there is an extra TimeInstant sent by the device to be removedb jexl expression using static attrs', function () {
|
|
1238
1420
|
// Case: Expression which results is sent as a new attribute
|
|
1239
1421
|
const values = [
|
|
@@ -1376,4 +1558,46 @@ describe('Java expression language (JEXL) based transformations plugin - Timesta
|
|
|
1376
1558
|
});
|
|
1377
1559
|
});
|
|
1378
1560
|
});
|
|
1561
|
+
|
|
1562
|
+
describe('When explicitAttrs is a jexl expression in a multientity case', function () {
|
|
1563
|
+
// Case: Expression which results is sent as a new attribute
|
|
1564
|
+
const values = [
|
|
1565
|
+
{
|
|
1566
|
+
name: 'cnt3',
|
|
1567
|
+
type: 'Number',
|
|
1568
|
+
value: '31450.000'
|
|
1569
|
+
}
|
|
1570
|
+
];
|
|
1571
|
+
|
|
1572
|
+
beforeEach(function () {
|
|
1573
|
+
const time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00
|
|
1574
|
+
|
|
1575
|
+
timekeeper.freeze(time);
|
|
1576
|
+
nock.cleanAll();
|
|
1577
|
+
|
|
1578
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1579
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1580
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1581
|
+
.post(
|
|
1582
|
+
'/v2/op/update',
|
|
1583
|
+
utils.readExampleFile(
|
|
1584
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json'
|
|
1585
|
+
)
|
|
1586
|
+
)
|
|
1587
|
+
.reply(204);
|
|
1588
|
+
});
|
|
1589
|
+
|
|
1590
|
+
afterEach(function (done) {
|
|
1591
|
+
timekeeper.reset();
|
|
1592
|
+
done();
|
|
1593
|
+
});
|
|
1594
|
+
|
|
1595
|
+
it('should calculate them and not remove the timestamp from the payload', function (done) {
|
|
1596
|
+
iotAgentLib.update('water1', 'WaterTank', '', values, function (error) {
|
|
1597
|
+
should.not.exist(error);
|
|
1598
|
+
contextBrokerMock.done();
|
|
1599
|
+
done();
|
|
1600
|
+
});
|
|
1601
|
+
});
|
|
1602
|
+
});
|
|
1379
1603
|
});
|
|
@@ -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) {
|
|
@@ -43,7 +43,8 @@ const iotAgentConfig = {
|
|
|
43
43
|
ngsiVersion: 'v2'
|
|
44
44
|
},
|
|
45
45
|
server: {
|
|
46
|
-
port: 4041
|
|
46
|
+
port: 4041,
|
|
47
|
+
host: 'localhost'
|
|
47
48
|
},
|
|
48
49
|
types: {
|
|
49
50
|
Light: {
|
|
@@ -139,8 +140,7 @@ const device4 = {
|
|
|
139
140
|
type: 'RobotExp',
|
|
140
141
|
service: 'smartgondor',
|
|
141
142
|
subservice: 'gardens',
|
|
142
|
-
polling: true
|
|
143
|
-
expressionLanguage: 'jexl'
|
|
143
|
+
polling: true
|
|
144
144
|
};
|
|
145
145
|
|
|
146
146
|
describe('NGSI-v2 - Polling commands', function () {
|
|
@@ -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();
|
|
@@ -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',
|
|
@@ -245,11 +246,11 @@ describe('NGSI-v2 - Bidirectional data plugin', function () {
|
|
|
245
246
|
let longitudeFound = false;
|
|
246
247
|
|
|
247
248
|
for (let i = 0; i < values.length; i++) {
|
|
248
|
-
if (values[i].name === 'latitude' && values[i].type === '
|
|
249
|
+
if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
|
|
249
250
|
latitudeFound = true;
|
|
250
251
|
}
|
|
251
252
|
|
|
252
|
-
if (values[i].name === 'longitude' && values[i].type === '
|
|
253
|
+
if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
|
|
253
254
|
longitudeFound = true;
|
|
254
255
|
}
|
|
255
256
|
}
|
|
@@ -356,11 +357,11 @@ describe('NGSI-v2 - Bidirectional data plugin', function () {
|
|
|
356
357
|
let longitudeFound = false;
|
|
357
358
|
|
|
358
359
|
for (let i = 0; i < values.length; i++) {
|
|
359
|
-
if (values[i].name === 'latitude' && values[i].type === '
|
|
360
|
+
if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
|
|
360
361
|
latitudeFound = true;
|
|
361
362
|
}
|
|
362
363
|
|
|
363
|
-
if (values[i].name === 'longitude' && values[i].type === '
|
|
364
|
+
if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
|
|
364
365
|
longitudeFound = true;
|
|
365
366
|
}
|
|
366
367
|
}
|
|
@@ -502,11 +503,11 @@ describe('NGSI-v2 - Bidirectional data plugin', function () {
|
|
|
502
503
|
let longitudeFound = false;
|
|
503
504
|
|
|
504
505
|
for (let i = 0; i < values.length; i++) {
|
|
505
|
-
if (values[i].name === 'latitude' && values[i].type === '
|
|
506
|
+
if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
|
|
506
507
|
latitudeFound = true;
|
|
507
508
|
}
|
|
508
509
|
|
|
509
|
-
if (values[i].name === 'longitude' && values[i].type === '
|
|
510
|
+
if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
|
|
510
511
|
longitudeFound = true;
|
|
511
512
|
}
|
|
512
513
|
}
|