iotagent-node-lib 3.1.0 → 3.3.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/CHANGES_NEXT_RELEASE +0 -2
- package/config.js +5 -5
- package/doc/api.md +1483 -298
- package/doc/deprecated.md +7 -1
- package/doc/development.md +120 -0
- package/doc/howto.md +58 -62
- package/doc/installationguide.md +3 -11
- package/doc/requirements.txt +1 -1
- package/docker/Mosquitto/Dockerfile +1 -1
- package/lib/commonConfig.js +7 -10
- package/lib/fiware-iotagent-lib.js +0 -10
- 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/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/common/iotManagerService.js +0 -1
- package/lib/services/devices/deviceRegistryMongoDB.js +10 -10
- package/lib/services/devices/deviceService.js +16 -20
- package/lib/services/devices/devices-NGSI-v2.js +2 -5
- package/lib/services/ngsi/entities-NGSI-LD.js +16 -60
- package/lib/services/ngsi/entities-NGSI-v2.js +179 -119
- package/lib/services/northBound/deviceProvisioningServer.js +17 -17
- package/lib/templates/createDevice.json +5 -6
- package/lib/templates/createDeviceLax.json +6 -8
- package/lib/templates/deviceGroup.json +1 -5
- package/lib/templates/updateDevice.json +9 -2
- package/lib/templates/updateDeviceLax.json +14 -5
- package/package.json +1 -1
- package/scripts/legacy_expression_tool/README.md +262 -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/provisionBidirectionalDevice.json +5 -5
- package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +4 -4
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +3 -13
- package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +0 -2
- package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +31 -30
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +8 -8
- package/test/unit/ngsi-ld/plugins/custom-plugin_test.js +152 -0
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +1 -1
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +33 -37
- package/test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice4.json +5 -1
- 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 +10 -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 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +2 -8
- 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 +22 -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 +42 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +33 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +2 -0
- 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 +37 -0
- 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 +355 -75
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +18 -51
- package/test/unit/ngsiv2/general/https-support-test.js +1 -5
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +4 -10
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +9 -26
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +143 -57
- 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 +1 -10
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +20 -30
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +6 -69
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +4 -6
- package/test/unit/ngsiv2/plugins/custom-plugin_test.js +150 -0
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +87 -16
- 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 +15 -55
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +1 -7
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +2 -9
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -11
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +0 -7
- package/test/unit/plugins/capture-provision-inPlugins_test.js +0 -6
- 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 -882
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +0 -951
- package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +0 -296
|
@@ -39,7 +39,6 @@ const iotAgentConfig = {
|
|
|
39
39
|
port: '1026',
|
|
40
40
|
ngsiVersion: 'v2'
|
|
41
41
|
},
|
|
42
|
-
defaultExpressionLanguage: 'jexl',
|
|
43
42
|
server: {
|
|
44
43
|
port: 4041,
|
|
45
44
|
host: 'localhost'
|
|
@@ -126,7 +125,7 @@ const iotAgentConfig = {
|
|
|
126
125
|
{
|
|
127
126
|
name: 'weather',
|
|
128
127
|
type: 'Summary',
|
|
129
|
-
expression: '"Humidity " + (humidity / 2) + " and pressure " + (
|
|
128
|
+
expression: '"Humidity " + (humidity / 2) + " and pressure " + (p * 20)'
|
|
130
129
|
},
|
|
131
130
|
{
|
|
132
131
|
object_id: 'a',
|
|
@@ -250,6 +249,24 @@ const iotAgentConfig = {
|
|
|
250
249
|
],
|
|
251
250
|
explicitAttrs: true
|
|
252
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
|
+
},
|
|
253
270
|
GPS3: {
|
|
254
271
|
commands: [],
|
|
255
272
|
type: 'GPS',
|
|
@@ -321,8 +338,31 @@ const iotAgentConfig = {
|
|
|
321
338
|
}
|
|
322
339
|
],
|
|
323
340
|
explicitAttrs: "theLocation ? ['mylocation'] : []"
|
|
324
|
-
|
|
325
|
-
|
|
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'}] : []"
|
|
326
366
|
},
|
|
327
367
|
GPS6: {
|
|
328
368
|
commands: [],
|
|
@@ -372,6 +412,36 @@ const iotAgentConfig = {
|
|
|
372
412
|
}
|
|
373
413
|
],
|
|
374
414
|
explicitAttrs: '[ ]'
|
|
415
|
+
},
|
|
416
|
+
skipvalue: {
|
|
417
|
+
commands: [],
|
|
418
|
+
type: 'skipvalue',
|
|
419
|
+
lazy: [],
|
|
420
|
+
active: [
|
|
421
|
+
{
|
|
422
|
+
name: 'alwaysSkip',
|
|
423
|
+
type: 'Number',
|
|
424
|
+
skipValue: true,
|
|
425
|
+
expression: 'true'
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
name: 'neverSkip',
|
|
429
|
+
type: 'Number',
|
|
430
|
+
skipValue: true,
|
|
431
|
+
expression: 'false'
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
name: 'skip',
|
|
435
|
+
type: 'Number',
|
|
436
|
+
skipValue: 33,
|
|
437
|
+
expression: 'condition'
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
object_id: 'condition',
|
|
441
|
+
name: 'condition',
|
|
442
|
+
type: 'Number'
|
|
443
|
+
}
|
|
444
|
+
]
|
|
375
445
|
}
|
|
376
446
|
},
|
|
377
447
|
service: 'smartgondor',
|
|
@@ -388,7 +458,6 @@ const iotAgentConfigTS = {
|
|
|
388
458
|
port: '1026',
|
|
389
459
|
ngsiVersion: 'v2'
|
|
390
460
|
},
|
|
391
|
-
defaultExpressionLanguage: 'jexl',
|
|
392
461
|
server: {
|
|
393
462
|
port: 4041,
|
|
394
463
|
host: 'localhost'
|
|
@@ -406,6 +475,57 @@ const iotAgentConfigTS = {
|
|
|
406
475
|
}
|
|
407
476
|
],
|
|
408
477
|
explicitAttrs: true
|
|
478
|
+
},
|
|
479
|
+
WaterTank: {
|
|
480
|
+
commands: [],
|
|
481
|
+
type: 'WaterTank',
|
|
482
|
+
lazy: [],
|
|
483
|
+
active: [
|
|
484
|
+
{
|
|
485
|
+
object_id: 'cnt2',
|
|
486
|
+
name: 'contA',
|
|
487
|
+
type: 'Number'
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
object_id: 'cnt3',
|
|
491
|
+
name: 'contB',
|
|
492
|
+
type: 'Number'
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
object_id: 'false2',
|
|
496
|
+
name: 'waterLeavingTanks',
|
|
497
|
+
type: 'Number',
|
|
498
|
+
expression: 'cnt2*0.1',
|
|
499
|
+
entity_name: 'PA_A_0001',
|
|
500
|
+
entity_type: 'WaterTank'
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
object_id: 'false3',
|
|
504
|
+
name: 'waterLeavingTanks',
|
|
505
|
+
type: 'Number',
|
|
506
|
+
expression: 'cnt3*0.1',
|
|
507
|
+
entity_name: 'PA_B_0001',
|
|
508
|
+
entity_type: 'WaterTank'
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
object_id: 'foostatus2',
|
|
512
|
+
name: 'status',
|
|
513
|
+
type: 'Text',
|
|
514
|
+
expression: 'status',
|
|
515
|
+
entity_name: 'PA_A_0001',
|
|
516
|
+
entity_type: 'WaterTank'
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
object_id: 'foostatus3',
|
|
520
|
+
name: 'status',
|
|
521
|
+
type: 'Text',
|
|
522
|
+
expression: 'status',
|
|
523
|
+
entity_name: 'PA_B_0001',
|
|
524
|
+
entity_type: 'WaterTank'
|
|
525
|
+
}
|
|
526
|
+
],
|
|
527
|
+
explicitAttrs:
|
|
528
|
+
"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'}]:[]"
|
|
409
529
|
}
|
|
410
530
|
},
|
|
411
531
|
timestamp: true,
|
|
@@ -447,13 +567,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
447
567
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
448
568
|
.matchHeader('fiware-service', 'smartgondor')
|
|
449
569
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
450
|
-
.
|
|
451
|
-
'/v2/entities
|
|
570
|
+
.post(
|
|
571
|
+
'/v2/entities?options=upsert',
|
|
452
572
|
utils.readExampleFile(
|
|
453
573
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json'
|
|
454
574
|
)
|
|
455
575
|
)
|
|
456
|
-
.query({ type: 'Light' })
|
|
457
576
|
.reply(204);
|
|
458
577
|
});
|
|
459
578
|
|
|
@@ -487,13 +606,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
487
606
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
488
607
|
.matchHeader('fiware-service', 'smartgondor')
|
|
489
608
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
490
|
-
.
|
|
491
|
-
'/v2/entities
|
|
609
|
+
.post(
|
|
610
|
+
'/v2/entities?options=upsert',
|
|
492
611
|
utils.readExampleFile(
|
|
493
612
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json'
|
|
494
613
|
)
|
|
495
614
|
)
|
|
496
|
-
.query({ type: 'WeatherStation' })
|
|
497
615
|
.reply(204);
|
|
498
616
|
});
|
|
499
617
|
|
|
@@ -528,13 +646,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
528
646
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
529
647
|
.matchHeader('fiware-service', 'smartgondor')
|
|
530
648
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
531
|
-
.
|
|
532
|
-
'/v2/entities
|
|
649
|
+
.post(
|
|
650
|
+
'/v2/entities?options=upsert',
|
|
533
651
|
utils.readExampleFile(
|
|
534
652
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json'
|
|
535
653
|
)
|
|
536
654
|
)
|
|
537
|
-
.query({ type: 'WeatherStation' })
|
|
538
655
|
.reply(204);
|
|
539
656
|
});
|
|
540
657
|
|
|
@@ -563,13 +680,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
563
680
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
564
681
|
.matchHeader('fiware-service', 'smartgondor')
|
|
565
682
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
566
|
-
.
|
|
567
|
-
'/v2/entities
|
|
683
|
+
.post(
|
|
684
|
+
'/v2/entities?options=upsert',
|
|
568
685
|
utils.readExampleFile(
|
|
569
686
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json'
|
|
570
687
|
)
|
|
571
688
|
)
|
|
572
|
-
.query({ type: 'Light' })
|
|
573
689
|
.reply(204);
|
|
574
690
|
});
|
|
575
691
|
|
|
@@ -598,13 +714,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
598
714
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
599
715
|
.matchHeader('fiware-service', 'smartgondor')
|
|
600
716
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
601
|
-
.
|
|
602
|
-
'/v2/entities
|
|
717
|
+
.post(
|
|
718
|
+
'/v2/entities?options=upsert',
|
|
603
719
|
utils.readExampleFile(
|
|
604
720
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json'
|
|
605
721
|
)
|
|
606
722
|
)
|
|
607
|
-
.query({ type: 'WeatherStation' })
|
|
608
723
|
.reply(204);
|
|
609
724
|
});
|
|
610
725
|
|
|
@@ -634,13 +749,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
634
749
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
635
750
|
.matchHeader('fiware-service', 'smartgondor')
|
|
636
751
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
637
|
-
.
|
|
638
|
-
'/v2/entities
|
|
752
|
+
.post(
|
|
753
|
+
'/v2/entities?options=upsert',
|
|
639
754
|
utils.readExampleFile(
|
|
640
755
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json'
|
|
641
756
|
)
|
|
642
757
|
)
|
|
643
|
-
.query({ type: 'Light' })
|
|
644
758
|
.reply(204);
|
|
645
759
|
});
|
|
646
760
|
|
|
@@ -670,13 +784,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
670
784
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
671
785
|
.matchHeader('fiware-service', 'smartgondor')
|
|
672
786
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
673
|
-
.
|
|
674
|
-
'/v2/entities
|
|
787
|
+
.post(
|
|
788
|
+
'/v2/entities?options=upsert',
|
|
675
789
|
utils.readExampleFile(
|
|
676
790
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json'
|
|
677
791
|
)
|
|
678
792
|
)
|
|
679
|
-
.query({ type: 'WeatherStation' })
|
|
680
793
|
.reply(204);
|
|
681
794
|
});
|
|
682
795
|
|
|
@@ -706,13 +819,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
706
819
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
707
820
|
.matchHeader('fiware-service', 'smartgondor')
|
|
708
821
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
709
|
-
.
|
|
710
|
-
'/v2/entities
|
|
822
|
+
.post(
|
|
823
|
+
'/v2/entities?options=upsert',
|
|
711
824
|
utils.readExampleFile(
|
|
712
825
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json'
|
|
713
826
|
)
|
|
714
827
|
)
|
|
715
|
-
.query({ type: 'Light' })
|
|
716
828
|
.reply(204);
|
|
717
829
|
});
|
|
718
830
|
|
|
@@ -742,13 +854,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
742
854
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
743
855
|
.matchHeader('fiware-service', 'smartgondor')
|
|
744
856
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
745
|
-
.
|
|
746
|
-
'/v2/entities
|
|
857
|
+
.post(
|
|
858
|
+
'/v2/entities?options=upsert',
|
|
747
859
|
utils.readExampleFile(
|
|
748
860
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json'
|
|
749
861
|
)
|
|
750
862
|
)
|
|
751
|
-
.query({ type: 'Light' })
|
|
752
863
|
.reply(204);
|
|
753
864
|
});
|
|
754
865
|
|
|
@@ -777,13 +888,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
777
888
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
778
889
|
.matchHeader('fiware-service', 'smartgondor')
|
|
779
890
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
780
|
-
.
|
|
781
|
-
'/v2/entities
|
|
891
|
+
.post(
|
|
892
|
+
'/v2/entities?options=upsert',
|
|
782
893
|
utils.readExampleFile(
|
|
783
894
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json'
|
|
784
895
|
)
|
|
785
896
|
)
|
|
786
|
-
.query({ type: 'Light' })
|
|
787
897
|
.reply(204);
|
|
788
898
|
});
|
|
789
899
|
|
|
@@ -813,13 +923,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
813
923
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
814
924
|
.matchHeader('fiware-service', 'smartgondor')
|
|
815
925
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
816
|
-
.
|
|
817
|
-
'/v2/entities
|
|
926
|
+
.post(
|
|
927
|
+
'/v2/entities?options=upsert',
|
|
818
928
|
utils.readExampleFile(
|
|
819
929
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json'
|
|
820
930
|
)
|
|
821
931
|
)
|
|
822
|
-
.query({ type: 'Light' })
|
|
823
932
|
.reply(204);
|
|
824
933
|
});
|
|
825
934
|
|
|
@@ -847,13 +956,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
847
956
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
848
957
|
.matchHeader('fiware-service', 'smartgondor')
|
|
849
958
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
850
|
-
.
|
|
851
|
-
'/v2/entities
|
|
959
|
+
.post(
|
|
960
|
+
'/v2/entities?options=upsert',
|
|
852
961
|
utils.readExampleFile(
|
|
853
962
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json'
|
|
854
963
|
)
|
|
855
964
|
)
|
|
856
|
-
.query({ type: 'Light' })
|
|
857
965
|
.reply(204);
|
|
858
966
|
});
|
|
859
967
|
|
|
@@ -881,13 +989,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
881
989
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
882
990
|
.matchHeader('fiware-service', 'smartgondor')
|
|
883
991
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
884
|
-
.
|
|
885
|
-
'/v2/entities
|
|
992
|
+
.post(
|
|
993
|
+
'/v2/entities?options=upsert',
|
|
886
994
|
utils.readExampleFile(
|
|
887
995
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json'
|
|
888
996
|
)
|
|
889
997
|
)
|
|
890
|
-
.query({ type: 'Light' })
|
|
891
998
|
.reply(204);
|
|
892
999
|
});
|
|
893
1000
|
|
|
@@ -920,13 +1027,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
920
1027
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
921
1028
|
.matchHeader('fiware-service', 'smartgondor')
|
|
922
1029
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
923
|
-
.
|
|
924
|
-
'/v2/entities
|
|
1030
|
+
.post(
|
|
1031
|
+
'/v2/entities?options=upsert',
|
|
925
1032
|
utils.readExampleFile(
|
|
926
1033
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json'
|
|
927
1034
|
)
|
|
928
1035
|
)
|
|
929
|
-
.query({ type: 'Light' })
|
|
930
1036
|
.reply(204);
|
|
931
1037
|
});
|
|
932
1038
|
|
|
@@ -954,13 +1060,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
954
1060
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
955
1061
|
.matchHeader('fiware-service', 'smartgondor')
|
|
956
1062
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
957
|
-
.
|
|
958
|
-
'/v2/entities
|
|
1063
|
+
.post(
|
|
1064
|
+
'/v2/entities?options=upsert',
|
|
959
1065
|
utils.readExampleFile(
|
|
960
1066
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json'
|
|
961
1067
|
)
|
|
962
1068
|
)
|
|
963
|
-
.query({ type: 'WeatherStation' })
|
|
964
1069
|
.reply(204);
|
|
965
1070
|
});
|
|
966
1071
|
|
|
@@ -987,13 +1092,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
987
1092
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
988
1093
|
.matchHeader('fiware-service', 'smartgondor')
|
|
989
1094
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
990
|
-
.
|
|
991
|
-
'/v2/entities
|
|
1095
|
+
.post(
|
|
1096
|
+
'/v2/entities?options=upsert',
|
|
992
1097
|
utils.readExampleFile(
|
|
993
1098
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json'
|
|
994
1099
|
)
|
|
995
1100
|
)
|
|
996
|
-
.query({ type: 'WeatherStation' })
|
|
997
1101
|
.reply(204);
|
|
998
1102
|
});
|
|
999
1103
|
|
|
@@ -1032,13 +1136,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
1032
1136
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1033
1137
|
.matchHeader('fiware-service', 'smartgondor')
|
|
1034
1138
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
1035
|
-
.
|
|
1036
|
-
'/v2/entities
|
|
1139
|
+
.post(
|
|
1140
|
+
'/v2/entities?options=upsert',
|
|
1037
1141
|
utils.readExampleFile(
|
|
1038
1142
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json'
|
|
1039
1143
|
)
|
|
1040
1144
|
)
|
|
1041
|
-
.query({ type: 'GPS' })
|
|
1042
1145
|
.reply(204);
|
|
1043
1146
|
});
|
|
1044
1147
|
|
|
@@ -1077,13 +1180,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
1077
1180
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1078
1181
|
.matchHeader('fiware-service', 'smartgondor')
|
|
1079
1182
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
1080
|
-
.
|
|
1081
|
-
'/v2/entities
|
|
1183
|
+
.post(
|
|
1184
|
+
'/v2/entities?options=upsert',
|
|
1082
1185
|
utils.readExampleFile(
|
|
1083
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
1186
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json'
|
|
1084
1187
|
)
|
|
1085
1188
|
)
|
|
1086
|
-
.query({ type: 'GPS' })
|
|
1087
1189
|
.reply(204);
|
|
1088
1190
|
});
|
|
1089
1191
|
|
|
@@ -1096,6 +1198,55 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
1096
1198
|
});
|
|
1097
1199
|
});
|
|
1098
1200
|
|
|
1201
|
+
describe('When there is an extra measure sent by the device to be removed', function () {
|
|
1202
|
+
// Case: Expression which results is sent as a new attribute
|
|
1203
|
+
const values = [
|
|
1204
|
+
{
|
|
1205
|
+
name: 'lat',
|
|
1206
|
+
type: 'Number',
|
|
1207
|
+
value: 52
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
name: 'lon',
|
|
1211
|
+
type: 'Number',
|
|
1212
|
+
value: 13
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
name: 'another',
|
|
1216
|
+
type: 'Number',
|
|
1217
|
+
value: 99
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
name: 'TimeInstant',
|
|
1221
|
+
type: 'DateTime',
|
|
1222
|
+
value: '2015-08-05T07:35:01.468+00:00'
|
|
1223
|
+
}
|
|
1224
|
+
];
|
|
1225
|
+
|
|
1226
|
+
beforeEach(function () {
|
|
1227
|
+
nock.cleanAll();
|
|
1228
|
+
|
|
1229
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1230
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1231
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1232
|
+
.post(
|
|
1233
|
+
'/v2/entities?options=upsert',
|
|
1234
|
+
utils.readExampleFile(
|
|
1235
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json'
|
|
1236
|
+
)
|
|
1237
|
+
)
|
|
1238
|
+
.reply(204);
|
|
1239
|
+
});
|
|
1240
|
+
|
|
1241
|
+
it('should calculate them and remove non-explicitAttrs from the payload', function (done) {
|
|
1242
|
+
iotAgentLib.update('gps1', 'GPS2b', '', values, function (error) {
|
|
1243
|
+
should.not.exist(error);
|
|
1244
|
+
contextBrokerMock.done();
|
|
1245
|
+
done();
|
|
1246
|
+
});
|
|
1247
|
+
});
|
|
1248
|
+
});
|
|
1249
|
+
|
|
1099
1250
|
describe('When there is an extra TimeInstant sent by the device to be removed by string', function () {
|
|
1100
1251
|
// Case: Expression which results is sent as a new attribute
|
|
1101
1252
|
const values = [
|
|
@@ -1122,13 +1273,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
1122
1273
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1123
1274
|
.matchHeader('fiware-service', 'smartgondor')
|
|
1124
1275
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
1125
|
-
.
|
|
1126
|
-
'/v2/entities
|
|
1276
|
+
.post(
|
|
1277
|
+
'/v2/entities?options=upsert',
|
|
1127
1278
|
utils.readExampleFile(
|
|
1128
1279
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json'
|
|
1129
1280
|
)
|
|
1130
1281
|
)
|
|
1131
|
-
.query({ type: 'GPS' })
|
|
1132
1282
|
.reply(204);
|
|
1133
1283
|
});
|
|
1134
1284
|
|
|
@@ -1167,13 +1317,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
1167
1317
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1168
1318
|
.matchHeader('fiware-service', 'smartgondor')
|
|
1169
1319
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
1170
|
-
.
|
|
1171
|
-
'/v2/entities
|
|
1320
|
+
.post(
|
|
1321
|
+
'/v2/entities?options=upsert',
|
|
1172
1322
|
utils.readExampleFile(
|
|
1173
1323
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json'
|
|
1174
1324
|
)
|
|
1175
1325
|
)
|
|
1176
|
-
.query({ type: 'GPS' })
|
|
1177
1326
|
.reply(204);
|
|
1178
1327
|
});
|
|
1179
1328
|
|
|
@@ -1217,13 +1366,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
1217
1366
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1218
1367
|
.matchHeader('fiware-service', 'smartgondor')
|
|
1219
1368
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
1220
|
-
.
|
|
1221
|
-
'/v2/entities
|
|
1369
|
+
.post(
|
|
1370
|
+
'/v2/entities?options=upsert',
|
|
1222
1371
|
utils.readExampleFile(
|
|
1223
1372
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json'
|
|
1224
1373
|
)
|
|
1225
1374
|
)
|
|
1226
|
-
.query({ type: 'GPS' })
|
|
1227
1375
|
.reply(204);
|
|
1228
1376
|
});
|
|
1229
1377
|
|
|
@@ -1236,6 +1384,45 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
1236
1384
|
});
|
|
1237
1385
|
});
|
|
1238
1386
|
|
|
1387
|
+
describe('When there is an extra TimeInstant sent by the device to be removed by jexl expression with context defined with object_id', function () {
|
|
1388
|
+
// Case: Expression which results is sent as a new attribute
|
|
1389
|
+
const values = [
|
|
1390
|
+
{
|
|
1391
|
+
name: 'lon',
|
|
1392
|
+
type: 'Number',
|
|
1393
|
+
value: 13
|
|
1394
|
+
},
|
|
1395
|
+
{
|
|
1396
|
+
name: 'TimeInstant',
|
|
1397
|
+
type: 'DateTime',
|
|
1398
|
+
value: '2015-08-05T07:35:01.468+00:00'
|
|
1399
|
+
}
|
|
1400
|
+
];
|
|
1401
|
+
|
|
1402
|
+
beforeEach(function () {
|
|
1403
|
+
nock.cleanAll();
|
|
1404
|
+
|
|
1405
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1406
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1407
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1408
|
+
.post(
|
|
1409
|
+
'/v2/entities?options=upsert',
|
|
1410
|
+
utils.readExampleFile(
|
|
1411
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json'
|
|
1412
|
+
)
|
|
1413
|
+
)
|
|
1414
|
+
.reply(204);
|
|
1415
|
+
});
|
|
1416
|
+
|
|
1417
|
+
it('should calculate them and remove non-explicitAttrs by jexl expression with context from the payload ', function (done) {
|
|
1418
|
+
iotAgentLib.update('gps1', 'GPS5b', '', values, function (error) {
|
|
1419
|
+
should.not.exist(error);
|
|
1420
|
+
contextBrokerMock.done();
|
|
1421
|
+
done();
|
|
1422
|
+
});
|
|
1423
|
+
});
|
|
1424
|
+
});
|
|
1425
|
+
|
|
1239
1426
|
describe('When there is an extra TimeInstant sent by the device to be removedb jexl expression using static attrs', function () {
|
|
1240
1427
|
// Case: Expression which results is sent as a new attribute
|
|
1241
1428
|
const values = [
|
|
@@ -1252,13 +1439,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
1252
1439
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1253
1440
|
.matchHeader('fiware-service', 'smartgondor')
|
|
1254
1441
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
1255
|
-
.
|
|
1256
|
-
'/v2/entities
|
|
1442
|
+
.post(
|
|
1443
|
+
'/v2/entities?options=upsert',
|
|
1257
1444
|
utils.readExampleFile(
|
|
1258
1445
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json'
|
|
1259
1446
|
)
|
|
1260
1447
|
)
|
|
1261
|
-
.query({ type: 'GPS' })
|
|
1262
1448
|
.reply(204);
|
|
1263
1449
|
});
|
|
1264
1450
|
|
|
@@ -1307,6 +1493,59 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
1307
1493
|
});
|
|
1308
1494
|
});
|
|
1309
1495
|
});
|
|
1496
|
+
|
|
1497
|
+
describe('When using skipValue is expression in a device', function () {
|
|
1498
|
+
// Case: Expression which results is sent as a new attribute
|
|
1499
|
+
const values = [
|
|
1500
|
+
{
|
|
1501
|
+
name: 'alwaysSkip',
|
|
1502
|
+
type: 'Number',
|
|
1503
|
+
value: 1
|
|
1504
|
+
},
|
|
1505
|
+
{
|
|
1506
|
+
name: 'neverSkip',
|
|
1507
|
+
type: 'Number',
|
|
1508
|
+
value: 2
|
|
1509
|
+
},
|
|
1510
|
+
{
|
|
1511
|
+
name: 'skip',
|
|
1512
|
+
type: 'Number',
|
|
1513
|
+
value: 3
|
|
1514
|
+
},
|
|
1515
|
+
{
|
|
1516
|
+
name: 'condition',
|
|
1517
|
+
type: 'Number',
|
|
1518
|
+
value: 33
|
|
1519
|
+
}
|
|
1520
|
+
];
|
|
1521
|
+
|
|
1522
|
+
beforeEach(function () {
|
|
1523
|
+
nock.cleanAll();
|
|
1524
|
+
|
|
1525
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1526
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1527
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1528
|
+
.post(
|
|
1529
|
+
'/v2/entities?options=upsert',
|
|
1530
|
+
utils.readExampleFile(
|
|
1531
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionSkip.json'
|
|
1532
|
+
)
|
|
1533
|
+
)
|
|
1534
|
+
.reply(204);
|
|
1535
|
+
});
|
|
1536
|
+
|
|
1537
|
+
afterEach(function (done) {
|
|
1538
|
+
done();
|
|
1539
|
+
});
|
|
1540
|
+
|
|
1541
|
+
it('should not propagate skipped values', function (done) {
|
|
1542
|
+
iotAgentLib.update('skip1', 'skipvalue', '', values, function (error) {
|
|
1543
|
+
should.not.exist(error);
|
|
1544
|
+
contextBrokerMock.done();
|
|
1545
|
+
done();
|
|
1546
|
+
});
|
|
1547
|
+
});
|
|
1548
|
+
});
|
|
1310
1549
|
});
|
|
1311
1550
|
|
|
1312
1551
|
describe('Java expression language (JEXL) based transformations plugin - Timestamps', function () {
|
|
@@ -1355,13 +1594,12 @@ describe('Java expression language (JEXL) based transformations plugin - Timesta
|
|
|
1355
1594
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1356
1595
|
.matchHeader('fiware-service', 'smartgondor')
|
|
1357
1596
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
1358
|
-
.
|
|
1359
|
-
'/v2/entities
|
|
1597
|
+
.post(
|
|
1598
|
+
'/v2/entities?options=upsert',
|
|
1360
1599
|
utils.readExampleFile(
|
|
1361
1600
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json'
|
|
1362
1601
|
)
|
|
1363
1602
|
)
|
|
1364
|
-
.query({ type: 'GPS' })
|
|
1365
1603
|
.reply(204);
|
|
1366
1604
|
});
|
|
1367
1605
|
|
|
@@ -1378,4 +1616,46 @@ describe('Java expression language (JEXL) based transformations plugin - Timesta
|
|
|
1378
1616
|
});
|
|
1379
1617
|
});
|
|
1380
1618
|
});
|
|
1619
|
+
|
|
1620
|
+
describe('When explicitAttrs is a jexl expression in a multientity case', function () {
|
|
1621
|
+
// Case: Expression which results is sent as a new attribute
|
|
1622
|
+
const values = [
|
|
1623
|
+
{
|
|
1624
|
+
name: 'cnt3',
|
|
1625
|
+
type: 'Number',
|
|
1626
|
+
value: '31450.000'
|
|
1627
|
+
}
|
|
1628
|
+
];
|
|
1629
|
+
|
|
1630
|
+
beforeEach(function () {
|
|
1631
|
+
const time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00
|
|
1632
|
+
|
|
1633
|
+
timekeeper.freeze(time);
|
|
1634
|
+
nock.cleanAll();
|
|
1635
|
+
|
|
1636
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1637
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1638
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1639
|
+
.post(
|
|
1640
|
+
'/v2/op/update',
|
|
1641
|
+
utils.readExampleFile(
|
|
1642
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json'
|
|
1643
|
+
)
|
|
1644
|
+
)
|
|
1645
|
+
.reply(204);
|
|
1646
|
+
});
|
|
1647
|
+
|
|
1648
|
+
afterEach(function (done) {
|
|
1649
|
+
timekeeper.reset();
|
|
1650
|
+
done();
|
|
1651
|
+
});
|
|
1652
|
+
|
|
1653
|
+
it('should calculate them and not remove the timestamp from the payload', function (done) {
|
|
1654
|
+
iotAgentLib.update('water1', 'WaterTank', '', values, function (error) {
|
|
1655
|
+
should.not.exist(error);
|
|
1656
|
+
contextBrokerMock.done();
|
|
1657
|
+
done();
|
|
1658
|
+
});
|
|
1659
|
+
});
|
|
1660
|
+
});
|
|
1381
1661
|
});
|