iotagent-node-lib 3.4.3 → 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 (94) hide show
  1. package/CHANGES_NEXT_RELEASE +0 -1
  2. package/README.md +4 -0
  3. package/doc/admin.md +1 -13
  4. package/doc/api.md +118 -14
  5. package/doc/devel/architecture.md +0 -12
  6. package/doc/index.md +1 -1
  7. package/doc/roadmap.md +22 -10
  8. package/lib/commonConfig.js +0 -11
  9. package/lib/model/Device.js +2 -1
  10. package/lib/model/Group.js +2 -1
  11. package/lib/model/dbConn.js +22 -11
  12. package/lib/plugins/expressionPlugin.js +0 -5
  13. package/lib/plugins/jexlParser.js +15 -31
  14. package/lib/services/common/genericMiddleware.js +14 -2
  15. package/lib/services/common/iotManagerService.js +2 -1
  16. package/lib/services/devices/deviceRegistryMongoDB.js +3 -1
  17. package/lib/services/devices/deviceService.js +16 -21
  18. package/lib/services/devices/devices-NGSI-LD.js +5 -98
  19. package/lib/services/devices/devices-NGSI-mixed.js +0 -14
  20. package/lib/services/devices/devices-NGSI-v2.js +3 -0
  21. package/lib/services/groups/groupRegistryMemory.js +0 -25
  22. package/lib/services/groups/groupRegistryMongoDB.js +20 -19
  23. package/lib/services/groups/groupService.js +3 -14
  24. package/lib/services/ngsi/entities-NGSI-LD.js +81 -6
  25. package/lib/services/ngsi/entities-NGSI-v2.js +304 -687
  26. package/lib/services/ngsi/ngsiUtils.js +0 -30
  27. package/lib/services/northBound/deviceProvisioningServer.js +6 -3
  28. package/lib/templates/createDevice.json +4 -0
  29. package/lib/templates/createDeviceLax.json +4 -0
  30. package/lib/templates/deviceGroup.json +4 -0
  31. package/lib/templates/updateDevice.json +4 -0
  32. package/lib/templates/updateDeviceLax.json +4 -0
  33. package/package.json +6 -2
  34. package/test/functional/README.md +378 -0
  35. package/test/functional/config-test.js +70 -0
  36. package/test/functional/functional-tests-runner.js +126 -0
  37. package/test/functional/functional-tests.js +241 -0
  38. package/test/functional/testCases.js +2944 -0
  39. package/test/functional/testUtils.js +251 -0
  40. package/test/tools/utils.js +25 -0
  41. package/test/unit/mongodb/mongodb-connectionoptions-test.js +35 -22
  42. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +3 -34
  43. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +8 -1
  44. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin7.json +1 -4
  45. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin8.json +1 -6
  46. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +67 -87
  47. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +7 -13
  48. package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +43 -43
  49. package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +19 -29
  50. package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +0 -1
  51. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +35 -46
  52. package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +8 -9
  53. package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +96 -221
  54. package/test/unit/ngsi-ld/provisioning/device-registration_test.js +18 -27
  55. package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +8 -16
  56. package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +0 -13
  57. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +4 -4
  58. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29b.json +8 -0
  59. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +1 -1
  60. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +0 -6
  61. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +8 -0
  62. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34b.json +14 -0
  63. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +1 -11
  64. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36b.json +13 -0
  65. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin37.json +8 -0
  66. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +1 -11
  67. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10b.json +37 -0
  68. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +0 -4
  69. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +0 -4
  70. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +0 -4
  71. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +4 -0
  72. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +0 -3
  73. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +10 -12
  74. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +0 -4
  75. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -5
  76. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +8 -12
  77. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +0 -4
  78. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +0 -8
  79. package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +7 -1
  80. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +898 -28
  81. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +188 -1
  82. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +267 -0
  83. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +19 -21
  84. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +21 -24
  85. package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -21
  86. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +4 -6
  87. package/test/unit/ngsi-ld/ngsiService/autocast-test.js +0 -438
  88. package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +0 -381
  89. package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +0 -311
  90. package/test/unit/ngsiv2/ngsiService/autocast-test.js +0 -325
  91. package/test/unit/ngsiv2/ngsiService/geoproperties-test.js +0 -427
  92. package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +0 -217
  93. package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +0 -119
  94. package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -309
@@ -0,0 +1,2944 @@
1
+ /*
2
+ * Copyright 2023 Telefonica Investigación y Desarrollo, S.A.U
3
+ *
4
+ * This file is part of iotagent-json
5
+ *
6
+ * iotagent-json 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
+ * iotagent-json 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 iotagent-json.
18
+ * If not, seehttp://www.gnu.org/licenses/.
19
+ *
20
+ * For those usages not covered by the GNU Affero General Public License
21
+ * please contact with::[contacto@tid.es]
22
+ *
23
+ * Modified by: Miguel Angel Pedraza
24
+ */
25
+
26
+ /* eslint-disable no-unused-vars*/
27
+ /* eslint-disable no-unused-expressions*/
28
+
29
+ const config = require('./config-test.js');
30
+ var chai = require('chai');
31
+ var chaiMatchPattern = require('chai-match-pattern');
32
+ chai.use(chaiMatchPattern);
33
+ var _ = chaiMatchPattern.getLodashModule();
34
+ chai.config.truncateThreshold = 0;
35
+
36
+ const globalEnv = {
37
+ service: 'smartgondor',
38
+ servicePath: '/gardens',
39
+ apikey: '123456',
40
+ entity_type: 'TestType',
41
+ entity_name: 'TestType:TestDevice',
42
+ deviceId: 'TestDevice'
43
+ };
44
+
45
+ const testCases = [
46
+ // 0000 - BASIC TESTS
47
+ {
48
+ describeName: '0010 - Simple group without attributes',
49
+ provision: {
50
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
51
+ method: 'POST',
52
+ json: {
53
+ services: [
54
+ {
55
+ resource: '/iot/json',
56
+ apikey: globalEnv.apikey,
57
+ entity_type: globalEnv.entity_type,
58
+ commands: [],
59
+ lazy: [],
60
+ attributes: [],
61
+ static_attributes: []
62
+ }
63
+ ]
64
+ },
65
+ headers: {
66
+ 'fiware-service': globalEnv.service,
67
+ 'fiware-servicepath': globalEnv.servicePath
68
+ }
69
+ },
70
+ should: [
71
+ {
72
+ // loglevel: 'debug',
73
+ shouldName:
74
+ 'A - WHEN sending measures through http IT should send measures to Context Broker preserving value types',
75
+ config: {
76
+ type: 'single'
77
+ },
78
+ measure: {
79
+ url: 'http://localhost:' + config.http.port + '/iot/json',
80
+ method: 'POST',
81
+ qs: {
82
+ i: globalEnv.deviceId,
83
+ k: globalEnv.apikey
84
+ },
85
+ json: {
86
+ a: false,
87
+ b: 10,
88
+ c: 'text',
89
+ d: 10.5,
90
+ e: [1, 2],
91
+ f: { a: 1, b: 2 }
92
+ }
93
+ },
94
+ expectation: {
95
+ id: globalEnv.entity_name,
96
+ type: globalEnv.entity_type,
97
+ a: {
98
+ value: false,
99
+ type: 'string'
100
+ },
101
+ b: {
102
+ value: 10,
103
+ type: 'string'
104
+ },
105
+ c: {
106
+ type: 'string',
107
+ value: 'text'
108
+ },
109
+ d: {
110
+ type: 'string',
111
+ value: 10.5
112
+ },
113
+ e: {
114
+ type: 'string',
115
+ value: [1, 2]
116
+ },
117
+ f: {
118
+ type: 'string',
119
+ value: {
120
+ a: 1,
121
+ b: 2
122
+ }
123
+ }
124
+ }
125
+ },
126
+ {
127
+ transport: 'MQTT',
128
+ shouldName:
129
+ 'B - WHEN sending measures through mqtt IT should send measures to Context Broker preserving value types',
130
+ type: 'single',
131
+ measure: {
132
+ url: 'http://localhost:' + config.http.port + '/iot/json',
133
+ method: 'POST',
134
+ qs: {
135
+ i: globalEnv.deviceId,
136
+ k: globalEnv.apikey
137
+ },
138
+ json: {
139
+ a: false,
140
+ b: 10,
141
+ c: 'text',
142
+ d: 10.5,
143
+ e: [1, 2],
144
+ f: { a: 1, b: 2 }
145
+ }
146
+ },
147
+ expectation: {
148
+ id: globalEnv.entity_name,
149
+ type: globalEnv.entity_type,
150
+ a: {
151
+ value: false,
152
+ type: 'string'
153
+ },
154
+ b: {
155
+ value: 10,
156
+ type: 'string'
157
+ },
158
+ c: {
159
+ type: 'string',
160
+ value: 'text'
161
+ },
162
+ d: {
163
+ type: 'string',
164
+ value: 10.5
165
+ },
166
+ e: {
167
+ type: 'string',
168
+ value: [1, 2]
169
+ },
170
+ f: {
171
+ type: 'string',
172
+ value: {
173
+ a: 1,
174
+ b: 2
175
+ }
176
+ }
177
+ }
178
+ }
179
+ ]
180
+ },
181
+ {
182
+ describeName: '0020 - Simple group with active attributes',
183
+ provision: {
184
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
185
+ method: 'POST',
186
+ json: {
187
+ services: [
188
+ {
189
+ resource: '/iot/json',
190
+ apikey: globalEnv.apikey,
191
+ entity_type: globalEnv.entity_type,
192
+ commands: [],
193
+ lazy: [],
194
+ attributes: [
195
+ {
196
+ object_id: 'a',
197
+ name: 'attr_a',
198
+ type: 'Boolean'
199
+ },
200
+ {
201
+ object_id: 'b',
202
+ name: 'attr_b',
203
+ type: 'Integer'
204
+ },
205
+ {
206
+ object_id: 'c',
207
+ name: 'attr_c',
208
+ type: 'Text'
209
+ },
210
+ {
211
+ object_id: 'd',
212
+ name: 'attr_d',
213
+ type: 'Float'
214
+ },
215
+ {
216
+ object_id: 'e',
217
+ name: 'attr_e',
218
+ type: 'Array'
219
+ },
220
+ {
221
+ object_id: 'f',
222
+ name: 'attr_f',
223
+ type: 'Object'
224
+ }
225
+ ],
226
+ static_attributes: []
227
+ }
228
+ ]
229
+ },
230
+ headers: {
231
+ 'fiware-service': globalEnv.service,
232
+ 'fiware-servicepath': globalEnv.servicePath
233
+ }
234
+ },
235
+ should: [
236
+ {
237
+ shouldName:
238
+ 'A - WHEN sending defined object_ids (measures) through http IT should send measures to Context Broker preserving value types and name mappings',
239
+ type: 'single',
240
+ measure: {
241
+ url: 'http://localhost:' + config.http.port + '/iot/json',
242
+ method: 'POST',
243
+ qs: {
244
+ i: globalEnv.deviceId,
245
+ k: globalEnv.apikey
246
+ },
247
+ json: {
248
+ a: false,
249
+ b: 10,
250
+ c: 'text',
251
+ d: 10.5,
252
+ e: [1, 2],
253
+ f: { a: 1, b: 2 }
254
+ }
255
+ },
256
+ expectation: {
257
+ id: globalEnv.entity_name,
258
+ type: globalEnv.entity_type,
259
+ attr_a: {
260
+ value: false,
261
+ type: 'Boolean'
262
+ },
263
+ attr_b: {
264
+ value: 10,
265
+ type: 'Integer'
266
+ },
267
+ attr_c: {
268
+ type: 'Text',
269
+ value: 'text'
270
+ },
271
+ attr_d: {
272
+ type: 'Float',
273
+ value: 10.5
274
+ },
275
+ attr_e: {
276
+ type: 'Array',
277
+ value: [1, 2]
278
+ },
279
+ attr_f: {
280
+ type: 'Object',
281
+ value: {
282
+ a: 1,
283
+ b: 2
284
+ }
285
+ }
286
+ }
287
+ },
288
+ {
289
+ shouldName:
290
+ 'B - WHEN sending defined object_ids (measures) through mqtt IT should send measures to Context Broker preserving value types and name mappings',
291
+ transport: 'MQTT',
292
+ type: 'single',
293
+ measure: {
294
+ url: 'http://localhost:' + config.http.port + '/iot/json',
295
+ method: 'POST',
296
+ qs: {
297
+ i: globalEnv.deviceId,
298
+ k: globalEnv.apikey
299
+ },
300
+ json: {
301
+ a: false,
302
+ b: 10,
303
+ c: 'text',
304
+ d: 10.5,
305
+ e: [1, 2],
306
+ f: { a: 1, b: 2 }
307
+ }
308
+ },
309
+ expectation: {
310
+ id: globalEnv.entity_name,
311
+ type: globalEnv.entity_type,
312
+ attr_a: {
313
+ value: false,
314
+ type: 'Boolean'
315
+ },
316
+ attr_b: {
317
+ value: 10,
318
+ type: 'Integer'
319
+ },
320
+ attr_c: {
321
+ type: 'Text',
322
+ value: 'text'
323
+ },
324
+ attr_d: {
325
+ type: 'Float',
326
+ value: 10.5
327
+ },
328
+ attr_e: {
329
+ type: 'Array',
330
+ value: [1, 2]
331
+ },
332
+ attr_f: {
333
+ type: 'Object',
334
+ value: {
335
+ a: 1,
336
+ b: 2
337
+ }
338
+ }
339
+ }
340
+ },
341
+ {
342
+ shouldName:
343
+ 'C - WHEN sending undefined object_ids (measures) through http IT should send measures to Context Broker preserving value types',
344
+ type: 'single',
345
+ measure: {
346
+ url: 'http://localhost:' + config.http.port + '/iot/json',
347
+ method: 'POST',
348
+ qs: {
349
+ i: globalEnv.deviceId,
350
+ k: globalEnv.apikey
351
+ },
352
+ json: {
353
+ u: false,
354
+ v: 10,
355
+ w: 'text',
356
+ y: 10.5,
357
+ x: [1, 2],
358
+ z: { a: 1, b: 2 }
359
+ }
360
+ },
361
+ expectation: {
362
+ id: globalEnv.entity_name,
363
+ type: globalEnv.entity_type,
364
+ u: {
365
+ value: false,
366
+ type: 'string'
367
+ },
368
+ v: {
369
+ value: 10,
370
+ type: 'string'
371
+ },
372
+ w: {
373
+ type: 'string',
374
+ value: 'text'
375
+ },
376
+ y: {
377
+ type: 'string',
378
+ value: 10.5
379
+ },
380
+ x: {
381
+ type: 'string',
382
+ value: [1, 2]
383
+ },
384
+ z: {
385
+ type: 'string',
386
+ value: {
387
+ a: 1,
388
+ b: 2
389
+ }
390
+ }
391
+ }
392
+ },
393
+ {
394
+ shouldName:
395
+ 'D - WHEN sending undefined object_ids (measures) through mqtt IT should send measures to Context Broker preserving value types',
396
+ transport: 'MQTT',
397
+ type: 'single',
398
+ measure: {
399
+ url: 'http://localhost:' + config.http.port + '/iot/json',
400
+ method: 'POST',
401
+ qs: {
402
+ i: globalEnv.deviceId,
403
+ k: globalEnv.apikey
404
+ },
405
+ json: {
406
+ u: false,
407
+ v: 10,
408
+ w: 'text',
409
+ y: 10.5,
410
+ x: [1, 2],
411
+ z: { a: 1, b: 2 }
412
+ }
413
+ },
414
+ expectation: {
415
+ id: globalEnv.entity_name,
416
+ type: globalEnv.entity_type,
417
+ u: {
418
+ value: false,
419
+ type: 'string'
420
+ },
421
+ v: {
422
+ value: 10,
423
+ type: 'string'
424
+ },
425
+ w: {
426
+ type: 'string',
427
+ value: 'text'
428
+ },
429
+ y: {
430
+ type: 'string',
431
+ value: 10.5
432
+ },
433
+ x: {
434
+ type: 'string',
435
+ value: [1, 2]
436
+ },
437
+ z: {
438
+ type: 'string',
439
+ value: {
440
+ a: 1,
441
+ b: 2
442
+ }
443
+ }
444
+ }
445
+ }
446
+ ]
447
+ },
448
+ // 0100 - JEXL TESTS
449
+ {
450
+ describeName: '0100 - Simple group with active attribute + JEXL expression boolean (!)',
451
+ provision: {
452
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
453
+ method: 'POST',
454
+ json: {
455
+ services: [
456
+ {
457
+ resource: '/iot/json',
458
+ apikey: globalEnv.apikey,
459
+ entity_type: globalEnv.entity_type,
460
+ commands: [],
461
+ lazy: [],
462
+ attributes: [
463
+ {
464
+ object_id: 'a',
465
+ name: 'attr_a',
466
+ type: 'Boolean',
467
+ expression: '!a'
468
+ }
469
+ ],
470
+ static_attributes: []
471
+ }
472
+ ]
473
+ },
474
+ headers: {
475
+ 'fiware-service': globalEnv.service,
476
+ 'fiware-servicepath': globalEnv.servicePath
477
+ }
478
+ },
479
+ should: [
480
+ {
481
+ shouldName:
482
+ 'A - WHEN sending a boolean value (false) through http IT should send to Context Broker the value true ',
483
+ type: 'single',
484
+ measure: {
485
+ url: 'http://localhost:' + config.http.port + '/iot/json',
486
+ method: 'POST',
487
+ qs: {
488
+ i: globalEnv.deviceId,
489
+ k: globalEnv.apikey
490
+ },
491
+ json: {
492
+ a: false
493
+ }
494
+ },
495
+ expectation: {
496
+ id: globalEnv.entity_name,
497
+ type: globalEnv.entity_type,
498
+ attr_a: {
499
+ value: true,
500
+ type: 'Boolean'
501
+ }
502
+ }
503
+ },
504
+ {
505
+ shouldName:
506
+ 'B - WHEN sending a numeric value (3) through http IT should send to Context Broker the value false ',
507
+ type: 'single',
508
+ measure: {
509
+ url: 'http://localhost:' + config.http.port + '/iot/json',
510
+ method: 'POST',
511
+ qs: {
512
+ i: globalEnv.deviceId,
513
+ k: globalEnv.apikey
514
+ },
515
+ json: {
516
+ a: 3
517
+ }
518
+ },
519
+ expectation: {
520
+ id: globalEnv.entity_name,
521
+ type: globalEnv.entity_type,
522
+ attr_a: {
523
+ value: false,
524
+ type: 'Boolean'
525
+ }
526
+ }
527
+ },
528
+ {
529
+ shouldName:
530
+ 'C - WHEN sending a text value (abcd) through http IT should send to Context Broker the value false ',
531
+ type: 'single',
532
+ measure: {
533
+ url: 'http://localhost:' + config.http.port + '/iot/json',
534
+ method: 'POST',
535
+ qs: {
536
+ i: globalEnv.deviceId,
537
+ k: globalEnv.apikey
538
+ },
539
+ json: {
540
+ a: 'abcd'
541
+ }
542
+ },
543
+ expectation: {
544
+ id: globalEnv.entity_name,
545
+ type: globalEnv.entity_type,
546
+ attr_a: {
547
+ value: false,
548
+ type: 'Boolean'
549
+ }
550
+ }
551
+ },
552
+ {
553
+ shouldName:
554
+ 'D - WHEN not sending the object ID (undefined) required by the expression through http IT should send to Context Broker the value true ',
555
+ type: 'single',
556
+ measure: {
557
+ url: 'http://localhost:' + config.http.port + '/iot/json',
558
+ method: 'POST',
559
+ qs: {
560
+ i: globalEnv.deviceId,
561
+ k: globalEnv.apikey
562
+ },
563
+ json: {
564
+ b: 1
565
+ }
566
+ },
567
+ expectation: {
568
+ id: globalEnv.entity_name,
569
+ type: globalEnv.entity_type,
570
+ attr_a: {
571
+ value: true,
572
+ type: 'Boolean'
573
+ },
574
+ b: {
575
+ value: 1,
576
+ type: 'string'
577
+ }
578
+ }
579
+ }
580
+ ]
581
+ },
582
+ {
583
+ describeName: '0110 - Simple group with active attribute + JEXL expression numeric (+3)',
584
+ provision: {
585
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
586
+ method: 'POST',
587
+ json: {
588
+ services: [
589
+ {
590
+ resource: '/iot/json',
591
+ apikey: globalEnv.apikey,
592
+ entity_type: globalEnv.entity_type,
593
+ commands: [],
594
+ lazy: [],
595
+ attributes: [
596
+ {
597
+ object_id: 'a',
598
+ name: 'attr_a',
599
+ type: 'Number',
600
+ expression: 'a+3'
601
+ }
602
+ ],
603
+ static_attributes: []
604
+ }
605
+ ]
606
+ },
607
+ headers: {
608
+ 'fiware-service': globalEnv.service,
609
+ 'fiware-servicepath': globalEnv.servicePath
610
+ }
611
+ },
612
+ should: [
613
+ {
614
+ shouldName:
615
+ 'A - WHEN sending a boolean value (true) through http IT should send to Context Broker the value 4 ',
616
+ type: 'single',
617
+ measure: {
618
+ url: 'http://localhost:' + config.http.port + '/iot/json',
619
+ method: 'POST',
620
+ qs: {
621
+ i: globalEnv.deviceId,
622
+ k: globalEnv.apikey
623
+ },
624
+ json: {
625
+ a: true
626
+ }
627
+ },
628
+ expectation: {
629
+ id: globalEnv.entity_name,
630
+ type: globalEnv.entity_type,
631
+ attr_a: {
632
+ value: 4,
633
+ type: 'Number'
634
+ }
635
+ }
636
+ },
637
+ {
638
+ shouldName:
639
+ 'B - WHEN sending a boolean value (false) through http IT should send to Context Broker the value 3 ',
640
+ type: 'single',
641
+ measure: {
642
+ url: 'http://localhost:' + config.http.port + '/iot/json',
643
+ method: 'POST',
644
+ qs: {
645
+ i: globalEnv.deviceId,
646
+ k: globalEnv.apikey
647
+ },
648
+ json: {
649
+ a: false
650
+ }
651
+ },
652
+ expectation: {
653
+ id: globalEnv.entity_name,
654
+ type: globalEnv.entity_type,
655
+ attr_a: {
656
+ value: 3,
657
+ type: 'Number'
658
+ }
659
+ }
660
+ },
661
+ {
662
+ shouldName:
663
+ 'C - WHEN sending a numeric value (-7) through http IT should send to Context Broker the value -4 ',
664
+ type: 'single',
665
+ measure: {
666
+ url: 'http://localhost:' + config.http.port + '/iot/json',
667
+ method: 'POST',
668
+ qs: {
669
+ i: globalEnv.deviceId,
670
+ k: globalEnv.apikey
671
+ },
672
+ json: {
673
+ a: -7
674
+ }
675
+ },
676
+ expectation: {
677
+ id: globalEnv.entity_name,
678
+ type: globalEnv.entity_type,
679
+ attr_a: {
680
+ value: -4,
681
+ type: 'Number'
682
+ }
683
+ }
684
+ },
685
+ {
686
+ shouldName:
687
+ 'D - WHEN sending a text value (abcd) through http IT should send to Context Broker the value abcd3',
688
+ type: 'single',
689
+ measure: {
690
+ url: 'http://localhost:' + config.http.port + '/iot/json',
691
+ method: 'POST',
692
+ qs: {
693
+ i: globalEnv.deviceId,
694
+ k: globalEnv.apikey
695
+ },
696
+ json: {
697
+ a: 'abcd'
698
+ }
699
+ },
700
+ expectation: {
701
+ id: globalEnv.entity_name,
702
+ type: globalEnv.entity_type,
703
+ attr_a: {
704
+ value: 'abcd3',
705
+ type: 'Number'
706
+ }
707
+ }
708
+ },
709
+ {
710
+ shouldName:
711
+ 'E - WHEN not sending the object ID (undefined) required by the expression through http IT should not send that attribute to Context Broker',
712
+ type: 'single',
713
+ measure: {
714
+ url: 'http://localhost:' + config.http.port + '/iot/json',
715
+ method: 'POST',
716
+ qs: {
717
+ i: globalEnv.deviceId,
718
+ k: globalEnv.apikey
719
+ },
720
+ json: {
721
+ b: 1
722
+ }
723
+ },
724
+ expectation: {
725
+ id: globalEnv.entity_name,
726
+ type: globalEnv.entity_type,
727
+ b: {
728
+ value: 1,
729
+ type: 'string'
730
+ }
731
+ }
732
+ }
733
+ ]
734
+ },
735
+ {
736
+ describeName: '0120 - Simple group with active attribute + JEXL expression numeric (*3)',
737
+ provision: {
738
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
739
+ method: 'POST',
740
+ json: {
741
+ services: [
742
+ {
743
+ resource: '/iot/json',
744
+ apikey: globalEnv.apikey,
745
+ entity_type: globalEnv.entity_type,
746
+ commands: [],
747
+ lazy: [],
748
+ attributes: [
749
+ {
750
+ object_id: 'a',
751
+ name: 'attr_a',
752
+ type: 'Number',
753
+ expression: 'a*3'
754
+ }
755
+ ],
756
+ static_attributes: []
757
+ }
758
+ ]
759
+ },
760
+ headers: {
761
+ 'fiware-service': globalEnv.service,
762
+ 'fiware-servicepath': globalEnv.servicePath
763
+ }
764
+ },
765
+ should: [
766
+ {
767
+ shouldName:
768
+ 'A - WHEN sending a boolean value (true) through http IT should send to Context Broker the value 3 ',
769
+ type: 'single',
770
+ measure: {
771
+ url: 'http://localhost:' + config.http.port + '/iot/json',
772
+ method: 'POST',
773
+ qs: {
774
+ i: globalEnv.deviceId,
775
+ k: globalEnv.apikey
776
+ },
777
+ json: {
778
+ a: true
779
+ }
780
+ },
781
+ expectation: {
782
+ id: globalEnv.entity_name,
783
+ type: globalEnv.entity_type,
784
+ attr_a: {
785
+ value: 3,
786
+ type: 'Number'
787
+ }
788
+ }
789
+ },
790
+ {
791
+ shouldName:
792
+ 'B - WHEN sending a boolean value (false) through http IT should send to Context Broker the value 0',
793
+ type: 'single',
794
+ measure: {
795
+ url: 'http://localhost:' + config.http.port + '/iot/json',
796
+ method: 'POST',
797
+ qs: {
798
+ i: globalEnv.deviceId,
799
+ k: globalEnv.apikey
800
+ },
801
+ json: {
802
+ a: false
803
+ }
804
+ },
805
+ expectation: {
806
+ id: globalEnv.entity_name,
807
+ type: globalEnv.entity_type,
808
+ attr_a: {
809
+ value: 0,
810
+ type: 'Number'
811
+ }
812
+ }
813
+ },
814
+ {
815
+ shouldName:
816
+ 'C - WHEN sending a numeric value (-7) through http IT should send to Context Broker the value -21 ',
817
+ type: 'single',
818
+ measure: {
819
+ url: 'http://localhost:' + config.http.port + '/iot/json',
820
+ method: 'POST',
821
+ qs: {
822
+ i: globalEnv.deviceId,
823
+ k: globalEnv.apikey
824
+ },
825
+ json: {
826
+ a: -7
827
+ }
828
+ },
829
+ expectation: {
830
+ id: globalEnv.entity_name,
831
+ type: globalEnv.entity_type,
832
+ attr_a: {
833
+ value: -21,
834
+ type: 'Number'
835
+ }
836
+ }
837
+ },
838
+ {
839
+ shouldName:
840
+ 'D - WHEN sending a text value (abcd) through http IT should not send to anything to Context Broker',
841
+ type: 'single',
842
+ measure: {
843
+ url: 'http://localhost:' + config.http.port + '/iot/json',
844
+ method: 'POST',
845
+ qs: {
846
+ i: globalEnv.deviceId,
847
+ k: globalEnv.apikey
848
+ },
849
+ json: {
850
+ a: 'abcd'
851
+ }
852
+ },
853
+ expectation: []
854
+ },
855
+ {
856
+ shouldName:
857
+ 'E - WHEN not sending the object ID (undefined) required by the expression through http IT should not send that attribute to Context Broker',
858
+ type: 'single',
859
+ measure: {
860
+ url: 'http://localhost:' + config.http.port + '/iot/json',
861
+ method: 'POST',
862
+ qs: {
863
+ i: globalEnv.deviceId,
864
+ k: globalEnv.apikey
865
+ },
866
+ json: {
867
+ b: 1
868
+ }
869
+ },
870
+ expectation: {
871
+ id: globalEnv.entity_name,
872
+ type: globalEnv.entity_type,
873
+ b: {
874
+ value: 1,
875
+ type: 'string'
876
+ }
877
+ }
878
+ }
879
+ ]
880
+ },
881
+ {
882
+ describeName: '0130 - Simple group with active attribute + JEXL expression text (a|substr(0,2))',
883
+ provision: {
884
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
885
+ method: 'POST',
886
+ json: {
887
+ services: [
888
+ {
889
+ resource: '/iot/json',
890
+ apikey: globalEnv.apikey,
891
+ entity_type: globalEnv.entity_type,
892
+ commands: [],
893
+ lazy: [],
894
+ attributes: [
895
+ {
896
+ object_id: 'a',
897
+ name: 'attr_a',
898
+ type: 'Number',
899
+ expression: 'a|substr(0,3)'
900
+ }
901
+ ],
902
+ static_attributes: []
903
+ }
904
+ ]
905
+ },
906
+ headers: {
907
+ 'fiware-service': globalEnv.service,
908
+ 'fiware-servicepath': globalEnv.servicePath
909
+ }
910
+ },
911
+ should: [
912
+ {
913
+ shouldName:
914
+ 'A - WHEN sending a boolean value (true) through http IT should send to Context Broker the value "tru" ',
915
+ type: 'single',
916
+ measure: {
917
+ url: 'http://localhost:' + config.http.port + '/iot/json',
918
+ method: 'POST',
919
+ qs: {
920
+ i: globalEnv.deviceId,
921
+ k: globalEnv.apikey
922
+ },
923
+ json: {
924
+ a: true
925
+ }
926
+ },
927
+ expectation: {
928
+ id: globalEnv.entity_name,
929
+ type: globalEnv.entity_type,
930
+ attr_a: {
931
+ value: 'tru',
932
+ type: 'Number'
933
+ }
934
+ }
935
+ },
936
+ {
937
+ shouldName:
938
+ 'B - WHEN sending a boolean value (false) through http IT should send to Context Broker the value "fal"',
939
+ type: 'single',
940
+ measure: {
941
+ url: 'http://localhost:' + config.http.port + '/iot/json',
942
+ method: 'POST',
943
+ qs: {
944
+ i: globalEnv.deviceId,
945
+ k: globalEnv.apikey
946
+ },
947
+ json: {
948
+ a: false
949
+ }
950
+ },
951
+ expectation: {
952
+ id: globalEnv.entity_name,
953
+ type: globalEnv.entity_type,
954
+ attr_a: {
955
+ value: 'fal',
956
+ type: 'Number'
957
+ }
958
+ }
959
+ },
960
+ {
961
+ shouldName:
962
+ 'C - WHEN sending a numeric value (-7) through http IT should send to Context Broker the value "-7" ',
963
+ type: 'single',
964
+ measure: {
965
+ url: 'http://localhost:' + config.http.port + '/iot/json',
966
+ method: 'POST',
967
+ qs: {
968
+ i: globalEnv.deviceId,
969
+ k: globalEnv.apikey
970
+ },
971
+ json: {
972
+ a: -7
973
+ }
974
+ },
975
+ expectation: {
976
+ id: globalEnv.entity_name,
977
+ type: globalEnv.entity_type,
978
+ attr_a: {
979
+ value: '-7',
980
+ type: 'Number'
981
+ }
982
+ }
983
+ },
984
+ {
985
+ shouldName:
986
+ 'D - WHEN sending a text value (abcd) through http IT should not send to anything to Context Broker',
987
+ type: 'single',
988
+ measure: {
989
+ url: 'http://localhost:' + config.http.port + '/iot/json',
990
+ method: 'POST',
991
+ qs: {
992
+ i: globalEnv.deviceId,
993
+ k: globalEnv.apikey
994
+ },
995
+ json: {
996
+ a: 'abcd'
997
+ }
998
+ },
999
+ expectation: {
1000
+ id: globalEnv.entity_name,
1001
+ type: globalEnv.entity_type,
1002
+ attr_a: {
1003
+ value: 'abc',
1004
+ type: 'Number'
1005
+ }
1006
+ }
1007
+ },
1008
+ {
1009
+ shouldName:
1010
+ 'E - WHEN not sending the object ID (undefined) required by the expression through http IT should not send that attribute to Context Broker',
1011
+ type: 'single',
1012
+ measure: {
1013
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1014
+ method: 'POST',
1015
+ qs: {
1016
+ i: globalEnv.deviceId,
1017
+ k: globalEnv.apikey
1018
+ },
1019
+ json: {
1020
+ b: 1
1021
+ }
1022
+ },
1023
+ expectation: {
1024
+ id: globalEnv.entity_name,
1025
+ type: globalEnv.entity_type,
1026
+ attr_a: {
1027
+ value: 'und',
1028
+ type: 'Number'
1029
+ },
1030
+ b: {
1031
+ value: 1,
1032
+ type: 'string'
1033
+ }
1034
+ }
1035
+ }
1036
+ ]
1037
+ },
1038
+ {
1039
+ describeName: '0140 - Simple group with active attribute + chained JEXL expression text (a|substr(0,2))',
1040
+ provision: {
1041
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
1042
+ method: 'POST',
1043
+ json: {
1044
+ services: [
1045
+ {
1046
+ resource: '/iot/json',
1047
+ apikey: globalEnv.apikey,
1048
+ entity_type: globalEnv.entity_type,
1049
+ commands: [],
1050
+ lazy: [],
1051
+ attributes: [
1052
+ {
1053
+ object_id: 'a',
1054
+ name: 'a',
1055
+ type: 'Text',
1056
+ expression: 'a | trim | replacestr("hello","hi")'
1057
+ }
1058
+ ],
1059
+ static_attributes: []
1060
+ }
1061
+ ]
1062
+ },
1063
+ headers: {
1064
+ 'fiware-service': globalEnv.service,
1065
+ 'fiware-servicepath': globalEnv.servicePath
1066
+ }
1067
+ },
1068
+ should: [
1069
+ {
1070
+ shouldName:
1071
+ 'A - WHEN sending a expected value ("Say hello and smile") through http IT should send to Context Broker the value "Say hi and smile" ',
1072
+ type: 'single',
1073
+ measure: {
1074
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1075
+ method: 'POST',
1076
+ qs: {
1077
+ i: globalEnv.deviceId,
1078
+ k: globalEnv.apikey
1079
+ },
1080
+ json: {
1081
+ a: 'Say hello and smile'
1082
+ }
1083
+ },
1084
+ expectation: {
1085
+ id: globalEnv.entity_name,
1086
+ type: globalEnv.entity_type,
1087
+ a: {
1088
+ value: 'Say hi and smile',
1089
+ type: 'Text'
1090
+ }
1091
+ }
1092
+ }
1093
+ ]
1094
+ },
1095
+ {
1096
+ describeName: '0150 - Simple group with active attribute + JEXL expression text reusing previous values)',
1097
+ provision: {
1098
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
1099
+ method: 'POST',
1100
+ json: {
1101
+ services: [
1102
+ {
1103
+ resource: '/iot/json',
1104
+ apikey: globalEnv.apikey,
1105
+ entity_type: globalEnv.entity_type,
1106
+ commands: [],
1107
+ lazy: [],
1108
+ attributes: [
1109
+ {
1110
+ object_id: 'a',
1111
+ name: 'attr_a',
1112
+ type: 'Number',
1113
+ expression: 'a*10'
1114
+ },
1115
+ {
1116
+ object_id: 'b',
1117
+ name: 'attr_b',
1118
+ type: 'Number',
1119
+ expression: 'attr_a*10'
1120
+ }
1121
+ ],
1122
+ static_attributes: []
1123
+ }
1124
+ ]
1125
+ },
1126
+ headers: {
1127
+ 'fiware-service': globalEnv.service,
1128
+ 'fiware-servicepath': globalEnv.servicePath
1129
+ }
1130
+ },
1131
+ should: [
1132
+ {
1133
+ shouldName:
1134
+ 'A - WHEN sending a value (a:3) through http IT should apply nested expressions and send to Context Broker the value "attr_b=300" ',
1135
+ type: 'single',
1136
+ measure: {
1137
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1138
+ method: 'POST',
1139
+ qs: {
1140
+ i: globalEnv.deviceId,
1141
+ k: globalEnv.apikey
1142
+ },
1143
+ json: {
1144
+ a: 3
1145
+ }
1146
+ },
1147
+ expectation: {
1148
+ id: globalEnv.entity_name,
1149
+ type: globalEnv.entity_type,
1150
+ attr_a: {
1151
+ value: 30,
1152
+ type: 'Number'
1153
+ },
1154
+ attr_b: {
1155
+ value: 300,
1156
+ type: 'Number'
1157
+ }
1158
+ }
1159
+ }
1160
+ ]
1161
+ },
1162
+ {
1163
+ describeName: '0160 - Simple group with active attribute + JEXL expression referencing static attributes',
1164
+ provision: {
1165
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
1166
+ method: 'POST',
1167
+ json: {
1168
+ services: [
1169
+ {
1170
+ resource: '/iot/json',
1171
+ apikey: globalEnv.apikey,
1172
+ entity_type: globalEnv.entity_type,
1173
+ commands: [],
1174
+ lazy: [],
1175
+ attributes: [
1176
+ {
1177
+ object_id: 'a',
1178
+ name: 'attr_a',
1179
+ type: 'Number',
1180
+ expression: 'a*coef'
1181
+ }
1182
+ ],
1183
+ static_attributes: [
1184
+ {
1185
+ name: 'coef',
1186
+ type: 'Number',
1187
+ value: 1.5
1188
+ }
1189
+ ]
1190
+ }
1191
+ ]
1192
+ },
1193
+ headers: {
1194
+ 'fiware-service': globalEnv.service,
1195
+ 'fiware-servicepath': globalEnv.servicePath
1196
+ }
1197
+ },
1198
+ should: [
1199
+ {
1200
+ shouldName:
1201
+ 'A - WHEN sending a value (a:6) through http IT should apply the expression using the static attribute value and send to Context Broker the value "attr_a:9" ',
1202
+ type: 'single',
1203
+ measure: {
1204
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1205
+ method: 'POST',
1206
+ qs: {
1207
+ i: globalEnv.deviceId,
1208
+ k: globalEnv.apikey
1209
+ },
1210
+ json: {
1211
+ a: 6
1212
+ }
1213
+ },
1214
+ expectation: {
1215
+ id: globalEnv.entity_name,
1216
+ type: globalEnv.entity_type,
1217
+ attr_a: {
1218
+ value: 9,
1219
+ type: 'Number'
1220
+ },
1221
+ coef: {
1222
+ value: 1.5,
1223
+ type: 'Number'
1224
+ }
1225
+ }
1226
+ }
1227
+ ]
1228
+ },
1229
+ {
1230
+ describeName: '0170 - Simple group with active attribute + JEXL expression referencing context attributes',
1231
+ skip: 'lib', // Explanation in #1523
1232
+ provision: {
1233
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
1234
+ method: 'POST',
1235
+ json: {
1236
+ services: [
1237
+ {
1238
+ resource: '/iot/json',
1239
+ apikey: globalEnv.apikey,
1240
+ entity_type: globalEnv.entity_type,
1241
+ commands: [],
1242
+ lazy: [],
1243
+ attributes: [
1244
+ {
1245
+ object_id: 'a',
1246
+ name: 'attr_a',
1247
+ type: 'Text',
1248
+ expression: 'a+":"+service+subservice+id+type'
1249
+ }
1250
+ ]
1251
+ }
1252
+ ]
1253
+ },
1254
+ headers: {
1255
+ 'fiware-service': globalEnv.service,
1256
+ 'fiware-servicepath': globalEnv.servicePath
1257
+ }
1258
+ },
1259
+ should: [
1260
+ {
1261
+ shouldName:
1262
+ 'A - WHEN sending a value (text) through http IT should apply the expression using the context attributes value and send to Context Broker the value "text:smartgondor/gardensTestDeviceTestType" ',
1263
+ type: 'single',
1264
+ measure: {
1265
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1266
+ method: 'POST',
1267
+ qs: {
1268
+ i: globalEnv.deviceId,
1269
+ k: globalEnv.apikey
1270
+ },
1271
+ json: {
1272
+ a: 'text'
1273
+ }
1274
+ },
1275
+ expectation: {
1276
+ id: globalEnv.entity_name,
1277
+ type: globalEnv.entity_type,
1278
+ attr_a: {
1279
+ value:
1280
+ 'text:' +
1281
+ globalEnv.service +
1282
+ globalEnv.servicePath +
1283
+ globalEnv.deviceId +
1284
+ globalEnv.entity_type,
1285
+ type: 'Text'
1286
+ }
1287
+ }
1288
+ }
1289
+ ]
1290
+ },
1291
+ {
1292
+ describeName: '0180 - Simple group with active attributes + JEXL multiples expressions at same time',
1293
+ skip: 'lib', // Explanation in #1523
1294
+ provision: {
1295
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
1296
+ method: 'POST',
1297
+ json: {
1298
+ services: [
1299
+ {
1300
+ resource: '/iot/json',
1301
+ apikey: globalEnv.apikey,
1302
+ entity_type: globalEnv.entity_type,
1303
+ commands: [],
1304
+ lazy: [],
1305
+ attributes: [
1306
+ {
1307
+ object_id: 'a',
1308
+ name: 'attr_a',
1309
+ type: 'Boolean',
1310
+ expression: '!a'
1311
+ },
1312
+ {
1313
+ object_id: 'b',
1314
+ name: 'attr_b',
1315
+ type: 'Integer',
1316
+ expression: 'b+1'
1317
+ },
1318
+ {
1319
+ object_id: 'c',
1320
+ name: 'attr_c',
1321
+ type: 'Text',
1322
+ expression: 'c+":"+service+subservice+id+type'
1323
+ },
1324
+ {
1325
+ object_id: 'd',
1326
+ name: 'attr_d',
1327
+ type: 'Float',
1328
+ expression: 'd/2+attr_b'
1329
+ },
1330
+ {
1331
+ object_id: 'e',
1332
+ name: 'attr_e',
1333
+ type: 'Array',
1334
+ expression: 'e|concatarr([3,4])'
1335
+ },
1336
+ {
1337
+ object_id: 'f',
1338
+ name: 'attr_f',
1339
+ type: 'Object',
1340
+ expression: '{coordinates: [f.a,f.b], type: "Point"}'
1341
+ }
1342
+ ],
1343
+ static_attributes: []
1344
+ }
1345
+ ]
1346
+ },
1347
+ headers: {
1348
+ 'fiware-service': globalEnv.service,
1349
+ 'fiware-servicepath': globalEnv.servicePath
1350
+ }
1351
+ },
1352
+ should: [
1353
+ {
1354
+ shouldName:
1355
+ 'A - WHEN sending multiples object_ids (measures) through http IT should send measures to Context Broker applying all expressions at same time',
1356
+ type: 'single',
1357
+ measure: {
1358
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1359
+ method: 'POST',
1360
+ qs: {
1361
+ i: globalEnv.deviceId,
1362
+ k: globalEnv.apikey
1363
+ },
1364
+ json: {
1365
+ a: false,
1366
+ b: 10,
1367
+ c: 'text',
1368
+ d: 10.5,
1369
+ e: [1, 2],
1370
+ f: { a: 1, b: 2 }
1371
+ }
1372
+ },
1373
+ expectation: {
1374
+ id: globalEnv.entity_name,
1375
+ type: globalEnv.entity_type,
1376
+ attr_a: {
1377
+ value: true,
1378
+ type: 'Boolean'
1379
+ },
1380
+ attr_b: {
1381
+ value: 11,
1382
+ type: 'Integer'
1383
+ },
1384
+ attr_c: {
1385
+ type: 'Text',
1386
+ value:
1387
+ 'text:' +
1388
+ globalEnv.service +
1389
+ globalEnv.servicePath +
1390
+ globalEnv.deviceId +
1391
+ globalEnv.entity_type
1392
+ },
1393
+ attr_d: {
1394
+ type: 'Float',
1395
+ value: 16.25
1396
+ },
1397
+ attr_e: {
1398
+ type: 'Array',
1399
+ value: [1, 2, 3, 4]
1400
+ },
1401
+ attr_f: {
1402
+ type: 'Object',
1403
+ value: { coordinates: [1, 2], type: 'Point' }
1404
+ }
1405
+ }
1406
+ }
1407
+ ]
1408
+ },
1409
+ {
1410
+ describeName:
1411
+ '0190 - Simple group with JEXL expression using static attribute - addressing structured values (JSON)',
1412
+ provision: {
1413
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
1414
+ method: 'POST',
1415
+ json: {
1416
+ services: [
1417
+ {
1418
+ resource: '/iot/json',
1419
+ apikey: globalEnv.apikey,
1420
+ entity_type: globalEnv.entity_type,
1421
+ commands: [],
1422
+ lazy: [],
1423
+ attributes: [
1424
+ {
1425
+ object_id: 'a',
1426
+ name: 'attr_a',
1427
+ type: 'Boolean',
1428
+ expression: 'a?threshold[90|tostring].max:true'
1429
+ }
1430
+ ],
1431
+ static_attributes: [
1432
+ {
1433
+ name: 'threshold',
1434
+ type: 'Object',
1435
+ value: {
1436
+ '90': { max: 10, min: 1 },
1437
+ '92': { max: 12, min: 2 },
1438
+ '93': { max: 13, min: 3 }
1439
+ }
1440
+ }
1441
+ ],
1442
+ explicitAttrs: "['attr_a']"
1443
+ }
1444
+ ]
1445
+ },
1446
+ headers: {
1447
+ 'fiware-service': globalEnv.service,
1448
+ 'fiware-servicepath': globalEnv.servicePath
1449
+ }
1450
+ },
1451
+ should: [
1452
+ {
1453
+ shouldName:
1454
+ 'A - WHEN sending a numeric value () through http IT should send to Context Broker the value true ',
1455
+ type: 'single',
1456
+ isRegex: true,
1457
+ measure: {
1458
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1459
+ method: 'POST',
1460
+ qs: {
1461
+ i: globalEnv.deviceId,
1462
+ k: globalEnv.apikey
1463
+ },
1464
+ json: {
1465
+ a: false
1466
+ }
1467
+ },
1468
+ expectation: {
1469
+ id: globalEnv.entity_name,
1470
+ type: globalEnv.entity_type,
1471
+ attr_a: {
1472
+ value: true,
1473
+ type: 'Boolean'
1474
+ }
1475
+ }
1476
+ }
1477
+ ]
1478
+ },
1479
+ // 0300 - STATIC ATTRIBUTES TESTS
1480
+ {
1481
+ describeName:
1482
+ '0300 - Simple group with active attributes + Static attributes + JEXL expression using static attribute value',
1483
+ provision: {
1484
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
1485
+ method: 'POST',
1486
+ json: {
1487
+ services: [
1488
+ {
1489
+ resource: '/iot/json',
1490
+ apikey: globalEnv.apikey,
1491
+ entity_type: globalEnv.entity_type,
1492
+ commands: [],
1493
+ lazy: [],
1494
+ attributes: [
1495
+ {
1496
+ object_id: 'a',
1497
+ name: 'attr_a',
1498
+ type: 'Number',
1499
+ expression: 'a*static_a'
1500
+ }
1501
+ ],
1502
+ static_attributes: [
1503
+ {
1504
+ name: 'static_a',
1505
+ type: 'Number',
1506
+ value: 3
1507
+ }
1508
+ ]
1509
+ }
1510
+ ]
1511
+ },
1512
+ headers: {
1513
+ 'fiware-service': globalEnv.service,
1514
+ 'fiware-servicepath': globalEnv.servicePath
1515
+ }
1516
+ },
1517
+ should: [
1518
+ {
1519
+ shouldName:
1520
+ 'A - WHEN sending not provisioned object_ids (measures) through http IT should store static attributes into Context Broker',
1521
+ type: 'single',
1522
+ measure: {
1523
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1524
+ method: 'POST',
1525
+ qs: {
1526
+ i: globalEnv.deviceId,
1527
+ k: globalEnv.apikey
1528
+ },
1529
+ json: {
1530
+ b: 10
1531
+ }
1532
+ },
1533
+ expectation: {
1534
+ id: globalEnv.entity_name,
1535
+ type: globalEnv.entity_type,
1536
+ b: {
1537
+ value: 10,
1538
+ type: 'string'
1539
+ },
1540
+ static_a: {
1541
+ value: 3,
1542
+ type: 'Number'
1543
+ }
1544
+ }
1545
+ },
1546
+ {
1547
+ shouldName:
1548
+ 'B - WHEN sending provisioned object_ids (measures) through http IT should store static attributes into Context Broker + calculate expression based on static',
1549
+ type: 'single',
1550
+ measure: {
1551
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1552
+ method: 'POST',
1553
+ qs: {
1554
+ i: globalEnv.deviceId,
1555
+ k: globalEnv.apikey
1556
+ },
1557
+ json: {
1558
+ a: 10
1559
+ }
1560
+ },
1561
+ expectation: {
1562
+ id: globalEnv.entity_name,
1563
+ type: globalEnv.entity_type,
1564
+ attr_a: {
1565
+ value: 30,
1566
+ type: 'Number'
1567
+ },
1568
+ static_a: {
1569
+ value: 3,
1570
+ type: 'Number'
1571
+ }
1572
+ }
1573
+ }
1574
+ ]
1575
+ },
1576
+ {
1577
+ describeName: '0310 - Simple group with active attributes + JSON value Static attributes ',
1578
+ provision: {
1579
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
1580
+ method: 'POST',
1581
+ json: {
1582
+ services: [
1583
+ {
1584
+ resource: '/iot/json',
1585
+ apikey: globalEnv.apikey,
1586
+ entity_type: globalEnv.entity_type,
1587
+ commands: [],
1588
+ lazy: [],
1589
+ attributes: [],
1590
+ static_attributes: [
1591
+ {
1592
+ name: 'static_a',
1593
+ type: 'Number',
1594
+ value: {
1595
+ v1: 1,
1596
+ v2: {
1597
+ v3: 3,
1598
+ v4: 4
1599
+ }
1600
+ }
1601
+ }
1602
+ ]
1603
+ }
1604
+ ]
1605
+ },
1606
+ headers: {
1607
+ 'fiware-service': globalEnv.service,
1608
+ 'fiware-servicepath': globalEnv.servicePath
1609
+ }
1610
+ },
1611
+ should: [
1612
+ {
1613
+ shouldName:
1614
+ 'A - WHEN sending measures through http IT should store complex static attributes into Context Broker',
1615
+ type: 'single',
1616
+ measure: {
1617
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1618
+ method: 'POST',
1619
+ qs: {
1620
+ i: globalEnv.deviceId,
1621
+ k: globalEnv.apikey
1622
+ },
1623
+ json: {
1624
+ a: 10
1625
+ }
1626
+ },
1627
+ expectation: {
1628
+ id: globalEnv.entity_name,
1629
+ type: globalEnv.entity_type,
1630
+ a: {
1631
+ value: 10,
1632
+ type: 'string'
1633
+ },
1634
+ static_a: {
1635
+ value: {
1636
+ v1: 1,
1637
+ v2: {
1638
+ v3: 3,
1639
+ v4: 4
1640
+ }
1641
+ },
1642
+ type: 'Number'
1643
+ }
1644
+ }
1645
+ }
1646
+ ]
1647
+ },
1648
+ // 0400 - TIMESTAMP TESTS
1649
+ {
1650
+ describeName: '0400 - Simple group with active attribute + timestamp:false',
1651
+ provision: {
1652
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
1653
+ method: 'POST',
1654
+ json: {
1655
+ services: [
1656
+ {
1657
+ resource: '/iot/json',
1658
+ apikey: globalEnv.apikey,
1659
+ entity_type: globalEnv.entity_type,
1660
+ timestamp: false,
1661
+ commands: [],
1662
+ lazy: [],
1663
+ attributes: [
1664
+ {
1665
+ object_id: 'a',
1666
+ name: 'attr_a',
1667
+ type: 'Number'
1668
+ }
1669
+ ]
1670
+ }
1671
+ ]
1672
+ },
1673
+ headers: {
1674
+ 'fiware-service': globalEnv.service,
1675
+ 'fiware-servicepath': globalEnv.servicePath
1676
+ }
1677
+ },
1678
+ should: [
1679
+ {
1680
+ shouldName:
1681
+ 'A - WHEN sending a measure not named TimeInstant through http IT should not add the timestamp to the attributes sent to Context Broker',
1682
+ type: 'single',
1683
+ measure: {
1684
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1685
+ method: 'POST',
1686
+ qs: {
1687
+ i: globalEnv.deviceId,
1688
+ k: globalEnv.apikey
1689
+ },
1690
+ json: {
1691
+ a: 23
1692
+ }
1693
+ },
1694
+ expectation: {
1695
+ id: globalEnv.entity_name,
1696
+ type: globalEnv.entity_type,
1697
+ attr_a: {
1698
+ value: 23,
1699
+ type: 'Number'
1700
+ }
1701
+ }
1702
+ },
1703
+ {
1704
+ shouldName:
1705
+ 'B - WHEN sending a measure named TimeInstant through http IT should not add the timestamp to the other attributes sent to Context Broker',
1706
+ type: 'single',
1707
+ measure: {
1708
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1709
+ method: 'POST',
1710
+ qs: {
1711
+ i: globalEnv.deviceId,
1712
+ k: globalEnv.apikey
1713
+ },
1714
+ json: {
1715
+ TimeInstant: '2015-12-14T08:06:01.468Z',
1716
+ a: 23
1717
+ }
1718
+ },
1719
+ expectation: {
1720
+ id: globalEnv.entity_name,
1721
+ type: globalEnv.entity_type,
1722
+ attr_a: {
1723
+ value: 23,
1724
+ type: 'Number'
1725
+ },
1726
+ TimeInstant: {
1727
+ value: '2015-12-14T08:06:01.468Z',
1728
+ type: 'DateTime'
1729
+ }
1730
+ }
1731
+ }
1732
+ ]
1733
+ },
1734
+ {
1735
+ describeName: '0410 - Simple group with active attribute + timestamp:true',
1736
+ provision: {
1737
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
1738
+ method: 'POST',
1739
+ json: {
1740
+ services: [
1741
+ {
1742
+ resource: '/iot/json',
1743
+ apikey: globalEnv.apikey,
1744
+ entity_type: globalEnv.entity_type,
1745
+ timestamp: true,
1746
+ commands: [],
1747
+ lazy: [],
1748
+ attributes: [
1749
+ {
1750
+ object_id: 'a',
1751
+ name: 'attr_a',
1752
+ type: 'Number'
1753
+ }
1754
+ ]
1755
+ }
1756
+ ]
1757
+ },
1758
+ headers: {
1759
+ 'fiware-service': globalEnv.service,
1760
+ 'fiware-servicepath': globalEnv.servicePath
1761
+ }
1762
+ },
1763
+ should: [
1764
+ {
1765
+ shouldName:
1766
+ 'A - WHEN sending a measure not named TimeInstant through http IT should add the timestamp to the attributes sent to Context Broker',
1767
+ type: 'single',
1768
+ isRegex: true,
1769
+ measure: {
1770
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1771
+ method: 'POST',
1772
+ qs: {
1773
+ i: globalEnv.deviceId,
1774
+ k: globalEnv.apikey
1775
+ },
1776
+ json: {
1777
+ a: 21
1778
+ }
1779
+ },
1780
+ expectation: {
1781
+ id: globalEnv.entity_name,
1782
+ type: globalEnv.entity_type,
1783
+ attr_a: {
1784
+ value: 21,
1785
+ type: 'Number',
1786
+ metadata: {
1787
+ TimeInstant: {
1788
+ type: 'DateTime',
1789
+ value: _.isDateString
1790
+ }
1791
+ }
1792
+ },
1793
+ TimeInstant: {
1794
+ type: 'DateTime',
1795
+ value: _.isDateString
1796
+ }
1797
+ }
1798
+ },
1799
+ {
1800
+ shouldName:
1801
+ 'B - WHEN sending a measure named TimeInstant through http IT should not add the timestamp to the other attributes sent to Context Broker',
1802
+ type: 'single',
1803
+ measure: {
1804
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1805
+ method: 'POST',
1806
+ qs: {
1807
+ i: globalEnv.deviceId,
1808
+ k: globalEnv.apikey
1809
+ },
1810
+ json: {
1811
+ TimeInstant: '2015-12-14T08:06:01.468Z',
1812
+ a: 23
1813
+ }
1814
+ },
1815
+ expectation: {
1816
+ id: globalEnv.entity_name,
1817
+ type: globalEnv.entity_type,
1818
+ attr_a: {
1819
+ value: 23,
1820
+ type: 'Number',
1821
+ metadata: {
1822
+ TimeInstant: {
1823
+ type: 'DateTime',
1824
+ value: '2015-12-14T08:06:01.468Z'
1825
+ }
1826
+ }
1827
+ },
1828
+ TimeInstant: {
1829
+ value: '2015-12-14T08:06:01.468Z',
1830
+ type: 'DateTime'
1831
+ }
1832
+ }
1833
+ }
1834
+ ]
1835
+ },
1836
+ {
1837
+ describeName: '0420 - Simple group with active attribute + timestamp not defined',
1838
+ provision: {
1839
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
1840
+ method: 'POST',
1841
+ json: {
1842
+ services: [
1843
+ {
1844
+ resource: '/iot/json',
1845
+ apikey: globalEnv.apikey,
1846
+ entity_type: globalEnv.entity_type,
1847
+ commands: [],
1848
+ lazy: [],
1849
+ attributes: [
1850
+ {
1851
+ object_id: 'a',
1852
+ name: 'attr_a',
1853
+ type: 'Number'
1854
+ }
1855
+ ]
1856
+ }
1857
+ ]
1858
+ },
1859
+ headers: {
1860
+ 'fiware-service': globalEnv.service,
1861
+ 'fiware-servicepath': globalEnv.servicePath
1862
+ }
1863
+ },
1864
+ should: [
1865
+ {
1866
+ shouldName:
1867
+ 'A - WHEN sending a measure not named TimeInstant through http IT should not add the timestamp to the attributes or metadata sent to Context Broker',
1868
+ type: 'single',
1869
+ measure: {
1870
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1871
+ method: 'POST',
1872
+ qs: {
1873
+ i: globalEnv.deviceId,
1874
+ k: globalEnv.apikey
1875
+ },
1876
+ json: {
1877
+ a: 21
1878
+ }
1879
+ },
1880
+ expectation: {
1881
+ id: globalEnv.entity_name,
1882
+ type: globalEnv.entity_type,
1883
+ attr_a: {
1884
+ value: 21,
1885
+ type: 'Number'
1886
+ }
1887
+ }
1888
+ },
1889
+ {
1890
+ shouldName:
1891
+ 'B - WHEN sending a measure named TimeInstant through http IT should not add the timestamp to the other attributes sent to Context Broker',
1892
+ type: 'single',
1893
+ measure: {
1894
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1895
+ method: 'POST',
1896
+ qs: {
1897
+ i: globalEnv.deviceId,
1898
+ k: globalEnv.apikey
1899
+ },
1900
+ json: {
1901
+ TimeInstant: '2015-12-14T08:06:01.468Z',
1902
+ a: 23
1903
+ }
1904
+ },
1905
+ expectation: {
1906
+ id: globalEnv.entity_name,
1907
+ type: globalEnv.entity_type,
1908
+ attr_a: {
1909
+ value: 23,
1910
+ type: 'Number'
1911
+ },
1912
+ TimeInstant: {
1913
+ value: '2015-12-14T08:06:01.468Z',
1914
+ type: 'DateTime'
1915
+ }
1916
+ }
1917
+ }
1918
+ ]
1919
+ },
1920
+ // 0500 - EXPLICIT ATTRIBUTES TESTS
1921
+ {
1922
+ describeName: '0500 - Group with explicit attrs:false (boolean) + active atributes',
1923
+ provision: {
1924
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
1925
+ method: 'POST',
1926
+ json: {
1927
+ services: [
1928
+ {
1929
+ resource: '/iot/json',
1930
+ apikey: globalEnv.apikey,
1931
+ entity_type: globalEnv.entity_type,
1932
+ explicitAttrs: false,
1933
+ commands: [],
1934
+ lazy: [],
1935
+ attributes: [
1936
+ {
1937
+ object_id: 'a',
1938
+ name: 'attr_a',
1939
+ type: 'Number'
1940
+ }
1941
+ ],
1942
+ static_attributes: []
1943
+ }
1944
+ ]
1945
+ },
1946
+ headers: {
1947
+ 'fiware-service': globalEnv.service,
1948
+ 'fiware-servicepath': globalEnv.servicePath
1949
+ }
1950
+ },
1951
+ should: [
1952
+ {
1953
+ shouldName:
1954
+ 'A - WHEN sending both provisioned and not object_ids (measures) through http IT should store all attributes into Context Broker',
1955
+ type: 'single',
1956
+ measure: {
1957
+ url: 'http://localhost:' + config.http.port + '/iot/json',
1958
+ method: 'POST',
1959
+ qs: {
1960
+ i: globalEnv.deviceId,
1961
+ k: globalEnv.apikey
1962
+ },
1963
+ json: {
1964
+ a: 3,
1965
+ b: 10
1966
+ }
1967
+ },
1968
+ expectation: {
1969
+ id: globalEnv.entity_name,
1970
+ type: globalEnv.entity_type,
1971
+ b: {
1972
+ value: 10,
1973
+ type: 'string'
1974
+ },
1975
+ attr_a: {
1976
+ value: 3,
1977
+ type: 'Number'
1978
+ }
1979
+ }
1980
+ }
1981
+ ]
1982
+ },
1983
+ {
1984
+ describeName: '0510 - Group without explicit (not defined) + active atributes',
1985
+ provision: {
1986
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
1987
+ method: 'POST',
1988
+ json: {
1989
+ services: [
1990
+ {
1991
+ resource: '/iot/json',
1992
+ apikey: globalEnv.apikey,
1993
+ entity_type: globalEnv.entity_type,
1994
+ commands: [],
1995
+ lazy: [],
1996
+ attributes: [
1997
+ {
1998
+ object_id: 'a',
1999
+ name: 'attr_a',
2000
+ type: 'Number'
2001
+ }
2002
+ ],
2003
+ static_attributes: []
2004
+ }
2005
+ ]
2006
+ },
2007
+ headers: {
2008
+ 'fiware-service': globalEnv.service,
2009
+ 'fiware-servicepath': globalEnv.servicePath
2010
+ }
2011
+ },
2012
+ should: [
2013
+ {
2014
+ shouldName:
2015
+ 'A - WHEN sending both provisioned and not object_ids (measures) through http IT should store all attributes into Context Broker',
2016
+ type: 'single',
2017
+ measure: {
2018
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2019
+ method: 'POST',
2020
+ qs: {
2021
+ i: globalEnv.deviceId,
2022
+ k: globalEnv.apikey
2023
+ },
2024
+ json: {
2025
+ a: 3,
2026
+ b: 10
2027
+ }
2028
+ },
2029
+ expectation: {
2030
+ id: globalEnv.entity_name,
2031
+ type: globalEnv.entity_type,
2032
+ b: {
2033
+ value: 10,
2034
+ type: 'string'
2035
+ },
2036
+ attr_a: {
2037
+ value: 3,
2038
+ type: 'Number'
2039
+ }
2040
+ }
2041
+ }
2042
+ ]
2043
+ },
2044
+ {
2045
+ describeName: '0520 - Group with explicit attrs:true (boolean) + active atributes',
2046
+ provision: {
2047
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
2048
+ method: 'POST',
2049
+ json: {
2050
+ services: [
2051
+ {
2052
+ resource: '/iot/json',
2053
+ apikey: globalEnv.apikey,
2054
+ entity_type: globalEnv.entity_type,
2055
+ explicitAttrs: true,
2056
+ commands: [],
2057
+ lazy: [],
2058
+ attributes: [
2059
+ {
2060
+ object_id: 'a',
2061
+ name: 'attr_a',
2062
+ type: 'Number'
2063
+ }
2064
+ ],
2065
+ static_attributes: []
2066
+ }
2067
+ ]
2068
+ },
2069
+ headers: {
2070
+ 'fiware-service': globalEnv.service,
2071
+ 'fiware-servicepath': globalEnv.servicePath
2072
+ }
2073
+ },
2074
+ should: [
2075
+ {
2076
+ shouldName:
2077
+ 'A - WHEN sending both provisioned and not object_ids (measures) through http IT should store all attributes into Context Broker',
2078
+ type: 'single',
2079
+ measure: {
2080
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2081
+ method: 'POST',
2082
+ qs: {
2083
+ i: globalEnv.deviceId,
2084
+ k: globalEnv.apikey
2085
+ },
2086
+ json: {
2087
+ a: 3,
2088
+ b: 10
2089
+ }
2090
+ },
2091
+ expectation: {
2092
+ id: globalEnv.entity_name,
2093
+ type: globalEnv.entity_type,
2094
+ attr_a: {
2095
+ value: 3,
2096
+ type: 'Number'
2097
+ }
2098
+ }
2099
+ }
2100
+ ]
2101
+ },
2102
+ {
2103
+ describeName: '0530 - Group with explicit attrs:[array] + active attributes + static attributes',
2104
+ provision: {
2105
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
2106
+ method: 'POST',
2107
+ json: {
2108
+ services: [
2109
+ {
2110
+ resource: '/iot/json',
2111
+ apikey: globalEnv.apikey,
2112
+ entity_type: globalEnv.entity_type,
2113
+ explicitAttrs: "['attr_a','static_a']",
2114
+ commands: [],
2115
+ lazy: [],
2116
+ attributes: [
2117
+ {
2118
+ name: 'attr_a',
2119
+ object_id: 'a',
2120
+ type: 'Number'
2121
+ },
2122
+ {
2123
+ name: 'attr_b',
2124
+ object_id: 'b',
2125
+ type: 'Number'
2126
+ }
2127
+ ],
2128
+ static_attributes: [
2129
+ {
2130
+ name: 'static_a',
2131
+ type: 'Number',
2132
+ value: 3
2133
+ },
2134
+ {
2135
+ name: 'static_b',
2136
+ type: 'Number',
2137
+ value: 4
2138
+ }
2139
+ ]
2140
+ }
2141
+ ]
2142
+ },
2143
+ headers: {
2144
+ 'fiware-service': globalEnv.service,
2145
+ 'fiware-servicepath': globalEnv.servicePath
2146
+ }
2147
+ },
2148
+ should: [
2149
+ {
2150
+ shouldName:
2151
+ 'A - WHEN sending both provisioned and not object_ids (measures) through http IT should store only defined in explicitAttrs array into Context Broker',
2152
+ type: 'single',
2153
+ measure: {
2154
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2155
+ method: 'POST',
2156
+ qs: {
2157
+ i: globalEnv.deviceId,
2158
+ k: globalEnv.apikey
2159
+ },
2160
+ json: {
2161
+ a: 3,
2162
+ b: 10,
2163
+ c: 11
2164
+ }
2165
+ },
2166
+ expectation: {
2167
+ id: globalEnv.entity_name,
2168
+ type: globalEnv.entity_type,
2169
+ attr_a: {
2170
+ value: 3,
2171
+ type: 'Number'
2172
+ },
2173
+ static_a: {
2174
+ value: 3,
2175
+ type: 'Number'
2176
+ }
2177
+ }
2178
+ }
2179
+ ]
2180
+ },
2181
+ {
2182
+ describeName:
2183
+ '0540 - Group with explicit attrs: JEXL expression based on measure resulting boolean + active attributes + static attributes',
2184
+ provision: {
2185
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
2186
+ method: 'POST',
2187
+ json: {
2188
+ services: [
2189
+ {
2190
+ resource: '/iot/json',
2191
+ apikey: globalEnv.apikey,
2192
+ entity_type: globalEnv.entity_type,
2193
+ explicitAttrs: 'c?true:false',
2194
+ commands: [],
2195
+ lazy: [],
2196
+ attributes: [
2197
+ {
2198
+ name: 'attr_a',
2199
+ object_id: 'a',
2200
+ type: 'Number'
2201
+ },
2202
+ {
2203
+ name: 'attr_b',
2204
+ object_id: 'b',
2205
+ type: 'Number'
2206
+ }
2207
+ ],
2208
+ static_attributes: [
2209
+ {
2210
+ name: 'static_a',
2211
+ type: 'Number',
2212
+ value: 3
2213
+ },
2214
+ {
2215
+ name: 'static_b',
2216
+ type: 'Number',
2217
+ value: 4
2218
+ }
2219
+ ]
2220
+ }
2221
+ ]
2222
+ },
2223
+ headers: {
2224
+ 'fiware-service': globalEnv.service,
2225
+ 'fiware-servicepath': globalEnv.servicePath
2226
+ }
2227
+ },
2228
+ should: [
2229
+ {
2230
+ shouldName:
2231
+ 'A - WHEN sending both provisioned and not object_ids (measures) through http and being the explicitAttrs JEXL result true IT should store only explicit attrs into Context Broker',
2232
+ type: 'single',
2233
+ measure: {
2234
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2235
+ method: 'POST',
2236
+ qs: {
2237
+ i: globalEnv.deviceId,
2238
+ k: globalEnv.apikey
2239
+ },
2240
+ json: {
2241
+ a: 3,
2242
+ b: 10,
2243
+ c: 11,
2244
+ d: 12
2245
+ }
2246
+ },
2247
+ expectation: {
2248
+ id: globalEnv.entity_name,
2249
+ type: globalEnv.entity_type,
2250
+ attr_a: {
2251
+ value: 3,
2252
+ type: 'Number'
2253
+ },
2254
+ attr_b: {
2255
+ value: 10,
2256
+ type: 'Number'
2257
+ },
2258
+ static_a: {
2259
+ value: 3,
2260
+ type: 'Number'
2261
+ },
2262
+ static_b: {
2263
+ value: 4,
2264
+ type: 'Number'
2265
+ }
2266
+ }
2267
+ },
2268
+ {
2269
+ shouldName:
2270
+ 'A - WHEN sending both provisioned and not object_ids (measures) through http and being the explicitAttrs JEXL result false IT should store all attrs into Context Broker',
2271
+ type: 'single',
2272
+ measure: {
2273
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2274
+ method: 'POST',
2275
+ qs: {
2276
+ i: globalEnv.deviceId,
2277
+ k: globalEnv.apikey
2278
+ },
2279
+ json: {
2280
+ a: 3,
2281
+ b: 10,
2282
+ d: 12
2283
+ }
2284
+ },
2285
+ expectation: {
2286
+ id: globalEnv.entity_name,
2287
+ type: globalEnv.entity_type,
2288
+ attr_a: {
2289
+ value: 3,
2290
+ type: 'Number'
2291
+ },
2292
+ attr_b: {
2293
+ value: 10,
2294
+ type: 'Number'
2295
+ },
2296
+ d: {
2297
+ value: 12,
2298
+ type: 'string'
2299
+ },
2300
+ static_a: {
2301
+ value: 3,
2302
+ type: 'Number'
2303
+ },
2304
+ static_b: {
2305
+ value: 4,
2306
+ type: 'Number'
2307
+ }
2308
+ }
2309
+ }
2310
+ ]
2311
+ },
2312
+ {
2313
+ describeName:
2314
+ '0550 - Group with explicit attrs: JEXL expression based on measure resulting an array + active attributes + static attributes',
2315
+ provision: {
2316
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
2317
+ method: 'POST',
2318
+ json: {
2319
+ services: [
2320
+ {
2321
+ resource: '/iot/json',
2322
+ apikey: globalEnv.apikey,
2323
+ entity_type: globalEnv.entity_type,
2324
+ explicitAttrs:
2325
+ "(a&&b)?['attr_a','attr_b']:a?['attr_a','static_b']:b?[{object_id:'b'},'c']:['static_a','static_b','d','c']",
2326
+ commands: [],
2327
+ lazy: [],
2328
+ attributes: [
2329
+ {
2330
+ name: 'attr_a',
2331
+ object_id: 'a',
2332
+ type: 'Number'
2333
+ },
2334
+ {
2335
+ name: 'attr_b',
2336
+ object_id: 'b',
2337
+ type: 'Number'
2338
+ },
2339
+ {
2340
+ object_id: 'c',
2341
+ type: 'Number'
2342
+ }
2343
+ ],
2344
+ static_attributes: [
2345
+ {
2346
+ name: 'static_a',
2347
+ type: 'Number',
2348
+ value: 3
2349
+ },
2350
+ {
2351
+ name: 'static_b',
2352
+ type: 'Number',
2353
+ value: 4
2354
+ }
2355
+ ]
2356
+ }
2357
+ ]
2358
+ },
2359
+ headers: {
2360
+ 'fiware-service': globalEnv.service,
2361
+ 'fiware-servicepath': globalEnv.servicePath
2362
+ }
2363
+ },
2364
+ should: [
2365
+ {
2366
+ shouldName: 'A - WHEN sending (a&&b) IT should store only [attr_a,attr_b] attrs into Context Broker',
2367
+ type: 'single',
2368
+ measure: {
2369
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2370
+ method: 'POST',
2371
+ qs: {
2372
+ i: globalEnv.deviceId,
2373
+ k: globalEnv.apikey
2374
+ },
2375
+ json: {
2376
+ a: 1,
2377
+ b: 2,
2378
+ c: 3,
2379
+ d: 4
2380
+ }
2381
+ },
2382
+ expectation: {
2383
+ id: globalEnv.entity_name,
2384
+ type: globalEnv.entity_type,
2385
+ attr_a: {
2386
+ value: 1,
2387
+ type: 'Number'
2388
+ },
2389
+ attr_b: {
2390
+ value: 2,
2391
+ type: 'Number'
2392
+ }
2393
+ }
2394
+ },
2395
+ {
2396
+ shouldName: 'B - WHEN sending only a IT should store only [attr_a,static_b] attrs into Context Broker',
2397
+ type: 'single',
2398
+ measure: {
2399
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2400
+ method: 'POST',
2401
+ qs: {
2402
+ i: globalEnv.deviceId,
2403
+ k: globalEnv.apikey
2404
+ },
2405
+ json: {
2406
+ a: 1,
2407
+ c: 3,
2408
+ d: 4
2409
+ }
2410
+ },
2411
+ expectation: {
2412
+ id: globalEnv.entity_name,
2413
+ type: globalEnv.entity_type,
2414
+ attr_a: {
2415
+ value: 1,
2416
+ type: 'Number'
2417
+ },
2418
+ static_b: {
2419
+ value: 4,
2420
+ type: 'Number'
2421
+ }
2422
+ }
2423
+ },
2424
+ {
2425
+ shouldName: 'C - WHEN sending only b IT should store only [{object_id:b}] attrs into Context Broker',
2426
+ type: 'single',
2427
+ measure: {
2428
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2429
+ method: 'POST',
2430
+ qs: {
2431
+ i: globalEnv.deviceId,
2432
+ k: globalEnv.apikey
2433
+ },
2434
+ json: {
2435
+ b: 2,
2436
+ c: 3,
2437
+ d: 4
2438
+ }
2439
+ },
2440
+ expectation: {
2441
+ id: globalEnv.entity_name,
2442
+ type: globalEnv.entity_type,
2443
+ attr_b: {
2444
+ value: 2,
2445
+ type: 'Number'
2446
+ }
2447
+ }
2448
+ },
2449
+ {
2450
+ shouldName:
2451
+ 'D - WHEN no sending any defined case IT should store [static_a,static_b] attrs into Context Broker',
2452
+ type: 'single',
2453
+ measure: {
2454
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2455
+ method: 'POST',
2456
+ qs: {
2457
+ i: globalEnv.deviceId,
2458
+ k: globalEnv.apikey
2459
+ },
2460
+ json: {
2461
+ c: 3,
2462
+ d: 4
2463
+ }
2464
+ },
2465
+ expectation: {
2466
+ id: globalEnv.entity_name,
2467
+ type: globalEnv.entity_type,
2468
+ static_a: {
2469
+ value: 3,
2470
+ type: 'Number'
2471
+ },
2472
+ static_b: {
2473
+ value: 4,
2474
+ type: 'Number'
2475
+ }
2476
+ }
2477
+ }
2478
+ ]
2479
+ },
2480
+ // 0600 - MULTIENTITY TESTS
2481
+ {
2482
+ describeName: '0600 - Group multientity attrs',
2483
+ provision: {
2484
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
2485
+ method: 'POST',
2486
+ json: {
2487
+ services: [
2488
+ {
2489
+ resource: '/iot/json',
2490
+ apikey: globalEnv.apikey,
2491
+ entity_type: globalEnv.entity_type,
2492
+ commands: [],
2493
+ lazy: [],
2494
+ attributes: [
2495
+ {
2496
+ object_id: 's',
2497
+ name: 'status',
2498
+ type: 'Boolean'
2499
+ },
2500
+ {
2501
+ object_id: 't',
2502
+ name: 'temperature',
2503
+ type: 'Number',
2504
+ entity_name: 'TestType:TestDevice2',
2505
+ entity_type: 'TestType'
2506
+ }
2507
+ ],
2508
+ static_attributes: []
2509
+ }
2510
+ ]
2511
+ },
2512
+ headers: {
2513
+ 'fiware-service': globalEnv.service,
2514
+ 'fiware-servicepath': globalEnv.servicePath
2515
+ }
2516
+ },
2517
+ should: [
2518
+ {
2519
+ shouldName:
2520
+ 'A - WHEN sending provisioned object_ids (measures) through http IT should store both entities into Context Broker',
2521
+ type: 'multientity',
2522
+ measure: {
2523
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2524
+ method: 'POST',
2525
+ qs: {
2526
+ i: globalEnv.deviceId,
2527
+ k: globalEnv.apikey
2528
+ },
2529
+ json: {
2530
+ s: false,
2531
+ t: 10
2532
+ }
2533
+ },
2534
+ expectation: {
2535
+ entities: [
2536
+ {
2537
+ id: globalEnv.entity_name,
2538
+ type: globalEnv.entity_type,
2539
+ status: {
2540
+ value: false,
2541
+ type: 'Boolean'
2542
+ }
2543
+ },
2544
+ {
2545
+ id: 'TestType:TestDevice2',
2546
+ type: 'TestType',
2547
+ temperature: {
2548
+ value: 10,
2549
+ type: 'Number'
2550
+ }
2551
+ }
2552
+ ],
2553
+ actionType: 'append'
2554
+ }
2555
+ }
2556
+ ]
2557
+ },
2558
+ {
2559
+ describeName: '0610 - Group multientity attrs + value JEXL expression',
2560
+ provision: {
2561
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
2562
+ method: 'POST',
2563
+ json: {
2564
+ services: [
2565
+ {
2566
+ resource: '/iot/json',
2567
+ apikey: globalEnv.apikey,
2568
+ entity_type: globalEnv.entity_type,
2569
+ commands: [],
2570
+ lazy: [],
2571
+ attributes: [
2572
+ {
2573
+ object_id: 's',
2574
+ name: 'status',
2575
+ type: 'Boolean'
2576
+ },
2577
+ {
2578
+ object_id: 't',
2579
+ name: 'temperature',
2580
+ type: 'Number',
2581
+ entity_name: 'TestType:TestDevice2',
2582
+ entity_type: 'TestType',
2583
+ expression: 'type+":"+(t*2*static_a)' // Only type is used as JEXL context attr due to #1523
2584
+ }
2585
+ ],
2586
+ static_attributes: [
2587
+ {
2588
+ name: 'static_a',
2589
+ type: 'Number',
2590
+ value: 3
2591
+ }
2592
+ ]
2593
+ }
2594
+ ]
2595
+ },
2596
+ headers: {
2597
+ 'fiware-service': globalEnv.service,
2598
+ 'fiware-servicepath': globalEnv.servicePath
2599
+ }
2600
+ },
2601
+ should: [
2602
+ {
2603
+ shouldName:
2604
+ 'A - WHEN sending provisioned object_ids (measures) through http IT should store both entities into Context Broker',
2605
+ type: 'multientity',
2606
+ measure: {
2607
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2608
+ method: 'POST',
2609
+ qs: {
2610
+ i: globalEnv.deviceId,
2611
+ k: globalEnv.apikey
2612
+ },
2613
+ json: {
2614
+ s: false,
2615
+ t: 10
2616
+ }
2617
+ },
2618
+ expectation: {
2619
+ entities: [
2620
+ {
2621
+ id: globalEnv.entity_name,
2622
+ type: globalEnv.entity_type,
2623
+ status: {
2624
+ value: false,
2625
+ type: 'Boolean'
2626
+ },
2627
+ static_a: {
2628
+ value: 3,
2629
+ type: 'Number'
2630
+ }
2631
+ },
2632
+ {
2633
+ id: 'TestType:TestDevice2',
2634
+ type: 'TestType',
2635
+ temperature: {
2636
+ value: 'TestType:60',
2637
+ type: 'Number'
2638
+ }
2639
+ }
2640
+ ],
2641
+ actionType: 'append'
2642
+ }
2643
+ }
2644
+ ]
2645
+ },
2646
+ {
2647
+ describeName: '0620 - Group multientity attrs + multientity ID JEXL expression',
2648
+ provision: {
2649
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
2650
+ method: 'POST',
2651
+ json: {
2652
+ services: [
2653
+ {
2654
+ resource: '/iot/json',
2655
+ apikey: globalEnv.apikey,
2656
+ entity_type: globalEnv.entity_type,
2657
+ commands: [],
2658
+ lazy: [],
2659
+ attributes: [
2660
+ {
2661
+ object_id: 's',
2662
+ name: 'status',
2663
+ type: 'Boolean'
2664
+ },
2665
+ {
2666
+ object_id: 't',
2667
+ name: 'temperature',
2668
+ type: 'Number',
2669
+ entity_name: 'type+":"+(t*2*static_a)', // Only type is used as JEXL context attr due to #1523
2670
+ entity_type: 'TestType'
2671
+ }
2672
+ ],
2673
+ static_attributes: [
2674
+ {
2675
+ name: 'static_a',
2676
+ type: 'Number',
2677
+ value: 3
2678
+ }
2679
+ ]
2680
+ }
2681
+ ]
2682
+ },
2683
+ headers: {
2684
+ 'fiware-service': globalEnv.service,
2685
+ 'fiware-servicepath': globalEnv.servicePath
2686
+ }
2687
+ },
2688
+ should: [
2689
+ {
2690
+ shouldName:
2691
+ 'A - WHEN sending provisioned object_ids (measures) through http IT should store both entities into Context Broker',
2692
+ type: 'multientity',
2693
+ measure: {
2694
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2695
+ method: 'POST',
2696
+ qs: {
2697
+ i: globalEnv.deviceId,
2698
+ k: globalEnv.apikey
2699
+ },
2700
+ json: {
2701
+ s: false,
2702
+ t: 10
2703
+ }
2704
+ },
2705
+ expectation: {
2706
+ entities: [
2707
+ {
2708
+ id: globalEnv.entity_name,
2709
+ type: globalEnv.entity_type,
2710
+ status: {
2711
+ value: false,
2712
+ type: 'Boolean'
2713
+ },
2714
+ static_a: {
2715
+ value: 3,
2716
+ type: 'Number'
2717
+ }
2718
+ },
2719
+ {
2720
+ id: 'TestType:60',
2721
+ type: 'TestType',
2722
+ temperature: {
2723
+ value: 10,
2724
+ type: 'Number'
2725
+ }
2726
+ }
2727
+ ],
2728
+ actionType: 'append'
2729
+ }
2730
+ }
2731
+ ]
2732
+ },
2733
+ // 0700 - ENTITY NAME EXPRESSION TESTS
2734
+ {
2735
+ describeName: '0700 - Group JEXL entityNameExpression',
2736
+ provision: {
2737
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
2738
+ method: 'POST',
2739
+ json: {
2740
+ services: [
2741
+ {
2742
+ resource: '/iot/json',
2743
+ apikey: globalEnv.apikey,
2744
+ entity_type: globalEnv.entity_type,
2745
+ entityNameExp: 'type+":"+(t*2*static_a)',
2746
+ commands: [],
2747
+ lazy: [],
2748
+ attributes: [
2749
+ {
2750
+ object_id: 's',
2751
+ name: 'status',
2752
+ type: 'Boolean'
2753
+ },
2754
+ {
2755
+ object_id: 't',
2756
+ name: 'temperature',
2757
+ type: 'Number'
2758
+ }
2759
+ ],
2760
+ static_attributes: [
2761
+ {
2762
+ name: 'static_a',
2763
+ type: 'Number',
2764
+ value: 3
2765
+ }
2766
+ ]
2767
+ }
2768
+ ]
2769
+ },
2770
+ headers: {
2771
+ 'fiware-service': globalEnv.service,
2772
+ 'fiware-servicepath': globalEnv.servicePath
2773
+ }
2774
+ },
2775
+ should: [
2776
+ {
2777
+ shouldName:
2778
+ 'A - WHEN sending provisioned object_ids (measures) through http IT should store the entity with the expression generated ID into the Context Broker',
2779
+ measure: {
2780
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2781
+ method: 'POST',
2782
+ qs: {
2783
+ i: globalEnv.deviceId,
2784
+ k: globalEnv.apikey
2785
+ },
2786
+ json: {
2787
+ s: false,
2788
+ t: 10
2789
+ }
2790
+ },
2791
+ expectation: {
2792
+ id: 'TestType:60',
2793
+ type: globalEnv.entity_type,
2794
+ status: {
2795
+ value: false,
2796
+ type: 'Boolean'
2797
+ },
2798
+ temperature: {
2799
+ value: 10,
2800
+ type: 'Number'
2801
+ },
2802
+ static_a: {
2803
+ value: 3,
2804
+ type: 'Number'
2805
+ }
2806
+ }
2807
+ }
2808
+ ]
2809
+ },
2810
+ // 0700 - FULL GROUP TESTS
2811
+ // FIXME: APIKEY recognition is not working for lib, and it needs to be tested if works as it is in agents.
2812
+ // 0800 - SKIP VALUE
2813
+ {
2814
+ describeName: '0700 - skipValue test',
2815
+ provision: {
2816
+ url: 'http://localhost:' + config.iota.server.port + '/iot/services',
2817
+ method: 'POST',
2818
+ json: {
2819
+ services: [
2820
+ {
2821
+ resource: '/iot/json',
2822
+ apikey: globalEnv.apikey,
2823
+ entity_type: globalEnv.entity_type,
2824
+ commands: [],
2825
+ lazy: [],
2826
+ attributes: [
2827
+ {
2828
+ object_id: 'a',
2829
+ name: 'attr_a',
2830
+ type: 'Number',
2831
+ skipValue: null
2832
+ },
2833
+ {
2834
+ object_id: 'b',
2835
+ name: 'attr_b',
2836
+ type: 'Number',
2837
+ skipValue: 'skip',
2838
+ expression: '(b+static_a)>0?(b+static_a):"skip"'
2839
+ }
2840
+ ],
2841
+ static_attributes: [
2842
+ {
2843
+ name: 'static_a',
2844
+ type: 'Number',
2845
+ value: 3
2846
+ }
2847
+ ]
2848
+ }
2849
+ ]
2850
+ },
2851
+ headers: {
2852
+ 'fiware-service': globalEnv.service,
2853
+ 'fiware-servicepath': globalEnv.servicePath
2854
+ }
2855
+ },
2856
+ should: [
2857
+ {
2858
+ shouldName:
2859
+ 'A - WHEN not matching skip conditions IT should store the entity with all the values (attr_a, attr_b, static_a) into the Context Broker',
2860
+ measure: {
2861
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2862
+ method: 'POST',
2863
+ qs: {
2864
+ i: globalEnv.deviceId,
2865
+ k: globalEnv.apikey
2866
+ },
2867
+ json: {
2868
+ a: 3,
2869
+ b: 10
2870
+ }
2871
+ },
2872
+ expectation: {
2873
+ id: globalEnv.entity_name,
2874
+ type: globalEnv.entity_type,
2875
+ attr_a: {
2876
+ value: 3,
2877
+ type: 'Number'
2878
+ },
2879
+ attr_b: {
2880
+ value: 13,
2881
+ type: 'Number'
2882
+ },
2883
+ static_a: {
2884
+ value: 3,
2885
+ type: 'Number'
2886
+ }
2887
+ }
2888
+ },
2889
+ {
2890
+ shouldName:
2891
+ 'B - WHEN matching skip conditions for attr_b IT should store the entity with some of the values (attr_a, static_a) into the Context Broker',
2892
+ measure: {
2893
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2894
+ method: 'POST',
2895
+ qs: {
2896
+ i: globalEnv.deviceId,
2897
+ k: globalEnv.apikey
2898
+ },
2899
+ json: {
2900
+ a: 3,
2901
+ b: -10
2902
+ }
2903
+ },
2904
+ expectation: {
2905
+ id: globalEnv.entity_name,
2906
+ type: globalEnv.entity_type,
2907
+ attr_a: {
2908
+ value: 3,
2909
+ type: 'Number'
2910
+ },
2911
+ static_a: {
2912
+ value: 3,
2913
+ type: 'Number'
2914
+ }
2915
+ }
2916
+ },
2917
+ {
2918
+ shouldName:
2919
+ 'C - WHEN matching skip conditions for attr_a and attr_b (expression result) IT should store the entity with only some of the values (static_a) into the Context Broker',
2920
+ measure: {
2921
+ url: 'http://localhost:' + config.http.port + '/iot/json',
2922
+ method: 'POST',
2923
+ qs: {
2924
+ i: globalEnv.deviceId,
2925
+ k: globalEnv.apikey
2926
+ },
2927
+ json: {
2928
+ b: -10
2929
+ }
2930
+ },
2931
+ expectation: {
2932
+ id: globalEnv.entity_name,
2933
+ type: globalEnv.entity_type,
2934
+ static_a: {
2935
+ value: 3,
2936
+ type: 'Number'
2937
+ }
2938
+ }
2939
+ }
2940
+ ]
2941
+ }
2942
+ ];
2943
+
2944
+ exports.testCases = testCases;