iotagent-node-lib 3.2.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.
Files changed (141) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.yml +134 -0
  2. package/.github/ISSUE_TEMPLATE/config.yml +16 -0
  3. package/.github/ISSUE_TEMPLATE/feature_request.yml +55 -0
  4. package/.github/advanced-issue-labeler.yml +30 -0
  5. package/.github/workflows/issue-labeler.yml +43 -0
  6. package/doc/api.md +23 -80
  7. package/doc/deprecated.md +4 -0
  8. package/doc/howto.md +58 -62
  9. package/doc/installationguide.md +0 -5
  10. package/doc/requirements.txt +1 -1
  11. package/docker/Mosquitto/Dockerfile +1 -1
  12. package/lib/model/Device.js +0 -1
  13. package/lib/model/Group.js +0 -1
  14. package/lib/model/dbConn.js +1 -7
  15. package/lib/plugins/jexlParser.js +1 -1
  16. package/lib/services/common/iotManagerService.js +0 -1
  17. package/lib/services/devices/deviceRegistryMongoDB.js +10 -10
  18. package/lib/services/devices/deviceService.js +14 -19
  19. package/lib/services/devices/devices-NGSI-v2.js +2 -5
  20. package/lib/services/ngsi/entities-NGSI-LD.js +3 -3
  21. package/lib/services/ngsi/entities-NGSI-v2.js +34 -11
  22. package/lib/services/northBound/deviceProvisioningServer.js +0 -3
  23. package/lib/templates/createDevice.json +0 -4
  24. package/lib/templates/createDeviceLax.json +0 -4
  25. package/lib/templates/deviceGroup.json +1 -5
  26. package/lib/templates/updateDevice.json +4 -0
  27. package/lib/templates/updateDeviceLax.json +11 -0
  28. package/package.json +1 -1
  29. package/scripts/legacy_expression_tool/README.md +262 -0
  30. package/scripts/legacy_expression_tool/legacy_expression_tool.py +423 -0
  31. package/scripts/legacy_expression_tool/requirements.txt +3 -0
  32. package/test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice4.json +0 -1
  33. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +3 -13
  34. package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +31 -30
  35. package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +33 -37
  36. package/test/unit/ngsiv2/examples/contextRequests/updateContext.json +2 -0
  37. package/test/unit/ngsiv2/examples/contextRequests/updateContext1.json +3 -1
  38. package/test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json +2 -0
  39. package/test/unit/ngsiv2/examples/contextRequests/updateContext4.json +4 -1
  40. package/test/unit/ngsiv2/examples/contextRequests/updateContext5.json +12 -0
  41. package/test/unit/ngsiv2/examples/contextRequests/updateContext6.json +10 -0
  42. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json +2 -0
  43. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin2.json +3 -1
  44. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json +3 -1
  45. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin4.json +3 -1
  46. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin5.json +3 -1
  47. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin6.json +3 -1
  48. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin7.json +3 -1
  49. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +3 -1
  50. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin9.json +3 -1
  51. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast1.json +2 -0
  52. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast2.json +2 -0
  53. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast3.json +3 -1
  54. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast4.json +3 -1
  55. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast5.json +3 -1
  56. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast6.json +3 -1
  57. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast7.json +3 -1
  58. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandError.json +3 -1
  59. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandExpired.json +3 -1
  60. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandFinish.json +3 -1
  61. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json +2 -0
  62. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus2.json +2 -0
  63. package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp1.json +3 -1
  64. package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp2.json +3 -1
  65. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +2 -0
  66. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +2 -0
  67. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +2 -0
  68. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json +3 -1
  69. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +2 -0
  70. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +2 -0
  71. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +2 -0
  72. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +2 -0
  73. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +2 -0
  74. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +2 -0
  75. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +2 -0
  76. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +2 -0
  77. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +2 -0
  78. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json +1 -0
  79. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json +2 -0
  80. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json +1 -1
  81. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +1 -0
  82. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +2 -0
  83. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +2 -0
  84. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +2 -0
  85. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +2 -0
  86. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +2 -0
  87. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionSkip.json +12 -0
  88. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityJexlExpressionPlugin1.json +1 -1
  89. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json +1 -1
  90. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json +1 -1
  91. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +1 -1
  92. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json +1 -1
  93. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json +1 -1
  94. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json +1 -1
  95. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +1 -1
  96. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +1 -1
  97. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin17.json +1 -1
  98. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json +1 -1
  99. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +1 -1
  100. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json +1 -1
  101. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +1 -1
  102. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +1 -1
  103. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +1 -1
  104. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -1
  105. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +1 -1
  106. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin9.json +1 -1
  107. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +1 -1
  108. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +1 -1
  109. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
  110. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -0
  111. package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +2 -0
  112. package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributes.json +2 -0
  113. package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +3 -1
  114. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestamp.json +3 -1
  115. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalse.json +12 -0
  116. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalseTimeInstant.json +12 -0
  117. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +2 -0
  118. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +2 -0
  119. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampTimezone.json +3 -1
  120. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +133 -75
  121. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +18 -51
  122. package/test/unit/ngsiv2/general/https-support-test.js +1 -5
  123. package/test/unit/ngsiv2/lazyAndCommands/command-test.js +4 -10
  124. package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +8 -24
  125. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +143 -57
  126. package/test/unit/ngsiv2/ngsiService/autocast-test.js +14 -21
  127. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +3 -5
  128. package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +1 -10
  129. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +20 -30
  130. package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +0 -63
  131. package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +4 -6
  132. package/test/unit/ngsiv2/plugins/custom-plugin_test.js +1 -2
  133. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +3 -5
  134. package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -3
  135. package/test/unit/ngsiv2/provisioning/device-group-api-test.js +2 -3
  136. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +5 -53
  137. package/test/unit/ngsiv2/provisioning/device-registration_test.js +1 -7
  138. package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +2 -9
  139. package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -11
  140. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +0 -7
  141. package/test/unit/plugins/capture-provision-inPlugins_test.js +0 -6
@@ -1,5 +1,5 @@
1
1
  {
2
- "actionType": "update",
2
+ "actionType": "append",
3
3
  "entities": [
4
4
  { "id": "ws6",
5
5
  "type": "WeatherStation"
@@ -1,5 +1,5 @@
1
1
  {
2
- "actionType": "update",
2
+ "actionType": "append",
3
3
  "entities": [
4
4
  {
5
5
  "id": "Sensor",
@@ -1,5 +1,5 @@
1
1
  {
2
- "actionType": "update",
2
+ "actionType": "append",
3
3
  "entities": [
4
4
  {
5
5
  "id": "Sensor",
@@ -1,5 +1,5 @@
1
1
  {
2
- "actionType": "update",
2
+ "actionType": "append",
3
3
  "entities": [
4
4
  {
5
5
  "id": "ws7",
@@ -1,5 +1,5 @@
1
1
  {
2
- "actionType": "update",
2
+ "actionType": "append",
3
3
  "entities": [
4
4
  {
5
5
  "id": "ws8",
@@ -41,5 +41,5 @@
41
41
  }
42
42
  }
43
43
  ],
44
- "actionType": "update"
44
+ "actionType": "append"
45
45
  }
@@ -24,5 +24,5 @@
24
24
  }
25
25
  }
26
26
  ],
27
- "actionType": "update"
27
+ "actionType": "append"
28
28
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "actionType": "update",
2
+ "actionType": "append",
3
3
  "entities": [
4
4
  {
5
5
  "id": "ws5",
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"sensorCommand",
3
+ "type":"SensorCommand",
2
4
  "PING_status": {
3
5
  "type": "commandStatus",
4
6
  "value": "OK",
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "state":{
3
5
  "type": "Boolean",
4
6
  "value": true,
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"motion1",
3
+ "type":"Motion",
2
4
  "moving":{
3
5
  "value": true,
4
6
  "type": "boolean"
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"lamp1",
3
+ "type":"Lamp",
2
4
  "luminosity": {
3
5
  "value": "100",
4
6
  "type": "text"
@@ -13,4 +15,4 @@
13
15
  }
14
16
  }
15
17
  }
16
- }
18
+ }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "state": {
3
5
  "value": true,
4
6
  "type": "boolean",
@@ -26,4 +28,4 @@
26
28
  "type": "DateTime",
27
29
  "value": "2015-08-05T07:35:01.468Z"
28
30
  }
29
- }
31
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "id": "lightNoTimestamp1",
3
+ "type": "Light",
4
+ "state": {
5
+ "value": true,
6
+ "type": "boolean"
7
+ },
8
+ "dimming": {
9
+ "value": 87,
10
+ "type": "number"
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "id": "lightNoTimestamp1",
3
+ "type": "Light",
4
+ "state": {
5
+ "value": true,
6
+ "type": "boolean"
7
+ },
8
+ "TimeInstant": {
9
+ "value": "2015-12-14T08:06:01.468Z",
10
+ "type": "DateTime"
11
+ }
12
+ }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "state": {
3
5
  "value": true,
4
6
  "type": "boolean",
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "state": {
3
5
  "value": true,
4
6
  "type": "boolean",
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "state": {
3
5
  "value": true,
4
6
  "type": "boolean",
@@ -26,4 +28,4 @@
26
28
  "type": "DateTime",
27
29
  "value": "2015-08-05T00:35:01.468-07:00"
28
30
  }
29
- }
31
+ }
@@ -412,6 +412,36 @@ const iotAgentConfig = {
412
412
  }
413
413
  ],
414
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
+ ]
415
445
  }
416
446
  },
417
447
  service: 'smartgondor',
@@ -537,13 +567,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
537
567
  contextBrokerMock = nock('http://192.168.1.1:1026')
538
568
  .matchHeader('fiware-service', 'smartgondor')
539
569
  .matchHeader('fiware-servicepath', 'gardens')
540
- .patch(
541
- '/v2/entities/light1/attrs',
570
+ .post(
571
+ '/v2/entities?options=upsert',
542
572
  utils.readExampleFile(
543
573
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json'
544
574
  )
545
575
  )
546
- .query({ type: 'Light' })
547
576
  .reply(204);
548
577
  });
549
578
 
@@ -577,13 +606,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
577
606
  contextBrokerMock = nock('http://192.168.1.1:1026')
578
607
  .matchHeader('fiware-service', 'smartgondor')
579
608
  .matchHeader('fiware-servicepath', 'gardens')
580
- .patch(
581
- '/v2/entities/ws1/attrs',
609
+ .post(
610
+ '/v2/entities?options=upsert',
582
611
  utils.readExampleFile(
583
612
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json'
584
613
  )
585
614
  )
586
- .query({ type: 'WeatherStation' })
587
615
  .reply(204);
588
616
  });
589
617
 
@@ -618,13 +646,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
618
646
  contextBrokerMock = nock('http://192.168.1.1:1026')
619
647
  .matchHeader('fiware-service', 'smartgondor')
620
648
  .matchHeader('fiware-servicepath', 'gardens')
621
- .patch(
622
- '/v2/entities/ws1/attrs',
649
+ .post(
650
+ '/v2/entities?options=upsert',
623
651
  utils.readExampleFile(
624
652
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json'
625
653
  )
626
654
  )
627
- .query({ type: 'WeatherStation' })
628
655
  .reply(204);
629
656
  });
630
657
 
@@ -653,13 +680,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
653
680
  contextBrokerMock = nock('http://192.168.1.1:1026')
654
681
  .matchHeader('fiware-service', 'smartgondor')
655
682
  .matchHeader('fiware-servicepath', 'gardens')
656
- .patch(
657
- '/v2/entities/light1/attrs',
683
+ .post(
684
+ '/v2/entities?options=upsert',
658
685
  utils.readExampleFile(
659
686
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json'
660
687
  )
661
688
  )
662
- .query({ type: 'Light' })
663
689
  .reply(204);
664
690
  });
665
691
 
@@ -688,13 +714,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
688
714
  contextBrokerMock = nock('http://192.168.1.1:1026')
689
715
  .matchHeader('fiware-service', 'smartgondor')
690
716
  .matchHeader('fiware-servicepath', 'gardens')
691
- .patch(
692
- '/v2/entities/ws1/attrs',
717
+ .post(
718
+ '/v2/entities?options=upsert',
693
719
  utils.readExampleFile(
694
720
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json'
695
721
  )
696
722
  )
697
- .query({ type: 'WeatherStation' })
698
723
  .reply(204);
699
724
  });
700
725
 
@@ -724,13 +749,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
724
749
  contextBrokerMock = nock('http://192.168.1.1:1026')
725
750
  .matchHeader('fiware-service', 'smartgondor')
726
751
  .matchHeader('fiware-servicepath', 'gardens')
727
- .patch(
728
- '/v2/entities/light1/attrs',
752
+ .post(
753
+ '/v2/entities?options=upsert',
729
754
  utils.readExampleFile(
730
755
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json'
731
756
  )
732
757
  )
733
- .query({ type: 'Light' })
734
758
  .reply(204);
735
759
  });
736
760
 
@@ -760,13 +784,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
760
784
  contextBrokerMock = nock('http://192.168.1.1:1026')
761
785
  .matchHeader('fiware-service', 'smartgondor')
762
786
  .matchHeader('fiware-servicepath', 'gardens')
763
- .patch(
764
- '/v2/entities/ws1/attrs',
787
+ .post(
788
+ '/v2/entities?options=upsert',
765
789
  utils.readExampleFile(
766
790
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json'
767
791
  )
768
792
  )
769
- .query({ type: 'WeatherStation' })
770
793
  .reply(204);
771
794
  });
772
795
 
@@ -796,13 +819,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
796
819
  contextBrokerMock = nock('http://192.168.1.1:1026')
797
820
  .matchHeader('fiware-service', 'smartgondor')
798
821
  .matchHeader('fiware-servicepath', 'gardens')
799
- .patch(
800
- '/v2/entities/light1/attrs',
822
+ .post(
823
+ '/v2/entities?options=upsert',
801
824
  utils.readExampleFile(
802
825
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json'
803
826
  )
804
827
  )
805
- .query({ type: 'Light' })
806
828
  .reply(204);
807
829
  });
808
830
 
@@ -832,13 +854,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
832
854
  contextBrokerMock = nock('http://192.168.1.1:1026')
833
855
  .matchHeader('fiware-service', 'smartgondor')
834
856
  .matchHeader('fiware-servicepath', 'gardens')
835
- .patch(
836
- '/v2/entities/light1/attrs',
857
+ .post(
858
+ '/v2/entities?options=upsert',
837
859
  utils.readExampleFile(
838
860
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json'
839
861
  )
840
862
  )
841
- .query({ type: 'Light' })
842
863
  .reply(204);
843
864
  });
844
865
 
@@ -867,13 +888,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
867
888
  contextBrokerMock = nock('http://192.168.1.1:1026')
868
889
  .matchHeader('fiware-service', 'smartgondor')
869
890
  .matchHeader('fiware-servicepath', 'gardens')
870
- .patch(
871
- '/v2/entities/light1/attrs',
891
+ .post(
892
+ '/v2/entities?options=upsert',
872
893
  utils.readExampleFile(
873
894
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json'
874
895
  )
875
896
  )
876
- .query({ type: 'Light' })
877
897
  .reply(204);
878
898
  });
879
899
 
@@ -903,13 +923,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
903
923
  contextBrokerMock = nock('http://192.168.1.1:1026')
904
924
  .matchHeader('fiware-service', 'smartgondor')
905
925
  .matchHeader('fiware-servicepath', 'gardens')
906
- .patch(
907
- '/v2/entities/light1/attrs',
926
+ .post(
927
+ '/v2/entities?options=upsert',
908
928
  utils.readExampleFile(
909
929
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json'
910
930
  )
911
931
  )
912
- .query({ type: 'Light' })
913
932
  .reply(204);
914
933
  });
915
934
 
@@ -937,13 +956,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
937
956
  contextBrokerMock = nock('http://192.168.1.1:1026')
938
957
  .matchHeader('fiware-service', 'smartgondor')
939
958
  .matchHeader('fiware-servicepath', 'gardens')
940
- .patch(
941
- '/v2/entities/light1/attrs',
959
+ .post(
960
+ '/v2/entities?options=upsert',
942
961
  utils.readExampleFile(
943
962
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json'
944
963
  )
945
964
  )
946
- .query({ type: 'Light' })
947
965
  .reply(204);
948
966
  });
949
967
 
@@ -971,13 +989,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
971
989
  contextBrokerMock = nock('http://192.168.1.1:1026')
972
990
  .matchHeader('fiware-service', 'smartgondor')
973
991
  .matchHeader('fiware-servicepath', 'gardens')
974
- .patch(
975
- '/v2/entities/light1/attrs',
992
+ .post(
993
+ '/v2/entities?options=upsert',
976
994
  utils.readExampleFile(
977
995
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json'
978
996
  )
979
997
  )
980
- .query({ type: 'Light' })
981
998
  .reply(204);
982
999
  });
983
1000
 
@@ -1010,13 +1027,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
1010
1027
  contextBrokerMock = nock('http://192.168.1.1:1026')
1011
1028
  .matchHeader('fiware-service', 'smartgondor')
1012
1029
  .matchHeader('fiware-servicepath', 'gardens')
1013
- .patch(
1014
- '/v2/entities/light1/attrs',
1030
+ .post(
1031
+ '/v2/entities?options=upsert',
1015
1032
  utils.readExampleFile(
1016
1033
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json'
1017
1034
  )
1018
1035
  )
1019
- .query({ type: 'Light' })
1020
1036
  .reply(204);
1021
1037
  });
1022
1038
 
@@ -1044,13 +1060,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
1044
1060
  contextBrokerMock = nock('http://192.168.1.1:1026')
1045
1061
  .matchHeader('fiware-service', 'smartgondor')
1046
1062
  .matchHeader('fiware-servicepath', 'gardens')
1047
- .patch(
1048
- '/v2/entities/ws1/attrs',
1063
+ .post(
1064
+ '/v2/entities?options=upsert',
1049
1065
  utils.readExampleFile(
1050
1066
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json'
1051
1067
  )
1052
1068
  )
1053
- .query({ type: 'WeatherStation' })
1054
1069
  .reply(204);
1055
1070
  });
1056
1071
 
@@ -1077,13 +1092,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
1077
1092
  contextBrokerMock = nock('http://192.168.1.1:1026')
1078
1093
  .matchHeader('fiware-service', 'smartgondor')
1079
1094
  .matchHeader('fiware-servicepath', 'gardens')
1080
- .patch(
1081
- '/v2/entities/ws1/attrs',
1095
+ .post(
1096
+ '/v2/entities?options=upsert',
1082
1097
  utils.readExampleFile(
1083
1098
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json'
1084
1099
  )
1085
1100
  )
1086
- .query({ type: 'WeatherStation' })
1087
1101
  .reply(204);
1088
1102
  });
1089
1103
 
@@ -1122,13 +1136,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
1122
1136
  contextBrokerMock = nock('http://192.168.1.1:1026')
1123
1137
  .matchHeader('fiware-service', 'smartgondor')
1124
1138
  .matchHeader('fiware-servicepath', 'gardens')
1125
- .patch(
1126
- '/v2/entities/gps1/attrs',
1139
+ .post(
1140
+ '/v2/entities?options=upsert',
1127
1141
  utils.readExampleFile(
1128
1142
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json'
1129
1143
  )
1130
1144
  )
1131
- .query({ type: 'GPS' })
1132
1145
  .reply(204);
1133
1146
  });
1134
1147
 
@@ -1167,13 +1180,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
1167
1180
  contextBrokerMock = nock('http://192.168.1.1:1026')
1168
1181
  .matchHeader('fiware-service', 'smartgondor')
1169
1182
  .matchHeader('fiware-servicepath', 'gardens')
1170
- .patch(
1171
- '/v2/entities/gps1/attrs',
1183
+ .post(
1184
+ '/v2/entities?options=upsert',
1172
1185
  utils.readExampleFile(
1173
1186
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json'
1174
1187
  )
1175
1188
  )
1176
- .query({ type: 'GPS' })
1177
1189
  .reply(204);
1178
1190
  });
1179
1191
 
@@ -1217,13 +1229,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
1217
1229
  contextBrokerMock = nock('http://192.168.1.1:1026')
1218
1230
  .matchHeader('fiware-service', 'smartgondor')
1219
1231
  .matchHeader('fiware-servicepath', 'gardens')
1220
- .patch(
1221
- '/v2/entities/gps1/attrs',
1232
+ .post(
1233
+ '/v2/entities?options=upsert',
1222
1234
  utils.readExampleFile(
1223
1235
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json'
1224
1236
  )
1225
1237
  )
1226
- .query({ type: 'GPS' })
1227
1238
  .reply(204);
1228
1239
  });
1229
1240
 
@@ -1262,13 +1273,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
1262
1273
  contextBrokerMock = nock('http://192.168.1.1:1026')
1263
1274
  .matchHeader('fiware-service', 'smartgondor')
1264
1275
  .matchHeader('fiware-servicepath', 'gardens')
1265
- .patch(
1266
- '/v2/entities/gps1/attrs',
1276
+ .post(
1277
+ '/v2/entities?options=upsert',
1267
1278
  utils.readExampleFile(
1268
1279
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json'
1269
1280
  )
1270
1281
  )
1271
- .query({ type: 'GPS' })
1272
1282
  .reply(204);
1273
1283
  });
1274
1284
 
@@ -1307,13 +1317,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
1307
1317
  contextBrokerMock = nock('http://192.168.1.1:1026')
1308
1318
  .matchHeader('fiware-service', 'smartgondor')
1309
1319
  .matchHeader('fiware-servicepath', 'gardens')
1310
- .patch(
1311
- '/v2/entities/gps1/attrs',
1320
+ .post(
1321
+ '/v2/entities?options=upsert',
1312
1322
  utils.readExampleFile(
1313
1323
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json'
1314
1324
  )
1315
1325
  )
1316
- .query({ type: 'GPS' })
1317
1326
  .reply(204);
1318
1327
  });
1319
1328
 
@@ -1357,13 +1366,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
1357
1366
  contextBrokerMock = nock('http://192.168.1.1:1026')
1358
1367
  .matchHeader('fiware-service', 'smartgondor')
1359
1368
  .matchHeader('fiware-servicepath', 'gardens')
1360
- .patch(
1361
- '/v2/entities/gps1/attrs',
1369
+ .post(
1370
+ '/v2/entities?options=upsert',
1362
1371
  utils.readExampleFile(
1363
1372
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json'
1364
1373
  )
1365
1374
  )
1366
- .query({ type: 'GPS' })
1367
1375
  .reply(204);
1368
1376
  });
1369
1377
 
@@ -1397,13 +1405,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
1397
1405
  contextBrokerMock = nock('http://192.168.1.1:1026')
1398
1406
  .matchHeader('fiware-service', 'smartgondor')
1399
1407
  .matchHeader('fiware-servicepath', 'gardens')
1400
- .patch(
1401
- '/v2/entities/gps1/attrs',
1408
+ .post(
1409
+ '/v2/entities?options=upsert',
1402
1410
  utils.readExampleFile(
1403
1411
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json'
1404
1412
  )
1405
1413
  )
1406
- .query({ type: 'GPS' })
1407
1414
  .reply(204);
1408
1415
  });
1409
1416
 
@@ -1432,13 +1439,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
1432
1439
  contextBrokerMock = nock('http://192.168.1.1:1026')
1433
1440
  .matchHeader('fiware-service', 'smartgondor')
1434
1441
  .matchHeader('fiware-servicepath', 'gardens')
1435
- .patch(
1436
- '/v2/entities/gps1/attrs',
1442
+ .post(
1443
+ '/v2/entities?options=upsert',
1437
1444
  utils.readExampleFile(
1438
1445
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json'
1439
1446
  )
1440
1447
  )
1441
- .query({ type: 'GPS' })
1442
1448
  .reply(204);
1443
1449
  });
1444
1450
 
@@ -1487,6 +1493,59 @@ describe('Java expression language (JEXL) based transformations plugin', functio
1487
1493
  });
1488
1494
  });
1489
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
+ });
1490
1549
  });
1491
1550
 
1492
1551
  describe('Java expression language (JEXL) based transformations plugin - Timestamps', function () {
@@ -1535,13 +1594,12 @@ describe('Java expression language (JEXL) based transformations plugin - Timesta
1535
1594
  contextBrokerMock = nock('http://192.168.1.1:1026')
1536
1595
  .matchHeader('fiware-service', 'smartgondor')
1537
1596
  .matchHeader('fiware-servicepath', 'gardens')
1538
- .patch(
1539
- '/v2/entities/gps1/attrs',
1597
+ .post(
1598
+ '/v2/entities?options=upsert',
1540
1599
  utils.readExampleFile(
1541
1600
  './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json'
1542
1601
  )
1543
1602
  )
1544
- .query({ type: 'GPS' })
1545
1603
  .reply(204);
1546
1604
  });
1547
1605