iotagent-node-lib 3.4.4 → 4.0.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 (93) hide show
  1. package/README.md +4 -0
  2. package/doc/admin.md +1 -13
  3. package/doc/api.md +116 -18
  4. package/doc/devel/architecture.md +0 -12
  5. package/doc/index.md +1 -1
  6. package/doc/roadmap.md +22 -10
  7. package/lib/commonConfig.js +0 -11
  8. package/lib/model/Device.js +2 -1
  9. package/lib/model/Group.js +2 -1
  10. package/lib/model/dbConn.js +22 -11
  11. package/lib/plugins/expressionPlugin.js +0 -5
  12. package/lib/plugins/jexlParser.js +15 -31
  13. package/lib/services/common/genericMiddleware.js +14 -2
  14. package/lib/services/common/iotManagerService.js +2 -1
  15. package/lib/services/devices/deviceRegistryMongoDB.js +3 -1
  16. package/lib/services/devices/deviceService.js +16 -21
  17. package/lib/services/devices/devices-NGSI-LD.js +5 -98
  18. package/lib/services/devices/devices-NGSI-mixed.js +0 -14
  19. package/lib/services/devices/devices-NGSI-v2.js +3 -0
  20. package/lib/services/groups/groupRegistryMemory.js +0 -25
  21. package/lib/services/groups/groupRegistryMongoDB.js +20 -19
  22. package/lib/services/groups/groupService.js +3 -14
  23. package/lib/services/ngsi/entities-NGSI-LD.js +81 -6
  24. package/lib/services/ngsi/entities-NGSI-v2.js +303 -698
  25. package/lib/services/ngsi/ngsiUtils.js +0 -30
  26. package/lib/services/northBound/deviceProvisioningServer.js +6 -3
  27. package/lib/templates/createDevice.json +4 -0
  28. package/lib/templates/createDeviceLax.json +4 -0
  29. package/lib/templates/deviceGroup.json +4 -0
  30. package/lib/templates/updateDevice.json +4 -0
  31. package/lib/templates/updateDeviceLax.json +4 -0
  32. package/package.json +6 -2
  33. package/test/functional/README.md +378 -0
  34. package/test/functional/config-test.js +70 -0
  35. package/test/functional/functional-tests-runner.js +126 -0
  36. package/test/functional/functional-tests.js +241 -0
  37. package/test/functional/testCases.js +2944 -0
  38. package/test/functional/testUtils.js +251 -0
  39. package/test/tools/utils.js +25 -0
  40. package/test/unit/mongodb/mongodb-connectionoptions-test.js +35 -22
  41. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +3 -34
  42. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +8 -1
  43. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin7.json +1 -4
  44. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin8.json +1 -6
  45. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +67 -87
  46. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +7 -13
  47. package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +43 -43
  48. package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +19 -29
  49. package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +0 -1
  50. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +35 -46
  51. package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +8 -9
  52. package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +96 -221
  53. package/test/unit/ngsi-ld/provisioning/device-registration_test.js +18 -27
  54. package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +8 -16
  55. package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +0 -13
  56. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +4 -4
  57. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29b.json +8 -0
  58. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +1 -1
  59. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +0 -6
  60. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +8 -0
  61. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34b.json +14 -0
  62. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +1 -11
  63. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36b.json +13 -0
  64. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin37.json +8 -0
  65. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +1 -11
  66. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10b.json +37 -0
  67. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +0 -4
  68. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +0 -4
  69. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +0 -4
  70. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +4 -0
  71. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +0 -3
  72. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +10 -12
  73. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +0 -4
  74. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -5
  75. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +8 -12
  76. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +0 -4
  77. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +0 -8
  78. package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +7 -1
  79. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +898 -28
  80. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +0 -4
  81. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +267 -0
  82. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +19 -21
  83. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +21 -24
  84. package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -21
  85. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +4 -6
  86. package/test/unit/ngsi-ld/ngsiService/autocast-test.js +0 -438
  87. package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +0 -381
  88. package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +0 -311
  89. package/test/unit/ngsiv2/ngsiService/autocast-test.js +0 -325
  90. package/test/unit/ngsiv2/ngsiService/geoproperties-test.js +0 -427
  91. package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +0 -217
  92. package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +0 -119
  93. package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -309
@@ -377,7 +377,6 @@ describe('NGSI-v2 - Active attributes test', function () {
377
377
  ];
378
378
 
379
379
  timekeeper.freeze(time);
380
-
381
380
  nock.cleanAll();
382
381
 
383
382
  contextBrokerMock = nock('http://192.168.1.1:1026')
@@ -922,7 +921,6 @@ describe('NGSI-v2 - Active attributes test', function () {
922
921
  ];
923
922
 
924
923
  beforeEach(function (done) {
925
-
926
924
  nock.cleanAll();
927
925
 
928
926
  contextBrokerMock = nock('http://192.168.1.1:1026')
@@ -970,7 +968,6 @@ describe('NGSI-v2 - Active attributes test', function () {
970
968
  ];
971
969
 
972
970
  beforeEach(function (done) {
973
-
974
971
  nock.cleanAll();
975
972
 
976
973
  contextBrokerMock = nock('http://192.168.1.1:1026')
@@ -1018,7 +1015,6 @@ describe('NGSI-v2 - Active attributes test', function () {
1018
1015
  ];
1019
1016
 
1020
1017
  beforeEach(function (done) {
1021
-
1022
1018
  nock.cleanAll();
1023
1019
 
1024
1020
  contextBrokerMock = nock('http://192.168.1.1:1026')
@@ -75,6 +75,102 @@ const iotAgentConfig = {
75
75
  type: 'type4'
76
76
  }
77
77
  ]
78
+ },
79
+ Light_Explicit_True: {
80
+ commands: [],
81
+ type: 'Light_Explicit_True',
82
+ explicitAttrs: true,
83
+ timestamp: false,
84
+ active: [
85
+ {
86
+ name: 'pressure',
87
+ type: 'Number'
88
+ }
89
+ ],
90
+ staticAttributes: [
91
+ {
92
+ name: 'attr1',
93
+ type: 'Text',
94
+ value: 'Static Text'
95
+ },
96
+ {
97
+ name: 'attr2',
98
+ type: 'Number',
99
+ value: 123
100
+ }
101
+ ]
102
+ },
103
+ Light_Explicit_False: {
104
+ commands: [],
105
+ type: 'Light_Explicit_False',
106
+ explicitAttrs: false,
107
+ timestamp: false,
108
+ active: [
109
+ {
110
+ name: 'pressure',
111
+ type: 'Number'
112
+ }
113
+ ],
114
+ staticAttributes: [
115
+ {
116
+ name: 'attr1',
117
+ type: 'Text',
118
+ value: 'Static Text'
119
+ },
120
+ {
121
+ name: 'attr2',
122
+ type: 'Number',
123
+ value: 123
124
+ }
125
+ ]
126
+ },
127
+ Light_Explicit_Array: {
128
+ commands: [],
129
+ type: 'Light_Explicit_Array',
130
+ explicitAttrs: '[ "pressure", "attr1" ]',
131
+ timestamp: false,
132
+ active: [
133
+ {
134
+ name: 'pressure',
135
+ type: 'Number'
136
+ }
137
+ ],
138
+ staticAttributes: [
139
+ {
140
+ name: 'attr1',
141
+ type: 'Text',
142
+ value: 'Static Text'
143
+ },
144
+ {
145
+ name: 'attr2',
146
+ type: 'Number',
147
+ value: 123
148
+ }
149
+ ]
150
+ },
151
+ Light_Explicit_Expression: {
152
+ commands: [],
153
+ type: 'Light_Explicit_Expression',
154
+ explicitAttrs: ' pressure ? [ "pressure", "attr1" ] : [ "attr2" ] ',
155
+ timestamp: false,
156
+ active: [
157
+ {
158
+ name: 'pressure',
159
+ type: 'Number'
160
+ }
161
+ ],
162
+ staticAttributes: [
163
+ {
164
+ name: 'attr1',
165
+ type: 'Text',
166
+ value: 'Static Text'
167
+ },
168
+ {
169
+ name: 'attr2',
170
+ type: 'Number',
171
+ value: 123
172
+ }
173
+ ]
78
174
  }
79
175
  },
80
176
  timestamp: true,
@@ -146,4 +242,175 @@ describe('NGSI-v2 - Static attributes test', function () {
146
242
  );
147
243
  });
148
244
  });
245
+
246
+ describe('When using explicitAttrs true', function () {
247
+ const newValues = [
248
+ {
249
+ name: 'pressure',
250
+ type: 'Number',
251
+ value: 321
252
+ }
253
+ ];
254
+
255
+ beforeEach(function (done) {
256
+ nock.cleanAll();
257
+
258
+ contextBrokerMock = nock('http://192.168.1.1:1026')
259
+ .matchHeader('fiware-service', 'smartgondor')
260
+ .matchHeader('fiware-servicepath', 'gardens')
261
+ .post('/v2/entities?options=upsert', {
262
+ id: 'light2',
263
+ type: 'Light_Explicit_True',
264
+ pressure: {
265
+ value: 321,
266
+ type: 'Number'
267
+ },
268
+ attr1: {
269
+ value: 'Static Text',
270
+ type: 'Text'
271
+ },
272
+ attr2: {
273
+ value: 123,
274
+ type: 'Number'
275
+ }
276
+ })
277
+ .reply(204);
278
+
279
+ iotAgentLib.activate(iotAgentConfig, done);
280
+ });
281
+
282
+ it('should include all the statics', function (done) {
283
+ iotAgentLib.update('light2', 'Light_Explicit_True', '', newValues, function (error) {
284
+ should.not.exist(error);
285
+ contextBrokerMock.done();
286
+ done();
287
+ });
288
+ });
289
+ });
290
+
291
+ describe('When using explicitAttrs false', function () {
292
+ const newValues = [
293
+ {
294
+ name: 'pressure',
295
+ type: 'Number',
296
+ value: 321
297
+ }
298
+ ];
299
+
300
+ beforeEach(function (done) {
301
+ nock.cleanAll();
302
+
303
+ contextBrokerMock = nock('http://192.168.1.1:1026')
304
+ .matchHeader('fiware-service', 'smartgondor')
305
+ .matchHeader('fiware-servicepath', 'gardens')
306
+ .post('/v2/entities?options=upsert', {
307
+ id: 'light2',
308
+ type: 'Light_Explicit_True',
309
+ pressure: {
310
+ value: 321,
311
+ type: 'Number'
312
+ },
313
+ attr1: {
314
+ value: 'Static Text',
315
+ type: 'Text'
316
+ },
317
+ attr2: {
318
+ value: 123,
319
+ type: 'Number'
320
+ }
321
+ })
322
+ .reply(204);
323
+
324
+ iotAgentLib.activate(iotAgentConfig, done);
325
+ });
326
+
327
+ it('should include all the statics', function (done) {
328
+ iotAgentLib.update('light2', 'Light_Explicit_True', '', newValues, function (error) {
329
+ should.not.exist(error);
330
+ contextBrokerMock.done();
331
+ done();
332
+ });
333
+ });
334
+ });
335
+
336
+ describe('When using explicitAttrs as array', function () {
337
+ const newValues = [
338
+ {
339
+ name: 'pressure',
340
+ type: 'Number',
341
+ value: 321
342
+ }
343
+ ];
344
+
345
+ beforeEach(function (done) {
346
+ nock.cleanAll();
347
+ contextBrokerMock = nock('http://192.168.1.1:1026')
348
+ .matchHeader('fiware-service', 'smartgondor')
349
+ .matchHeader('fiware-servicepath', 'gardens')
350
+ .post('/v2/entities?options=upsert', {
351
+ id: 'light2',
352
+ type: 'Light_Explicit_Array',
353
+ pressure: {
354
+ value: 321,
355
+ type: 'Number'
356
+ },
357
+ attr1: {
358
+ value: 'Static Text',
359
+ type: 'Text'
360
+ }
361
+ })
362
+ .reply(204);
363
+
364
+ iotAgentLib.activate(iotAgentConfig, done);
365
+ });
366
+
367
+ it('should include only statics defined into the array', function (done) {
368
+ iotAgentLib.update('light2', 'Light_Explicit_Array', '', newValues, function (error) {
369
+ should.not.exist(error);
370
+ contextBrokerMock.done();
371
+ done();
372
+ });
373
+ });
374
+ });
375
+
376
+ describe('When using explicitAttrs as expression', function () {
377
+ const newValues = [
378
+ {
379
+ name: 'pressure',
380
+ type: 'Number',
381
+ value: 321
382
+ }
383
+ ];
384
+
385
+ beforeEach(function (done) {
386
+ nock.cleanAll();
387
+
388
+ contextBrokerMock = nock('http://192.168.1.1:1026')
389
+ .matchHeader('fiware-service', 'smartgondor')
390
+ .matchHeader('fiware-servicepath', 'gardens')
391
+ .post('/v2/entities?options=upsert', {
392
+ id: 'light2',
393
+ type: 'Light_Explicit_Expression',
394
+ pressure: {
395
+ value: 321,
396
+ type: 'Number'
397
+ },
398
+ attr1: {
399
+ value: 'Static Text',
400
+ type: 'Text'
401
+ }
402
+ })
403
+ .reply(204);
404
+
405
+ iotAgentLib.activate(iotAgentConfig, done);
406
+ });
407
+
408
+ it('should include statics as the result on the expression', function (done) {
409
+ iotAgentLib.update('light2', 'Light_Explicit_Expression', '', newValues, function (error) {
410
+ should.not.exist(error);
411
+ contextBrokerMock.done();
412
+ done();
413
+ });
414
+ });
415
+ });
149
416
  });
@@ -32,7 +32,6 @@ const logger = require('logops');
32
32
  const nock = require('nock');
33
33
  let contextBrokerMock;
34
34
  const iotAgentConfig = {
35
- autocast: true,
36
35
  contextBroker: {
37
36
  host: '192.168.1.1',
38
37
  port: '1026',
@@ -90,7 +89,8 @@ const iotAgentConfig = {
90
89
  {
91
90
  object_id: 'al',
92
91
  name: 'keep_alive',
93
- type: 'None'
92
+ type: 'None',
93
+ skipValue: 'null passes'
94
94
  },
95
95
  {
96
96
  object_id: 'ta',
@@ -113,7 +113,6 @@ const iotAgentConfig = {
113
113
  describe('NGSI-v2 - Attribute alias plugin', function () {
114
114
  beforeEach(function (done) {
115
115
  logger.setLevel('FATAL');
116
-
117
116
  iotAgentLib.activate(iotAgentConfig, function () {
118
117
  iotAgentLib.clearAll(function () {
119
118
  done();
@@ -131,7 +130,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
131
130
  {
132
131
  name: 't',
133
132
  type: 'centigrades',
134
- value: '52'
133
+ value: 52
135
134
  },
136
135
  {
137
136
  name: 'p',
@@ -153,7 +152,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
153
152
  .reply(204);
154
153
  });
155
154
 
156
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
155
+ it('should rename the attributes as expected by the alias mappings', function (done) {
157
156
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
158
157
  should.not.exist(error);
159
158
  contextBrokerMock.done();
@@ -166,7 +165,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
166
165
  {
167
166
  name: 'l',
168
167
  type: 'lums',
169
- value: '9'
168
+ value: 9
170
169
  }
171
170
  ];
172
171
 
@@ -183,7 +182,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
183
182
  .reply(204);
184
183
  });
185
184
 
186
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
185
+ it('should rename the attributes as expected by the alias mappings', function (done) {
187
186
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
188
187
  should.not.exist(error);
189
188
  contextBrokerMock.done();
@@ -196,7 +195,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
196
195
  {
197
196
  name: 'ut',
198
197
  type: 'Number',
199
- value: '99823423'
198
+ value: 99823423
200
199
  }
201
200
  ];
202
201
 
@@ -227,7 +226,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
227
226
  {
228
227
  name: 'ut',
229
228
  type: 'Number',
230
- value: '99823423'
229
+ value: 99823423
231
230
  }
232
231
  ];
233
232
 
@@ -244,7 +243,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
244
243
  .reply(204);
245
244
  });
246
245
 
247
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
246
+ it('should rename the attributes as expected by the alias mappings', function (done) {
248
247
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
249
248
  should.not.exist(error);
250
249
  contextBrokerMock.done();
@@ -258,7 +257,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
258
257
  {
259
258
  name: 'ap',
260
259
  type: 'Number',
261
- value: '0.45'
260
+ value: 0.45
262
261
  }
263
262
  ];
264
263
 
@@ -275,7 +274,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
275
274
  .reply(204);
276
275
  });
277
276
 
278
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
277
+ it('should rename the attributes as expected by the alias mappings', function (done) {
279
278
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
280
279
  should.not.exist(error);
281
280
  contextBrokerMock.done();
@@ -306,7 +305,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
306
305
  .reply(204);
307
306
  });
308
307
 
309
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
308
+ it('should rename the attributes as expected by the alias mappings', function (done) {
310
309
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
311
310
  should.not.exist(error);
312
311
  contextBrokerMock.done();
@@ -320,13 +319,12 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
320
319
  {
321
320
  name: 'al',
322
321
  type: 'None',
323
- value: 'null'
322
+ value: null
324
323
  }
325
324
  ];
326
325
 
327
326
  beforeEach(function () {
328
327
  nock.cleanAll();
329
-
330
328
  contextBrokerMock = nock('http://192.168.1.1:1026')
331
329
  .matchHeader('fiware-service', 'smartgondor')
332
330
  .matchHeader('fiware-servicepath', 'gardens')
@@ -337,7 +335,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
337
335
  .reply(204);
338
336
  });
339
337
 
340
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
338
+ it('should rename the attributes as expected by the alias mappings', function (done) {
341
339
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
342
340
  should.not.exist(error);
343
341
  contextBrokerMock.done();
@@ -351,7 +349,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
351
349
  {
352
350
  name: 'ta',
353
351
  type: 'Array',
354
- value: '["iot","device"]'
352
+ value: ['iot', 'device']
355
353
  }
356
354
  ];
357
355
 
@@ -368,7 +366,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
368
366
  .reply(204);
369
367
  });
370
368
 
371
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
369
+ it('should rename the attributes as expected by the alias mappings', function (done) {
372
370
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
373
371
  should.not.exist(error);
374
372
  contextBrokerMock.done();
@@ -382,7 +380,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
382
380
  {
383
381
  name: 'c',
384
382
  type: 'Object',
385
- value: '{"firmware": {"version": "1.1.0","hash": "cf23df2207d99a74fbe169e3eba035e633b65d94"}}'
383
+ value: { firmware: { version: '1.1.0', hash: 'cf23df2207d99a74fbe169e3eba035e633b65d94' } }
386
384
  }
387
385
  ];
388
386
 
@@ -399,7 +397,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
399
397
  .reply(204);
400
398
  });
401
399
 
402
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
400
+ it('should rename the attributes as expected by the alias mappings', function (done) {
403
401
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
404
402
  should.not.exist(error);
405
403
  contextBrokerMock.done();
@@ -430,7 +428,7 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
430
428
  .reply(204);
431
429
  });
432
430
 
433
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
431
+ it('should rename the attributes as expected by the alias mappings', function (done) {
434
432
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
435
433
  should.not.exist(error);
436
434
  contextBrokerMock.done();
@@ -272,7 +272,7 @@ const iotAgentConfig = {
272
272
  commands: [],
273
273
  type: 'WeatherStation',
274
274
  lazy: [],
275
- static: [
275
+ staticAttributes: [
276
276
  {
277
277
  name: 'st1',
278
278
  type: 'Number',
@@ -522,7 +522,13 @@ const iotAgentConfig = {
522
522
  expression: 'z+1'
523
523
  },
524
524
  {
525
- name: 'nonexpectedAtt',
525
+ name: 'alsoexpectedAtt',
526
+ type: 'number',
527
+ expression: 'w+1',
528
+ skipValue: 'loquesea'
529
+ },
530
+ {
531
+ name: 'nonexpectedAttByDefaultSkipValue',
526
532
  type: 'number',
527
533
  expression: 'w+1'
528
534
  },
@@ -564,7 +570,7 @@ const iotAgentConfig = {
564
570
  object_id: 'y'
565
571
  }
566
572
  ],
567
- static: [
573
+ staticAttributes: [
568
574
  {
569
575
  name: 'bar',
570
576
  type: 'text',
@@ -600,7 +606,7 @@ const iotAgentConfig = {
600
606
 
601
607
  describe('NGSI-v2 - Multi-entity plugin', function () {
602
608
  beforeEach(function (done) {
603
- logger.setLevel('DEBUG');
609
+ logger.setLevel('FATAL');
604
610
 
605
611
  iotAgentLib.activate(iotAgentConfig, function () {
606
612
  iotAgentLib.clearAll(function () {
@@ -702,7 +708,6 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
702
708
 
703
709
  beforeEach(function () {
704
710
  nock.cleanAll();
705
-
706
711
  contextBrokerMock = nock('http://192.168.1.1:1026')
707
712
  .matchHeader('fiware-service', 'smartgondor')
708
713
  .matchHeader('fiware-servicepath', 'gardens')
@@ -740,7 +745,6 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
740
745
 
741
746
  beforeEach(function () {
742
747
  nock.cleanAll();
743
-
744
748
  contextBrokerMock = nock('http://192.168.1.1:1026')
745
749
  .matchHeader('fiware-service', 'smartgondor')
746
750
  .matchHeader('fiware-servicepath', 'gardens')
@@ -779,7 +783,6 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
779
783
 
780
784
  beforeEach(function () {
781
785
  nock.cleanAll();
782
-
783
786
  contextBrokerMock = nock('http://192.168.1.1:1026')
784
787
  .matchHeader('fiware-service', 'smartgondor')
785
788
  .matchHeader('fiware-servicepath', 'gardens')
@@ -1120,7 +1123,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
1120
1123
  .post(
1121
1124
  '/v2/op/update',
1122
1125
  utils.readExampleFile(
1123
- './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json'
1126
+ './test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10b.json'
1124
1127
  )
1125
1128
  )
1126
1129
  .reply(204);
@@ -1151,7 +1154,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
1151
1154
  .reply(204);
1152
1155
  });
1153
1156
 
1154
- describe('When an update comes for a multientity whith a wrong mapping)', function () {
1157
+ describe('When an update comes for a multientity whith a wrong mapping', function () {
1155
1158
  const values = [
1156
1159
  {
1157
1160
  name: 'v',
@@ -1172,7 +1175,6 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
1172
1175
 
1173
1176
  beforeEach(function () {
1174
1177
  nock.cleanAll();
1175
-
1176
1178
  contextBrokerMock = nock('http://192.168.1.1:1026')
1177
1179
  .matchHeader('fiware-service', 'smartgondor')
1178
1180
  .matchHeader('fiware-servicepath', 'gardens')
@@ -1372,7 +1374,6 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
1372
1374
 
1373
1375
  beforeEach(function () {
1374
1376
  nock.cleanAll();
1375
-
1376
1377
  contextBrokerMock = nock('http://192.168.1.1:1026')
1377
1378
  .matchHeader('fiware-service', 'smartgondor')
1378
1379
  .matchHeader('fiware-servicepath', 'gardens')
@@ -1424,7 +1425,6 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
1424
1425
 
1425
1426
  beforeEach(function () {
1426
1427
  nock.cleanAll();
1427
-
1428
1428
  contextBrokerMock = nock('http://192.168.1.1:1026')
1429
1429
  .matchHeader('fiware-service', 'smartgondor')
1430
1430
  .matchHeader('fiware-servicepath', 'gardens')
@@ -1489,7 +1489,6 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
1489
1489
  describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plugin', function () {
1490
1490
  beforeEach(function (done) {
1491
1491
  logger.setLevel('FATAL');
1492
-
1493
1492
  iotAgentConfig.timestamp = true;
1494
1493
  iotAgentLib.activate(iotAgentConfig, function () {
1495
1494
  iotAgentLib.clearAll(function () {
@@ -1560,7 +1559,7 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu
1560
1559
 
1561
1560
  delete expectedBody.entities[1].TimeInstant;
1562
1561
  delete expectedBody.entities[1].humidity.metadata.TimeInstant;
1563
- return JSON.stringify(body) === JSON.stringify(expectedBody);
1562
+ return utils.deepEqual(body, expectedBody);
1564
1563
  }
1565
1564
  return false;
1566
1565
  })
@@ -1583,22 +1582,22 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu
1583
1582
  );
1584
1583
  // Note that TimeInstant fields are not included in the json used by this mock as they are dynamic
1585
1584
  // fields. The following code just checks that TimeInstant fields are present.
1586
- if (!body.entities[1].TimeInstant || !body.entities[1].humidity.metadata.TimeInstant) {
1585
+ if (!body.entities[0].TimeInstant || !body.entities[0].humidity.metadata.TimeInstant) {
1587
1586
  return false;
1588
1587
  }
1589
1588
 
1590
- const timeInstantEntity2 = body.entities[1].TimeInstant;
1591
- const timeInstantAtt = body.entities[1].humidity.metadata.TimeInstant;
1589
+ const timeInstantEntity2 = body.entities[0].TimeInstant;
1590
+ const timeInstantAtt = body.entities[0].humidity.metadata.TimeInstant;
1592
1591
  if (
1593
1592
  moment(timeInstantEntity2, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid &&
1594
1593
  moment(timeInstantAtt, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid
1595
1594
  ) {
1596
- delete body.entities[1].TimeInstant;
1597
- delete body.entities[1].humidity.metadata.TimeInstant;
1595
+ delete body.entities[0].TimeInstant;
1596
+ delete body.entities[0].humidity.metadata.TimeInstant;
1598
1597
 
1599
- delete expectedBody.entities[1].TimeInstant;
1600
- delete expectedBody.entities[1].humidity.metadata.TimeInstant;
1601
- return JSON.stringify(body) === JSON.stringify(expectedBody);
1598
+ delete expectedBody.entities[0].TimeInstant;
1599
+ delete expectedBody.entities[0].humidity.metadata.TimeInstant;
1600
+ return utils.deepEqual(body, expectedBody);
1602
1601
  }
1603
1602
  return false;
1604
1603
  })
@@ -1636,7 +1635,6 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu
1636
1635
  value: '2018-06-13T13:28:34.611Z'
1637
1636
  }
1638
1637
  ];
1639
-
1640
1638
  iotAgentLib.update('ws5', 'WeatherStation', '', tsValue, function (error) {
1641
1639
  should.not.exist(error);
1642
1640
  contextBrokerMock.done();
@@ -1649,7 +1647,6 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu
1649
1647
  describe('NGSI-v2 - Multi-entity plugin is executed for a command update for a regular entity ', function () {
1650
1648
  beforeEach(function (done) {
1651
1649
  logger.setLevel('FATAL');
1652
-
1653
1650
  iotAgentConfig.timestamp = true;
1654
1651
  const time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00
1655
1652
  timekeeper.freeze(time);