iotagent-node-lib 3.0.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/.github/workflows/ci.yml +1 -0
  2. package/config.js +5 -5
  3. package/doc/api.md +1540 -298
  4. package/doc/deprecated.md +3 -1
  5. package/doc/development.md +120 -0
  6. package/doc/installationguide.md +3 -6
  7. package/docker-compose-dev.yml +1 -1
  8. package/lib/commonConfig.js +7 -10
  9. package/lib/fiware-iotagent-lib.js +0 -10
  10. package/lib/jexlTranformsMap.js +2 -1
  11. package/lib/plugins/bidirectionalData.js +8 -26
  12. package/lib/plugins/expressionPlugin.js +8 -40
  13. package/lib/plugins/jexlParser.js +28 -0
  14. package/lib/services/commands/commandService.js +1 -1
  15. package/lib/services/devices/deviceService.js +2 -1
  16. package/lib/services/ngsi/entities-NGSI-LD.js +15 -73
  17. package/lib/services/ngsi/entities-NGSI-v2.js +149 -124
  18. package/lib/services/northBound/deviceProvisioningServer.js +17 -14
  19. package/lib/templates/createDevice.json +5 -2
  20. package/lib/templates/createDeviceLax.json +7 -5
  21. package/lib/templates/updateDevice.json +5 -2
  22. package/lib/templates/updateDeviceLax.json +3 -5
  23. package/package.json +2 -2
  24. package/test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json +5 -5
  25. package/test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice4.json +1 -0
  26. package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +4 -4
  27. package/test/unit/general/config-multi-core-test.js +2 -1
  28. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +2 -1
  29. package/test/unit/general/deviceService-test.js +2 -1
  30. package/test/unit/general/loglevel-api_test.js +2 -1
  31. package/test/unit/general/startup-test.js +2 -1
  32. package/test/unit/general/statistics-persistence_test.js +1 -0
  33. package/test/unit/general/statistics-service_test.js +1 -0
  34. package/test/unit/lazyAndCommands/commandRegistry_test.js +1 -0
  35. package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +1 -0
  36. package/test/unit/mongodb/mongodb-connectionoptions-test.js +1 -0
  37. package/test/unit/mongodb/mongodb-group-registry-test.js +1 -0
  38. package/test/unit/mongodb/mongodb-registry-test.js +2 -1
  39. package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +0 -2
  40. package/test/unit/ngsi-ld/general/config-jsonld-contexts-test.js +2 -1
  41. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +2 -1
  42. package/test/unit/ngsi-ld/general/deviceService-test.js +2 -1
  43. package/test/unit/ngsi-ld/general/https-support-test.js +2 -1
  44. package/test/unit/ngsi-ld/general/iotam-autoregistration-test.js +2 -1
  45. package/test/unit/ngsi-ld/general/startup-test.js +3 -2
  46. package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +2 -1
  47. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +5 -7
  48. package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +8 -6
  49. package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +18 -22
  50. package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +2 -1
  51. package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +2 -1
  52. package/test/unit/ngsi-ld/ngsiService/autocast-test.js +2 -1
  53. package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +2 -1
  54. package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +32 -34
  55. package/test/unit/ngsi-ld/ngsiService/staticAttributes-test.js +2 -1
  56. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +2 -1
  57. package/test/unit/ngsi-ld/ngsiService/unsupported-endpoints-test.js +11 -15
  58. package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +2 -1
  59. package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +10 -9
  60. package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +2 -1
  61. package/test/unit/ngsi-ld/plugins/custom-plugin_test.js +152 -0
  62. package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +3 -2
  63. package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +2 -1
  64. package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +1 -0
  65. package/test/unit/ngsi-ld/provisioning/device-registration_test.js +2 -1
  66. package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +15 -12
  67. package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +1 -0
  68. package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +1 -0
  69. package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +1 -0
  70. package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +1 -0
  71. package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +1 -0
  72. package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +13 -7
  73. package/test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice4.json +5 -1
  74. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +0 -8
  75. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +6 -0
  76. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +20 -0
  77. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json +42 -0
  78. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +32 -0
  79. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +37 -0
  80. package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +7 -1
  81. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +7 -1
  82. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +7 -1
  83. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +232 -8
  84. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +2 -1
  85. package/test/unit/ngsiv2/general/deviceService-test.js +2 -1
  86. package/test/unit/ngsiv2/general/https-support-test.js +2 -1
  87. package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +2 -1
  88. package/test/unit/ngsiv2/general/startup-test.js +2 -1
  89. package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +2 -1
  90. package/test/unit/ngsiv2/lazyAndCommands/command-test.js +2 -1
  91. package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +8 -6
  92. package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +3 -3
  93. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +3 -2
  94. package/test/unit/ngsiv2/ngsiService/autocast-test.js +2 -1
  95. package/test/unit/ngsiv2/ngsiService/queryDeviceInformationInCb-test.js +2 -1
  96. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +2 -1
  97. package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +2 -1
  98. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +2 -1
  99. package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +8 -7
  100. package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +2 -1
  101. package/test/unit/ngsiv2/plugins/custom-plugin_test.js +151 -0
  102. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +87 -13
  103. package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -1
  104. package/test/unit/ngsiv2/provisioning/device-group-api-test.js +1 -0
  105. package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -0
  106. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +12 -3
  107. package/test/unit/ngsiv2/provisioning/device-registration_test.js +2 -1
  108. package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +15 -12
  109. package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +1 -0
  110. package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +1 -0
  111. package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +1 -0
  112. package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +1 -0
  113. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +1 -0
  114. package/test/unit/plugins/capture-configuration-inPlugins_test.js +2 -1
  115. package/test/unit/plugins/capture-provision-inPlugins_test.js +2 -1
  116. package/doc/advanced-topics.md +0 -626
  117. package/doc/expressionLanguage.md +0 -762
  118. package/lib/plugins/expressionParser.js +0 -205
  119. package/test/unit/expressions/expression-test.js +0 -197
  120. package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +0 -881
  121. package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +0 -950
  122. package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +0 -294
@@ -39,7 +39,8 @@ const iotAgentConfig = {
39
39
  jsonLdContext: 'http://context.json-ld'
40
40
  },
41
41
  server: {
42
- port: 4041
42
+ port: 4041,
43
+ host: 'localhost'
43
44
  },
44
45
  types: {
45
46
  Light: {
@@ -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
  service: 'smartgondor',
@@ -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
  service: 'smartgondor',
@@ -48,7 +49,6 @@ const iotAgentConfig = {
48
49
  providerUrl: 'http://smartgondor.com'
49
50
  };
50
51
 
51
-
52
52
  const iotAgentConfigWithLimitedSupport = {
53
53
  contextBroker: {
54
54
  host: '192.168.1.1',
@@ -58,10 +58,11 @@ const iotAgentConfigWithLimitedSupport = {
58
58
  },
59
59
  server: {
60
60
  port: 4041,
61
- ldSupport : {
62
- null: false,
63
- datasetId: false
64
- }
61
+ host: 'localhost',
62
+ ldSupport: {
63
+ null: false,
64
+ datasetId: false
65
+ }
65
66
  },
66
67
  types: {
67
68
  Robot: {
@@ -91,7 +92,6 @@ const device = {
91
92
  service: 'smartgondor'
92
93
  };
93
94
 
94
-
95
95
  describe('NGSI-LD - Unsupported Endpoints', function () {
96
96
  beforeEach(function (done) {
97
97
  iotAgentLib.activate(iotAgentConfig, function () {
@@ -153,7 +153,6 @@ describe('NGSI-LD - Unsupported Endpoints', function () {
153
153
  });
154
154
  });
155
155
 
156
-
157
156
  it('PUT /entities/<entity-id> includes an NGSI-LD Null should return a valid NSGI-LD error message', function (done) {
158
157
  const options = {
159
158
  url:
@@ -162,7 +161,7 @@ describe('NGSI-LD - Unsupported Endpoints', function () {
162
161
  '/ngsi-ld/v1/entities/urn:ngsi-ld:entity/attrs/att',
163
162
  method: 'PUT',
164
163
  json: {
165
- "value": "urn:ngsi-ld:null"
164
+ value: 'urn:ngsi-ld:null'
166
165
  },
167
166
  headers: {
168
167
  'fiware-service': 'smartgondor',
@@ -194,7 +193,6 @@ describe('NGSI-LD - Limiting Support', function () {
194
193
  .post('/ngsi-ld/v1/entityOperations/upsert/')
195
194
  .reply(204);
196
195
 
197
-
198
196
  iotAgentLib.activate(iotAgentConfigWithLimitedSupport, function () {
199
197
  iotAgentLib.clearAll(function () {
200
198
  done();
@@ -217,7 +215,7 @@ describe('NGSI-LD - Limiting Support', function () {
217
215
  '/ngsi-ld/v1/entities/urn:ngsi-ld:Robot:r2d2/attrs/position',
218
216
  method: 'PATCH',
219
217
  json: {
220
- "value": "urn:ngsi-ld:null"
218
+ value: 'urn:ngsi-ld:null'
221
219
  },
222
220
  headers: {
223
221
  'fiware-service': 'smartgondor',
@@ -235,9 +233,8 @@ describe('NGSI-LD - Limiting Support', function () {
235
233
  done();
236
234
  });
237
235
  });
238
-
239
236
  });
240
- });
237
+ });
241
238
  describe('When sending a payload including a datasetId when datasetIds are unsupported ', function () {
242
239
  it('should return a valid NSGI-LD error message', function (done) {
243
240
  const options = {
@@ -276,7 +273,6 @@ describe('NGSI-LD - Limiting Support', function () {
276
273
  done();
277
274
  });
278
275
  });
279
-
280
276
  });
281
- });
277
+ });
282
278
  });
@@ -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: {
@@ -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
  service: 'smartgondor',
@@ -239,11 +240,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
239
240
  let longitudeFound = false;
240
241
 
241
242
  for (let i = 0; i < values.length; i++) {
242
- if (values[i].name === 'latitude' && values[i].type === 'string' && values[i].value === '-9.6') {
243
+ if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
243
244
  latitudeFound = true;
244
245
  }
245
246
 
246
- if (values[i].name === 'longitude' && values[i].type === 'string' && values[i].value === '12.4') {
247
+ if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
247
248
  longitudeFound = true;
248
249
  }
249
250
  }
@@ -347,11 +348,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
347
348
  let longitudeFound = false;
348
349
 
349
350
  for (let i = 0; i < values.length; i++) {
350
- if (values[i].name === 'latitude' && values[i].type === 'string' && values[i].value === '-9.6') {
351
+ if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
351
352
  latitudeFound = true;
352
353
  }
353
354
 
354
- if (values[i].name === 'longitude' && values[i].type === 'string' && values[i].value === '12.4') {
355
+ if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
355
356
  longitudeFound = true;
356
357
  }
357
358
  }
@@ -460,11 +461,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
460
461
  let longitudeFound = false;
461
462
 
462
463
  for (let i = 0; i < values.length; i++) {
463
- if (values[i].name === 'latitude' && values[i].type === 'string' && values[i].value === '-9.6') {
464
+ if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
464
465
  latitudeFound = true;
465
466
  }
466
467
 
467
- if (values[i].name === 'longitude' && values[i].type === 'string' && values[i].value === '12.4') {
468
+ if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
468
469
  longitudeFound = true;
469
470
  }
470
471
  }
@@ -602,11 +603,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
602
603
  let longitudeFound = false;
603
604
 
604
605
  for (let i = 0; i < values.length; i++) {
605
- if (values[i].name === 'latitude' && values[i].type === 'string' && values[i].value === '-9.6') {
606
+ if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
606
607
  latitudeFound = true;
607
608
  }
608
609
 
609
- if (values[i].name === 'longitude' && values[i].type === 'string' && values[i].value === '12.4') {
610
+ if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
610
611
  longitudeFound = true;
611
612
  }
612
613
  }
@@ -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: {
@@ -0,0 +1,152 @@
1
+ /*
2
+ * Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U
3
+ *
4
+ * This file is part of fiware-iotagent-lib
5
+ *
6
+ * fiware-iotagent-lib is free software: you can redistribute it and/or
7
+ * modify it under the terms of the GNU Affero General Public License as
8
+ * published by the Free Software Foundation, either version 3 of the License,
9
+ * or (at your option) any later version.
10
+ *
11
+ * fiware-iotagent-lib is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
+ * See the GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public
17
+ * License along with fiware-iotagent-lib.
18
+ * If not, see http://www.gnu.org/licenses/.
19
+ *
20
+ * For those usages not covered by the GNU Affero General Public License
21
+ * please contact with::daniel.moranjimenez@telefonica.com
22
+ *
23
+ * Modified by: Daniel Calvo - ATOS Research & Innovation
24
+ */
25
+
26
+ const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
27
+ const should = require('should');
28
+ const logger = require('logops');
29
+ const nock = require('nock');
30
+ let contextBrokerMock;
31
+ const iotAgentConfig = {
32
+ contextBroker: {
33
+ host: '192.168.1.1',
34
+ port: '1026',
35
+ ngsiVersion: 'ld',
36
+ jsonLdContext: 'http://context.json-ld'
37
+ },
38
+ server: {
39
+ port: 4041
40
+ },
41
+ types: {
42
+ Light: {
43
+ commands: [],
44
+ type: 'Light',
45
+ lazy: [
46
+ {
47
+ name: 'temperature',
48
+ type: 'centigrades'
49
+ }
50
+ ],
51
+ active: [
52
+ {
53
+ name: 'pressure',
54
+ type: 'Hgmm'
55
+ }
56
+ ]
57
+ }
58
+ },
59
+ service: 'smartgondor',
60
+ subservice: 'gardens',
61
+ providerUrl: 'http://smartgondor.com'
62
+ };
63
+
64
+ describe('NGSI-LD - Custom plugin', function () {
65
+ let updateInvoked = false;
66
+ let queryInvoked = false;
67
+
68
+ function updatePlugin(entity, typeInformation, callback) {
69
+ updateInvoked = true;
70
+ return callback(null, entity, typeInformation);
71
+ }
72
+ function queryPlugin(entity, typeInformation, callback) {
73
+ queryInvoked = true;
74
+ return callback(null, entity, typeInformation);
75
+ }
76
+ beforeEach(function (done) {
77
+ logger.setLevel('FATAL');
78
+
79
+ iotAgentLib.activate(iotAgentConfig, function () {
80
+ iotAgentLib.clearAll(function () {
81
+ iotAgentLib.addUpdateMiddleware(updatePlugin);
82
+ iotAgentLib.addQueryMiddleware(queryPlugin);
83
+ done();
84
+ });
85
+ });
86
+ });
87
+
88
+ afterEach(function (done) {
89
+ iotAgentLib.clearAll(function () {
90
+ iotAgentLib.deactivate(done);
91
+ updateInvoked = false;
92
+ queryInvoked = false;
93
+ });
94
+ });
95
+ describe('When an update occurs', function () {
96
+ const values = [
97
+ {
98
+ name: 'state',
99
+ type: 'Boolean',
100
+ value: 'true'
101
+ },
102
+ {
103
+ name: 'dimming',
104
+ type: 'Number',
105
+ value: 23
106
+ }
107
+ ];
108
+
109
+ beforeEach(function () {
110
+ nock.cleanAll();
111
+
112
+ contextBrokerMock = nock('http://192.168.1.1:1026')
113
+ .matchHeader('fiware-service', 'smartgondor')
114
+ .matchHeader('fiware-servicepath', 'gardens')
115
+ .post('/ngsi-ld/v1/entityOperations/upsert/')
116
+ .query({ options: 'update' })
117
+ .reply(204);
118
+ });
119
+
120
+ it('should invoke the plugin', function (done) {
121
+ iotAgentLib.update('light1', 'Light', '', values, function (error) {
122
+ should.not.exist(error);
123
+ contextBrokerMock.done();
124
+ updateInvoked.should.equal(true);
125
+ done();
126
+ });
127
+ });
128
+ });
129
+ describe('When an query occurs', function () {
130
+ beforeEach(function () {
131
+ nock.cleanAll();
132
+
133
+ contextBrokerMock = nock('http://192.168.1.1:1026')
134
+ .matchHeader('fiware-service', 'smartgondor')
135
+ .matchHeader('fiware-servicepath', 'gardens')
136
+ .get('/ngsi-ld/v1/entities/urn:ngsi-ld:Light:light1')
137
+ .query({ attrs: 'state,dimming' })
138
+ .reply(200, { state: 'good', dimming: '23' });
139
+ });
140
+
141
+ it('should invoke the plugin', function (done) {
142
+ const attributes = ['state', 'dimming'];
143
+ iotAgentLib.query('light1', 'Light', '', attributes, function (error) {
144
+ should.not.exist(error);
145
+ contextBrokerMock.done();
146
+ should.not.exist(error);
147
+ queryInvoked.should.equal(true);
148
+ done();
149
+ });
150
+ });
151
+ });
152
+ });
@@ -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: {
@@ -95,7 +96,7 @@ const iotAgentConfig = {
95
96
  object_id: 'h',
96
97
  name: 'humidity',
97
98
  type: 'Percentage',
98
- entity_name: 'Station Number ${@sn * 10}'
99
+ entity_name: '"Station Number "+sn*10'
99
100
  }
100
101
  ]
101
102
  },
@@ -38,7 +38,8 @@ const iotAgentConfig = {
38
38
  jsonLdContext: 'http://context.json-ld'
39
39
  },
40
40
  server: {
41
- port: 4041
41
+ port: 4041,
42
+ host: 'localhost'
42
43
  },
43
44
  types: {
44
45
  Light: {
@@ -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
  });
@@ -1,8 +1,12 @@
1
1
  {
2
- "id": "EntityNameByExp",
2
+ "id": "MicroLight1__SUFFIX",
3
3
  "type": "MicroLights",
4
4
  "attr_name": {
5
5
  "type": "string",
6
6
  "value": null
7
+ },
8
+ "suffix_st": {
9
+ "type": "Text",
10
+ "value": "SUFFIX"
7
11
  }
8
12
  }
@@ -1,12 +1,4 @@
1
1
  {
2
- "undef": {
3
- "type": "json",
4
- "value": null
5
- },
6
- "nil": {
7
- "type": "json",
8
- "value": null
9
- },
10
2
  "falsy": {
11
3
  "type": "Boolean",
12
4
  "value": false
@@ -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,2 +1,22 @@
1
1
  {
2
+ "TimeInstant": {
3
+ "type": "DateTime",
4
+ "value": "2015-08-05T07:35:01.468+00:00"
5
+ },
6
+ "location": {
7
+ "value": {
8
+ "coordinates": [
9
+ 13,
10
+ 52
11
+ ],
12
+ "type": "Point"
13
+ },
14
+ "type": "geo:json",
15
+ "metadata": {
16
+ "TimeInstant": {
17
+ "type": "DateTime",
18
+ "value": "2015-08-05T07:35:01.468+00:00"
19
+ }
20
+ }
21
+ }
2
22
  }
@@ -0,0 +1,42 @@
1
+ {
2
+ "entities": [
3
+ {
4
+ "id": "water1",
5
+ "type": "WaterTank",
6
+ "contB": {
7
+ "value": "31450.000",
8
+ "type": "Number",
9
+ "metadata": {
10
+ "TimeInstant": {
11
+ "type": "DateTime",
12
+ "value": "2015-08-05T07:35:01.468Z"
13
+ }
14
+ }
15
+ },
16
+ "TimeInstant": {
17
+ "type": "DateTime",
18
+ "value": "2015-08-05T07:35:01.468Z"
19
+ }
20
+ },
21
+ {
22
+ "id": "PA_B_0001",
23
+ "type": "WaterTank",
24
+ "waterLeavingTanks": {
25
+ "value": 3145,
26
+ "type": "Number",
27
+ "metadata": {
28
+ "TimeInstant": {
29
+ "type": "DateTime",
30
+ "value": "2015-08-05T07:35:01.468Z"
31
+ }
32
+ }
33
+ },
34
+ "TimeInstant": {
35
+ "type": "DateTime",
36
+ "value": "2015-08-05T07:35:01.468Z"
37
+ }
38
+ }
39
+ ],
40
+ "actionType": "update"
41
+ }
42
+
@@ -0,0 +1,32 @@
1
+ {
2
+ "TimeInstant": {
3
+ "type": "DateTime",
4
+ "value": "2015-08-05T07:35:01.468+00:00"
5
+ },
6
+ "location": {
7
+ "value": {
8
+ "coordinates": [
9
+ 13,
10
+ 52
11
+ ],
12
+ "type": "Point"
13
+ },
14
+ "type": "geo:json",
15
+ "metadata": {
16
+ "TimeInstant": {
17
+ "type": "DateTime",
18
+ "value": "2015-08-05T07:35:01.468+00:00"
19
+ }
20
+ }
21
+ },
22
+ "temperature": {
23
+ "value": null,
24
+ "type": "Number",
25
+ "metadata": {
26
+ "TimeInstant": {
27
+ "type": "DateTime",
28
+ "value": "2015-08-05T07:35:01.468+00:00"
29
+ }
30
+ }
31
+ }
32
+ }