iotagent-node-lib 2.26.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/.github/workflows/ci.yml +1 -0
  2. package/CHANGES_NEXT_RELEASE +2 -0
  3. package/docker-compose-dev.yml +1 -1
  4. package/lib/fiware-iotagent-lib.js +0 -5
  5. package/lib/plugins/compressTimestamp.js +2 -7
  6. package/lib/plugins/expressionParser.js +0 -47
  7. package/lib/plugins/expressionPlugin.js +6 -78
  8. package/lib/plugins/jexlParser.js +0 -36
  9. package/lib/plugins/pluginUtils.js +0 -119
  10. package/lib/services/ngsi/entities-NGSI-LD.js +586 -199
  11. package/lib/services/ngsi/entities-NGSI-v2.js +607 -297
  12. package/lib/services/ngsi/ngsiUtils.js +15 -22
  13. package/package.json +2 -2
  14. package/test/unit/general/config-multi-core-test.js +2 -1
  15. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +2 -1
  16. package/test/unit/general/deviceService-test.js +2 -1
  17. package/test/unit/general/loglevel-api_test.js +2 -3
  18. package/test/unit/general/startup-test.js +2 -1
  19. package/test/unit/general/statistics-persistence_test.js +1 -0
  20. package/test/unit/general/statistics-service_test.js +1 -0
  21. package/test/unit/lazyAndCommands/commandRegistry_test.js +1 -0
  22. package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +1 -0
  23. package/test/unit/mongodb/mongodb-connectionoptions-test.js +1 -0
  24. package/test/unit/mongodb/mongodb-group-registry-test.js +1 -0
  25. package/test/unit/mongodb/mongodb-registry-test.js +2 -1
  26. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin1.json +0 -5
  27. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast10.json +1 -1
  28. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast8.json +1 -1
  29. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast9.json +1 -1
  30. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +16 -15
  31. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4.json +8 -8
  32. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4a.json +34 -34
  33. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin5.json +8 -8
  34. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin6.json +0 -20
  35. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin7.json +0 -5
  36. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin8.json +10 -10
  37. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +8 -7
  38. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +5 -4
  39. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
  40. package/test/unit/ngsi-ld/examples/contextRequests/updateContextProcessTimestamp.json +4 -4
  41. package/test/unit/ngsi-ld/examples/contextRequests/updateContextTimestampOverride.json +4 -3
  42. package/test/unit/ngsi-ld/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +4 -3
  43. package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +4 -6
  44. package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +1 -7
  45. package/test/unit/ngsi-ld/general/config-jsonld-contexts-test.js +2 -1
  46. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +2 -1
  47. package/test/unit/ngsi-ld/general/deviceService-test.js +2 -1
  48. package/test/unit/ngsi-ld/general/https-support-test.js +2 -1
  49. package/test/unit/ngsi-ld/general/iotam-autoregistration-test.js +2 -1
  50. package/test/unit/ngsi-ld/general/startup-test.js +3 -2
  51. package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +2 -1
  52. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +5 -7
  53. package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +8 -6
  54. package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +18 -22
  55. package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +2 -1
  56. package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +2 -1
  57. package/test/unit/ngsi-ld/ngsiService/autocast-test.js +17 -4
  58. package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +2 -1
  59. package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +32 -34
  60. package/test/unit/ngsi-ld/ngsiService/staticAttributes-test.js +2 -1
  61. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +2 -1
  62. package/test/unit/ngsi-ld/ngsiService/unsupported-endpoints-test.js +11 -15
  63. package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +2 -3
  64. package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +2 -1
  65. package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +2 -32
  66. package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +20 -19
  67. package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +21 -7
  68. package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +1 -0
  69. package/test/unit/ngsi-ld/provisioning/device-registration_test.js +2 -1
  70. package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +15 -12
  71. package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +1 -0
  72. package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +1 -0
  73. package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +1 -0
  74. package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +1 -0
  75. package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +1 -0
  76. package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +13 -7
  77. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json +2 -2
  78. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +6 -0
  79. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +5 -1
  80. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +4 -4
  81. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +0 -16
  82. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +0 -4
  83. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +8 -8
  84. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +42 -42
  85. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +7 -7
  86. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +0 -5
  87. package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +6 -6
  88. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +7 -1
  89. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +7 -1
  90. package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +2 -4
  91. package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +4 -8
  92. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +5 -9
  93. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +2 -1
  94. package/test/unit/ngsiv2/general/deviceService-test.js +2 -1
  95. package/test/unit/ngsiv2/general/https-support-test.js +2 -1
  96. package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +2 -1
  97. package/test/unit/ngsiv2/general/startup-test.js +2 -1
  98. package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +2 -1
  99. package/test/unit/ngsiv2/lazyAndCommands/command-test.js +2 -1
  100. package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +8 -6
  101. package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +2 -1
  102. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +3 -2
  103. package/test/unit/ngsiv2/ngsiService/autocast-test.js +2 -1
  104. package/test/unit/ngsiv2/ngsiService/queryDeviceInformationInCb-test.js +2 -1
  105. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +2 -1
  106. package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +2 -1
  107. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +2 -3
  108. package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +2 -5
  109. package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +2 -33
  110. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +7 -16
  111. package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +3 -2
  112. package/test/unit/ngsiv2/provisioning/device-group-api-test.js +1 -0
  113. package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -0
  114. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +1 -0
  115. package/test/unit/ngsiv2/provisioning/device-registration_test.js +2 -1
  116. package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +15 -12
  117. package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +1 -0
  118. package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +1 -0
  119. package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +1 -0
  120. package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +1 -0
  121. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +1 -0
  122. package/test/unit/plugins/capture-configuration-inPlugins_test.js +2 -1
  123. package/test/unit/plugins/capture-provision-inPlugins_test.js +2 -1
  124. package/lib/plugins/addEvent.js +0 -32
  125. package/lib/plugins/attributeAlias.js +0 -107
  126. package/lib/plugins/multiEntity.js +0 -255
  127. package/lib/plugins/timestampProcessPlugin.js +0 -95
  128. package/test/unit/ngsi-ld/plugins/event-plugin_test.js +0 -116
  129. package/test/unit/ngsiv2/plugins/event-plugin_test.js +0 -118
  130. package/test/unit/ngsiv2/plugins/translation-inPlugins_test.js +0 -262
@@ -37,7 +37,8 @@ const iotAgentConfig = {
37
37
  jsonLdContext: 'http://context.json-ld'
38
38
  },
39
39
  server: {
40
- port: 4041
40
+ port: 4041,
41
+ host: 'localhost'
41
42
  },
42
43
  types: {
43
44
  Light: {
@@ -123,8 +124,6 @@ describe('NGSI-LD - Timestamp compression plugin', function () {
123
124
  logger.setLevel('FATAL');
124
125
  iotAgentLib.activate(iotAgentConfig, function () {
125
126
  iotAgentLib.clearAll(function () {
126
- iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.compressTimestamp.updateNgsi2);
127
- iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.compressTimestamp.queryNgsi2);
128
127
  done();
129
128
  });
130
129
  });
@@ -214,33 +213,4 @@ describe('NGSI-LD - Timestamp compression plugin', function () {
214
213
  });
215
214
  });
216
215
  });
217
-
218
- describe('When a query comes for a timestamp through the plugin', function () {
219
- const values = ['state', 'TheTargetValue'];
220
-
221
- beforeEach(function () {
222
- nock.cleanAll();
223
-
224
- contextBrokerMock = nock('http://192.168.1.1:1026')
225
- .matchHeader('fiware-service', 'smartgondor')
226
- .get('/ngsi-ld/v1/entities/urn:ngsi-ld:Light:light1?attrs=state,TheTargetValue')
227
- .reply(
228
- 200,
229
- utils.readExampleFile(
230
- './test/unit/ngsi-ld/examples/contextResponses/queryContextCompressTimestamp1Success.json'
231
- )
232
- );
233
- });
234
-
235
- it('should return an entity with all its timestamps without separators (basic format)', function (done) {
236
- iotAgentLib.query('light1', 'Light', '', values, function (error, response) {
237
- should.not.exist(error);
238
- should.exist(response);
239
- should.exist(response.TheTargetValue);
240
- should.exist(response.TheTargetValue.value);
241
- response.TheTargetValue.value.should.equal('20071103T131805');
242
- done();
243
- });
244
- });
245
- });
246
216
  });
@@ -41,7 +41,8 @@ const iotAgentConfig = {
41
41
  jsonLdContext: 'http://context.json-ld'
42
42
  },
43
43
  server: {
44
- port: 4041
44
+ port: 4041,
45
+ host: 'localhost'
45
46
  },
46
47
  types: {
47
48
  WeatherStation: {
@@ -246,9 +247,6 @@ describe('NGSI-LD - Multi-entity plugin', function () {
246
247
  logger.setLevel('FATAL');
247
248
  iotAgentLib.activate(iotAgentConfig, function () {
248
249
  iotAgentLib.clearAll(function () {
249
- iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
250
- iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
251
- iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.multiEntity.update);
252
250
  done();
253
251
  });
254
252
  });
@@ -614,15 +612,9 @@ describe('NGSI-LD - Multi-entity plugin', function () {
614
612
 
615
613
  describe('NGSI-LD - Multi-entity plugin is executed before timestamp process plugin', function () {
616
614
  beforeEach(function (done) {
617
- logger.setLevel('FATAL');
618
-
619
615
  iotAgentConfig.timestamp = true;
620
616
  iotAgentLib.activate(iotAgentConfig, function () {
621
617
  iotAgentLib.clearAll(function () {
622
- iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
623
- iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
624
- iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.multiEntity.update);
625
- iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.timestampProcess.update);
626
618
  done();
627
619
  });
628
620
  });
@@ -731,13 +723,26 @@ describe('NGSI-LD - Multi-entity plugin is executed before timestamp process plu
731
723
  it('should propagate user provider timestamp to mapped entities', function (done) {
732
724
  contextBrokerMock = nock('http://192.168.1.1:1026')
733
725
  .matchHeader('fiware-service', 'smartgondor')
734
- .post(
735
- '/ngsi-ld/v1/entityOperations/upsert/?options=update',
736
- utils.readExampleFile(
726
+ .post('/ngsi-ld/v1/entityOperations/upsert/?options=update', function (body) {
727
+ const expectedBody = utils.readExampleFile(
737
728
  './test/unit/ngsi-ld/examples' +
738
729
  '/contextRequests/updateContextMultientityTimestampPlugin3.json'
739
- )
740
- )
730
+ );
731
+
732
+ // Note that TimeInstant fields are not included in the json used by this mock as they are dynamic
733
+ // fields. The following code just checks that TimeInstant fields are present.
734
+ if (!body[1].humidity.observedAt) {
735
+ return false;
736
+ }
737
+
738
+ const timeInstantAtt = body[1].humidity.observedAt;
739
+ if (moment(timeInstantAtt, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid) {
740
+ delete body[1].humidity.observedAt;
741
+ delete expectedBody[1].humidity.observedAt;
742
+ return JSON.stringify(body) === JSON.stringify(expectedBody);
743
+ }
744
+ return false;
745
+ })
741
746
  .reply(204);
742
747
 
743
748
  const tsValue = [
@@ -772,10 +777,6 @@ describe('NGSI-LD - Multi-entity plugin is executed for a command update for a r
772
777
  timekeeper.freeze(time);
773
778
  iotAgentLib.activate(iotAgentConfig, function () {
774
779
  iotAgentLib.clearAll(function () {
775
- iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
776
- iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
777
- iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.multiEntity.update);
778
- iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.timestampProcess.update);
779
780
  done();
780
781
  });
781
782
  });
@@ -28,6 +28,7 @@ const utils = require('../../../tools/utils');
28
28
  const should = require('should');
29
29
  const logger = require('logops');
30
30
  const nock = require('nock');
31
+ const moment = require('moment');
31
32
  let contextBrokerMock;
32
33
  const iotAgentConfig = {
33
34
  contextBroker: {
@@ -37,7 +38,8 @@ const iotAgentConfig = {
37
38
  jsonLdContext: 'http://context.json-ld'
38
39
  },
39
40
  server: {
40
- port: 4041
41
+ port: 4041,
42
+ host: 'localhost'
41
43
  },
42
44
  types: {
43
45
  Light: {
@@ -68,7 +70,6 @@ describe('NGSI-LD - Timestamp processing plugin', function () {
68
70
 
69
71
  iotAgentLib.activate(iotAgentConfig, function () {
70
72
  iotAgentLib.clearAll(function () {
71
- iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.timestampProcess.update);
72
73
  done();
73
74
  });
74
75
  });
@@ -98,12 +99,25 @@ describe('NGSI-LD - Timestamp processing plugin', function () {
98
99
 
99
100
  contextBrokerMock = nock('http://192.168.1.1:1026')
100
101
  .matchHeader('fiware-service', 'smartgondor')
101
- .post(
102
- '/ngsi-ld/v1/entityOperations/upsert/?options=update',
103
- utils.readExampleFile(
102
+ .post('/ngsi-ld/v1/entityOperations/upsert/?options=update', function (body) {
103
+ const expectedBody = utils.readExampleFile(
104
104
  './test/unit/ngsi-ld/examples/contextRequests/updateContextProcessTimestamp.json'
105
- )
106
- )
105
+ );
106
+
107
+ // Note that TimeInstant fields are not included in the json used by this mock as they are dynamic
108
+ // fields. The following code just checks that TimeInstant fields are present.
109
+ if (!body[0].state.observedAt) {
110
+ return false;
111
+ }
112
+
113
+ const timeInstantAtt = body[0].state.observedAt;
114
+ if (moment(timeInstantAtt, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid) {
115
+ delete body[0].state.observedAt;
116
+ delete expectedBody[0].state.observedAt;
117
+ return JSON.stringify(body) === JSON.stringify(expectedBody);
118
+ }
119
+ return false;
120
+ })
107
121
  .reply(204);
108
122
  });
109
123
 
@@ -42,6 +42,7 @@ const iotAgentConfig = {
42
42
  },
43
43
  server: {
44
44
  port: 4041,
45
+ host: 'localhost',
45
46
  baseRoot: '/'
46
47
  },
47
48
  types: {},
@@ -41,7 +41,8 @@ const iotAgentConfig = {
41
41
  jsonLdContext: 'http://context.json-ld'
42
42
  },
43
43
  server: {
44
- port: 4041
44
+ port: 4041,
45
+ host: 'localhost'
45
46
  },
46
47
  types: {
47
48
  Light: {
@@ -40,7 +40,8 @@ const iotAgentConfig = {
40
40
  jsonLdContext: 'http://context.json-ld'
41
41
  },
42
42
  server: {
43
- port: 4041
43
+ port: 4041,
44
+ host: 'localhost'
44
45
  },
45
46
  types: {
46
47
  Light: {
@@ -244,17 +245,19 @@ describe('NGSI-LD - IoT Agent Device Update Registration', function () {
244
245
  });
245
246
  it('should store the new values in the registry', function (done) {
246
247
  iotAgentLib.updateRegister(deviceCommandUpdated, false, function (error, data) {
247
- iotAgentLib.getDevice(deviceCommandUpdated.id, 'smartgondor', 'gardens', function (
248
- error,
249
- deviceResult
250
- ) {
251
- should.not.exist(error);
252
- should.exist(deviceResult);
253
- deviceResult.internalId.should.equal(deviceUpdated.internalId);
254
- deviceResult.commands[0].name.should.equal('move');
255
- deviceResult.active[0].name.should.equal('temperature');
256
- done();
257
- });
248
+ iotAgentLib.getDevice(
249
+ deviceCommandUpdated.id,
250
+ 'smartgondor',
251
+ 'gardens',
252
+ function (error, deviceResult) {
253
+ should.not.exist(error);
254
+ should.exist(deviceResult);
255
+ deviceResult.internalId.should.equal(deviceUpdated.internalId);
256
+ deviceResult.commands[0].name.should.equal('move');
257
+ deviceResult.active[0].name.should.equal('temperature');
258
+ done();
259
+ }
260
+ );
258
261
  });
259
262
  });
260
263
  });
@@ -43,6 +43,7 @@ const iotAgentConfig = {
43
43
  },
44
44
  server: {
45
45
  port: 4041,
46
+ host: 'localhost',
46
47
  baseRoot: '/'
47
48
  },
48
49
  types: {},
@@ -43,6 +43,7 @@ const iotAgentConfig = {
43
43
  },
44
44
  server: {
45
45
  port: 4041,
46
+ host: 'localhost',
46
47
  baseRoot: '/'
47
48
  },
48
49
  types: {},
@@ -43,6 +43,7 @@ const iotAgentConfig = {
43
43
  },
44
44
  server: {
45
45
  port: 4041,
46
+ host: 'localhost',
46
47
  baseRoot: '/'
47
48
  },
48
49
  types: {},
@@ -43,6 +43,7 @@ const iotAgentConfig = {
43
43
  },
44
44
  server: {
45
45
  port: 4041,
46
+ host: 'localhost',
46
47
  baseRoot: '/'
47
48
  },
48
49
  types: {},
@@ -43,6 +43,7 @@ const iotAgentConfig = {
43
43
  },
44
44
  server: {
45
45
  port: 4041,
46
+ host: 'localhost',
46
47
  baseRoot: '/'
47
48
  },
48
49
  types: {},
@@ -40,6 +40,7 @@ const iotAgentConfig = {
40
40
  server: {
41
41
  name: 'testAgent',
42
42
  port: 4041,
43
+ host: 'localhost',
43
44
  baseRoot: '/'
44
45
  },
45
46
  types: {},
@@ -268,13 +269,18 @@ describe('Mixed Mode: ngsiVersion test', function () {
268
269
  });
269
270
  });
270
271
  it('should operate using NGSI-v2', function (done) {
271
- iotAgentLib.update('light2', 'Device', 'v2-test', values, { ngsiVersion: 'v2', type: 'Device' }, function (
272
- error
273
- ) {
274
- should.not.exist(error);
275
- contextBrokerMock.done();
276
- done();
277
- });
272
+ iotAgentLib.update(
273
+ 'light2',
274
+ 'Device',
275
+ 'v2-test',
276
+ values,
277
+ { ngsiVersion: 'v2', type: 'Device' },
278
+ function (error) {
279
+ should.not.exist(error);
280
+ contextBrokerMock.done();
281
+ done();
282
+ }
283
+ );
278
284
  });
279
285
  });
280
286
  });
@@ -9,10 +9,10 @@
9
9
  },
10
10
  "pressure": {
11
11
  "type":"Number",
12
- "value":20071103,
12
+ "value":"20071103T131805",
13
13
  "metadata": {
14
14
  "type":"Property",
15
15
  "value":"Hgmm"
16
16
  }
17
17
  }
18
- }
18
+ }
@@ -7,6 +7,12 @@
7
7
  52
8
8
  ],
9
9
  "type": "Point"
10
+ },
11
+ "metadata": {
12
+ "TimeInstant": {
13
+ "type": "DateTime",
14
+ "value": "1970-01-01T00:00:00.001Z"
15
+ }
10
16
  }
11
17
  },
12
18
  "TimeInstant": {
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "actionType": "update",
3
- "entities": [
3
+ "entities": [
4
+ {
5
+ "id": "ws11",
6
+ "type": "WrongStation"
7
+ },
4
8
  {
5
9
  "id": "WrongStation1",
6
10
  "type": "WrongStation",
@@ -5,19 +5,19 @@
5
5
  "type": "WeatherStation"
6
6
  },
7
7
  {
8
- "id": "Higro2002",
8
+ "id": "Higro2000",
9
9
  "type": "Higrometer",
10
10
  "pressure": {
11
11
  "type": "Hgmm",
12
- "value": "17"
12
+ "value": "16"
13
13
  }
14
14
  },
15
15
  {
16
- "id": "Higro2000",
16
+ "id": "Higro2002",
17
17
  "type": "Higrometer",
18
18
  "pressure": {
19
19
  "type": "Hgmm",
20
- "value": "16"
20
+ "value": "17"
21
21
  }
22
22
  }
23
23
  ]
@@ -12,22 +12,6 @@
12
12
  },
13
13
  "type": "WM",
14
14
  "id": "SO1"
15
- },
16
- {
17
- "type": "WM",
18
- "id": "SO2"
19
- },
20
- {
21
- "type": "WM",
22
- "id": "SO3"
23
- },
24
- {
25
- "type": "WM",
26
- "id": "SO4"
27
- },
28
- {
29
- "type": "WM",
30
- "id": "SO5"
31
15
  }
32
16
  ]
33
17
  }
@@ -29,10 +29,6 @@
29
29
  "type": "WM",
30
30
  "id": "SO3"
31
31
  },
32
- {
33
- "type": "WM",
34
- "id": "SO4"
35
- },
36
32
  {
37
33
  "vol": {
38
34
  "type": "number",
@@ -5,6 +5,14 @@
5
5
  "id": "ws7",
6
6
  "type": "WeatherStation"
7
7
  },
8
+ {
9
+ "pressure": {
10
+ "type": "Hgmm",
11
+ "value": "16"
12
+ },
13
+ "type": "Higrometer",
14
+ "id": "Higro2000"
15
+ },
8
16
  {
9
17
  "pressure": {
10
18
  "type": "Hgmm",
@@ -18,14 +26,6 @@
18
26
  },
19
27
  "type": "Higrometer",
20
28
  "id": "Higro2002"
21
- },
22
- {
23
- "pressure": {
24
- "type": "Hgmm",
25
- "value": "16"
26
- },
27
- "type": "Higrometer",
28
- "id": "Higro2000"
29
29
  }
30
30
  ]
31
31
  }
@@ -1,45 +1,45 @@
1
1
  {
2
- "actionType": "update",
3
- "entities": [
4
- {
5
- "pressure": {
6
- "type": "Hgmm",
7
- "value": "52",
8
- "metadata": {
9
- "TimeInstant": {
10
- "type": "DateTime",
11
- "value": "2016-05-30T16:25:22.304Z"
12
- }
2
+ "entities": [
3
+ {
4
+ "id": "ws4",
5
+ "type": "WeatherStation",
6
+ "TimeInstant": {
7
+ "type": "DateTime",
8
+ "value": "2016-05-30T16:25:22.304Z"
9
+ },
10
+ "pressure": {
11
+ "value": "52",
12
+ "type": "Hgmm",
13
+ "metadata": {
14
+ "TimeInstant": {
15
+ "type": "DateTime",
16
+ "value": "2016-05-30T16:25:22.304Z"
17
+ }
18
+ }
19
+ }
20
+ },
21
+ {
22
+ "id": "Higro2000",
23
+ "type": "Higrometer",
24
+ "humidity": {
25
+ "value": "12",
26
+ "type": "Percentage",
27
+ "metadata": {
28
+ "unitCode": {
29
+ "type": "Text",
30
+ "value": "Hgmm"
31
+ },
32
+ "TimeInstant": {
33
+ "type": "DateTime",
34
+ "value": "2016-05-30T16:25:22.304Z"
35
+ }
36
+ }
37
+ },
38
+ "TimeInstant": {
39
+ "type": "DateTime",
40
+ "value": "2016-05-30T16:25:22.304Z"
41
+ }
13
42
  }
14
- },
15
- "TimeInstant": {
16
- "type": "DateTime",
17
- "value": "2016-05-30T16:25:22.304Z"
18
- },
19
- "id": "ws4",
20
- "type": "WeatherStation"
21
- },
22
- {
23
- "humidity": {
24
- "type": "Percentage",
25
- "value": "12",
26
- "metadata": {
27
- "unitCode": {
28
- "type": "Text",
29
- "value": "Hgmm"
30
- },
31
- "TimeInstant": {
32
- "type": "DateTime",
33
- "value": "2016-05-30T16:25:22.304Z"
34
- }
35
- }
36
- },
37
- "TimeInstant": {
38
- "type": "DateTime",
39
- "value": "2016-05-30T16:25:22.304Z"
40
- },
41
- "id": "Higro2000",
42
- "type": "Higrometer"
43
- }
44
- ]
43
+ ],
44
+ "actionType": "update"
45
45
  }
@@ -1,14 +1,15 @@
1
1
  {
2
- "actionType": "update",
3
2
  "entities": [
4
3
  {
5
4
  "id": "ws4",
6
5
  "type": "WeatherStation"
7
6
  },
8
7
  {
9
- "humidity": {
10
- "type": "Percentage",
8
+ "id": "Higro2000",
9
+ "type": "Higrometer",
10
+ "humidity": {
11
11
  "value": "12",
12
+ "type": "Percentage",
12
13
  "metadata": {
13
14
  "TimeInstant": {
14
15
  "type": "DateTime",
@@ -20,9 +21,8 @@
20
21
  "TimeInstant": {
21
22
  "type": "DateTime",
22
23
  "value": "2018-06-13T13:28:34.611Z"
23
- },
24
- "id": "Higro2000",
25
- "type": "Higrometer"
24
+ }
26
25
  }
27
- ]
26
+ ],
27
+ "actionType": "update"
28
28
  }
@@ -1,8 +1,4 @@
1
1
  {
2
- "actionType": "update",
3
- "entities": [{
4
- "id": "sensorCommand",
5
- "type": "SensorCommand",
6
2
  "PING_status": {
7
3
  "type": "commandStatus",
8
4
  "value": "OK",
@@ -27,5 +23,4 @@
27
23
  "type": "DateTime",
28
24
  "value": "2015-08-05T07:35:01.468Z"
29
25
  }
30
- }]
31
26
  }
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "state":{
3
3
  "type": "Boolean",
4
- "value": true,
5
- "metadata": {
6
- "TimeInstant":{
7
- "type": "DateTime",
8
- "value": "2016-05-30T16:25:22.304Z"
4
+ "value": true,
5
+ "metadata": {
6
+ "TimeInstant": {
7
+ "type": "DateTime",
8
+ "value": "2016-05-30T16:25:22.304Z"
9
+ }
9
10
  }
10
- }
11
11
  },
12
12
  "TimeInstant":
13
13
  {
@@ -1,7 +1,13 @@
1
1
  {
2
2
  "state": {
3
3
  "value": true,
4
- "type": "boolean"
4
+ "type": "boolean",
5
+ "metadata": {
6
+ "TimeInstant":{
7
+ "type": "DateTime",
8
+ "value": "2015-12-14T08:06:01.468Z"
9
+ }
10
+ }
5
11
  },
6
12
  "TimeInstant":{
7
13
  "type": "DateTime",
@@ -1,7 +1,13 @@
1
1
  {
2
2
  "state": {
3
3
  "value": true,
4
- "type": "boolean"
4
+ "type": "boolean",
5
+ "metadata": {
6
+ "TimeInstant":{
7
+ "type": "DateTime",
8
+ "value": "2022-10-22T22:22:22Z"
9
+ }
10
+ }
5
11
  },
6
12
  "TimeInstant":{
7
13
  "type": "DateTime",