iotagent-node-lib 4.5.0 → 4.6.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.
- package/README.md +67 -272
- package/doc/README.md +1 -1
- package/doc/admin.md +3 -15
- package/doc/api.md +469 -134
- package/doc/deprecated.md +4 -0
- package/doc/devel/architecture.md +5 -135
- package/doc/devel/development.md +224 -12
- package/doc/getting-started.md +114 -53
- package/doc/roadmap.md +5 -5
- package/docker/Mosquitto/Dockerfile +2 -2
- package/docker/Mosquitto/README.md +14 -11
- package/lib/constants.js +3 -0
- package/lib/fiware-iotagent-lib.js +12 -15
- package/lib/jexlTranformsMap.js +3 -1
- package/lib/model/dbConn.js +1 -4
- package/lib/services/common/alarmManagement.js +3 -0
- package/lib/services/groups/groupService.js +1 -1
- package/lib/services/ngsi/entities-NGSI-LD.js +320 -570
- package/lib/services/ngsi/entities-NGSI-v2.js +36 -1
- package/lib/services/ngsi/ngsiService.js +3 -1
- package/lib/services/northBound/deviceGroupAdministrationServer.js +42 -6
- package/lib/services/northBound/deviceProvisioningServer.js +0 -1
- package/lib/services/northBound/northboundServer.js +2 -0
- package/lib/services/stats/statsRegistry.js +128 -101
- package/lib/templates/createDevice.json +0 -24
- package/lib/templates/createDeviceLax.json +0 -23
- package/lib/templates/deviceGroup.json +1 -25
- package/lib/templates/updateDevice.json +0 -24
- package/lib/templates/updateDeviceLax.json +0 -23
- package/package.json +2 -2
- package/scripts/legacy_expression_tool/README.md +0 -1
- package/test/functional/README.md +22 -17
- package/test/functional/functional-tests-runner.js +9 -4
- package/test/functional/functional-tests.js +4 -4
- package/test/functional/testCases.js +245 -4
- package/test/unit/examples/deviceProvisioningRequests/provisionFullDevice.json +1 -13
- package/test/unit/examples/groupProvisioningRequests/multipleConfigGroupsCreation.json +44 -0
- package/test/unit/examples/groupProvisioningRequests/provisionDuplicateConfigGroup.json +35 -0
- package/test/unit/examples/groupProvisioningRequests/provisionFullConfigGroup.json +36 -0
- package/test/unit/examples/groupProvisioningRequests/provisionFullConfigGroupAlternate.json +36 -0
- package/test/unit/general/deviceService-test.js +102 -0
- package/test/unit/general/statistics-service_test.js +1 -74
- package/test/unit/mongodb/mongodb-configGroup-registry-test.js +452 -0
- package/test/unit/mongodb/mongodb-connectionoptions-test.js +2 -3
- package/test/unit/mongodb/mongodb-group-registry-test.js +34 -33
- package/test/unit/mongodb/mongodb-service-registry-test.js +477 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin1a.json +4 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin2.json +22 -22
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin29.json +4 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +14 -15
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin1.json +23 -23
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin15.json +0 -5
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin4.json +11 -16
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin5.json +23 -28
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin6.json +8 -13
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin7.json +0 -5
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin8.json +24 -29
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +12 -17
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextStaticLinkedAttributes.json +12 -10
- package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +0 -102
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +4 -5
- package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +0 -4
- package/test/unit/ngsiv2/general/deviceService-test.js +94 -1
- package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +195 -0
- package/test/unit/ngsiv2/provisioning/device-group-api-test.js +259 -0
- package/test/unit/ngsiv2/provisioning/device-provisioning-configGroup-api_test.js +1189 -0
- package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +0 -4
- package/test/unit/statsRegistry/openmetrics-test.js +167 -0
- package/lib/templates/queryContext.json +0 -25
- package/test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json +0 -35
- package/test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json +0 -17
- package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +0 -31
- package/test/unit/general/statistics-persistence_test.js +0 -121
- package/test/unit/ngsi-ld/examples/contextRequests/createBidirectionalDevice.json +0 -17
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextProcessTimestamp.json +0 -12
- package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotification.json +0 -13
- package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotificationWithDatasetId.json +0 -21
- package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotificationWithMetadata.json +0 -17
- package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +0 -23
- package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +0 -132
- package/test/unit/ngsiv2/examples/contextRequests/createBidirectionalDevice.json +0 -8
- package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalNotification.json +0 -13
- package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalNotificationWithMetadata.json +0 -19
- package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +0 -24
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "iotagent-node-lib",
|
|
3
3
|
"license": "AGPL-3.0-only",
|
|
4
4
|
"description": "IoT Agent library to interface with NGSI Context Broker",
|
|
5
|
-
"version": "4.
|
|
5
|
+
"version": "4.6.0",
|
|
6
6
|
"homepage": "https://github.com/telefonicaid/iotagent-node-lib",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"fiware",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"async": "2.6.4",
|
|
47
|
-
"body-parser": "~1.20.
|
|
47
|
+
"body-parser": "~1.20.3",
|
|
48
48
|
"express": "~4.19.2",
|
|
49
49
|
"got": "~11.8.5",
|
|
50
50
|
"jexl": "2.3.0",
|
|
@@ -21,8 +21,10 @@ pattern than the one supported by the test runner).
|
|
|
21
21
|
Each test case is defined as a JSON object in the `testCases.js` file. This file is loaded by the test suite and the
|
|
22
22
|
test cases are automatically generated. Each test case is defined as an object with the following elements:
|
|
23
23
|
|
|
24
|
-
- `describeName`: The name of the `DESCRIBE` test case. This will be used to generate the test case name in the mocha.
|
|
25
|
-
|
|
24
|
+
- `describeName`: The name of the `DESCRIBE` test case. This will be used to generate the test case name in the mocha.
|
|
25
|
+
Note this name is prefixed by a pure number (e.g `0010 - Simple group without attributes`) which specifies the group
|
|
26
|
+
to which the test belong (usually meaning a feature) or by a number preced by the `#` symbol to refer to an issue
|
|
27
|
+
number (e.g. `#1234 - Bug foobar`). test suite.
|
|
26
28
|
- `provision`: The JSON object that will be sent to the IoTA JSON provisioning API. This will be used to create the
|
|
27
29
|
group. It contains the following elements:
|
|
28
30
|
- `url`: The URL of the provisioning API (group)
|
|
@@ -30,17 +32,19 @@ test cases are automatically generated. Each test case is defined as an object w
|
|
|
30
32
|
- `json`: The JSON object that defines the group
|
|
31
33
|
- `headers`: The headers to send to the provisioning API. This should contain the `fiware-service` and
|
|
32
34
|
`fiware-servicepath` headers.
|
|
33
|
-
- `skip`: optional. Allow to skip test cases (at `describe` level). It allows diferent values: `false` (default,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
- `skip`: optional. Allow to skip test cases (at `describe` level). It allows diferent values: `false` (default,
|
|
36
|
+
meaning that the test is not skipped in any circustance), `true` (meaning the test is always skipped), `"lib"`
|
|
37
|
+
(meaning the test has to be skipped when running it in IoTA Node lib repo) and `"json"` (meaning the test has to
|
|
38
|
+
be skipped when running it in IOTA JSON repo). The latter alternatives are useful to skip test cases that are
|
|
39
|
+
not supported by the lib (I.E: all tests related to the transport) or by the IOTA. Combinations (e.g
|
|
40
|
+
`"lib,json"`) and negation (e.g. `"!lib"`) are also supported.
|
|
37
41
|
- `should`: The array of test cases to execute. Each test case is defined as an object with the following elements:
|
|
38
42
|
- `transport`: The transport to use to send the measure. This can be `HTTP` or `MQTT`. It uses `HTTP` by default
|
|
39
43
|
or if the `transport` element is not defined. See the "Advanced features" section for more information.
|
|
40
44
|
- `shouldName`: The name of the `IT` test case. This will be used to generate the test case name in the mocha test
|
|
41
45
|
suite.
|
|
42
|
-
- `type`: The type of the test case. This can be `single`, `multimeasure` or `multientity`. See the "Advanced
|
|
43
|
-
for more information.
|
|
46
|
+
- `type`: The type of the test case. This can be `single`, `multimeasure` or `multientity`. See the "Advanced
|
|
47
|
+
features" section for more information.
|
|
44
48
|
- `measure`: The JSON object that will be sent to the IoTA JSON measure API. This will be used to send the
|
|
45
49
|
measure. It contains the following elements:
|
|
46
50
|
- `url`: The URL of the measure API (group)
|
|
@@ -64,10 +68,10 @@ test cases are automatically generated. Each test case is defined as an object w
|
|
|
64
68
|
{
|
|
65
69
|
describeName: 'Basic group provision with attributes',
|
|
66
70
|
provision: {
|
|
67
|
-
url: 'http://localhost:' + config.iota.server.port + '/iot/
|
|
71
|
+
url: 'http://localhost:' + config.iota.server.port + '/iot/groups',
|
|
68
72
|
method: 'POST',
|
|
69
73
|
json: {
|
|
70
|
-
|
|
74
|
+
groups: [
|
|
71
75
|
{
|
|
72
76
|
resource: '/iot/json',
|
|
73
77
|
apikey: '123456',
|
|
@@ -199,11 +203,11 @@ as a batch operation (see the following example).
|
|
|
199
203
|
|
|
200
204
|
#### Multimeasures
|
|
201
205
|
|
|
202
|
-
It is also supported to test cases in which is sent more than one measure. To do so, you need to set add to the test
|
|
203
|
-
the parameter `should.type` to the value `'multimeasure'`.
|
|
206
|
+
It is also supported to test cases in which is sent more than one measure. To do so, you need to set add to the test
|
|
207
|
+
case the parameter `should.type` to the value `'multimeasure'`.
|
|
204
208
|
|
|
205
|
-
You must define the measure as multimeasure. This is done by defining the `measure` JSON element as an array of
|
|
206
|
-
|
|
209
|
+
You must define the measure as multimeasure. This is done by defining the `measure` JSON element as an array of objects.
|
|
210
|
+
I.E:
|
|
207
211
|
|
|
208
212
|
```javascript
|
|
209
213
|
measure: {
|
|
@@ -276,8 +280,8 @@ expectation: {
|
|
|
276
280
|
}
|
|
277
281
|
```
|
|
278
282
|
|
|
279
|
-
Then, a batch request would be sent to the Context Broker containing the different measures. More information about
|
|
280
|
-
|
|
283
|
+
Then, a batch request would be sent to the Context Broker containing the different measures. More information about how
|
|
284
|
+
the IoT Agent send multimeasures to the Context Broker [here](/doc/api.md#multimeasure-support).
|
|
281
285
|
|
|
282
286
|
#### Transport
|
|
283
287
|
|
|
@@ -332,7 +336,8 @@ the expectation as an empty object. I.E:
|
|
|
332
336
|
...
|
|
333
337
|
```
|
|
334
338
|
|
|
335
|
-
Note that this means the CB
|
|
339
|
+
Note that this means the CB _must not_ receive any payload. In other words, if the CB would receive any payload, the
|
|
340
|
+
test will fail.
|
|
336
341
|
|
|
337
342
|
### Debugging automated tests
|
|
338
343
|
|
|
@@ -63,12 +63,17 @@ describe('FUNCTIONAL TESTS AUTO', function () {
|
|
|
63
63
|
if (testCase.loglevel) {
|
|
64
64
|
logger.setLevel(testCase.loglevel);
|
|
65
65
|
}
|
|
66
|
-
let
|
|
66
|
+
let confType = testUtils.groupToIoTAConfigType(
|
|
67
67
|
testCase.provision.json.services[0],
|
|
68
|
-
testCase.provision.headers
|
|
69
|
-
testCase.provision.headers
|
|
68
|
+
testCase.provision.headers['fiware-service'],
|
|
69
|
+
testCase.provision.headers['fiware-servicepath']
|
|
70
70
|
);
|
|
71
|
-
config
|
|
71
|
+
// Inject device id into config as real typeInformation
|
|
72
|
+
if (testCase.should[0] && testCase.should[0].measure.qs.i) {
|
|
73
|
+
confType.type['id'] = testCase.should[0].measure.qs.i;
|
|
74
|
+
}
|
|
75
|
+
config.iota.types[confType.name] = confType.type;
|
|
76
|
+
|
|
72
77
|
iotAgentLib.activate(config.iota, function (error) {
|
|
73
78
|
done(error);
|
|
74
79
|
});
|
|
@@ -115,8 +115,8 @@ describe('FUNCTIONAL TESTS', function () {
|
|
|
115
115
|
beforeEach(function (done) {
|
|
116
116
|
let type = testUtils.groupToIoTAConfigType(
|
|
117
117
|
provision.json.services[0],
|
|
118
|
-
provision.headers
|
|
119
|
-
provision.headers
|
|
118
|
+
provision.headers['fiware-service'],
|
|
119
|
+
provision.headers['fiware-servicepath']
|
|
120
120
|
);
|
|
121
121
|
config.iota.types[type.name] = type.type;
|
|
122
122
|
iotAgentLib.activate(config.iota, function (error) {
|
|
@@ -214,8 +214,8 @@ describe('FUNCTIONAL TESTS', function () {
|
|
|
214
214
|
beforeEach(function (done) {
|
|
215
215
|
let type = testUtils.groupToIoTAConfigType(
|
|
216
216
|
provision.json.services[0],
|
|
217
|
-
provision.headers
|
|
218
|
-
provision.headers
|
|
217
|
+
provision.headers['fiware-service'],
|
|
218
|
+
provision.headers['fiware-servicepath']
|
|
219
219
|
);
|
|
220
220
|
config.iota.types[type.name] = type.type;
|
|
221
221
|
iotAgentLib.activate(config.iota, function (error) {
|
|
@@ -513,6 +513,84 @@ const testCases = [
|
|
|
513
513
|
}
|
|
514
514
|
]
|
|
515
515
|
},
|
|
516
|
+
{
|
|
517
|
+
describeName: '0021b - Simple group with active attributes with special names in object_id',
|
|
518
|
+
provision: {
|
|
519
|
+
url: 'http://localhost:' + config.iota.server.port + '/iot/services',
|
|
520
|
+
method: 'POST',
|
|
521
|
+
json: {
|
|
522
|
+
services: [
|
|
523
|
+
{
|
|
524
|
+
resource: '/iot/json',
|
|
525
|
+
apikey: globalEnv.apikey,
|
|
526
|
+
entity_type: globalEnv.entity_type,
|
|
527
|
+
commands: [],
|
|
528
|
+
lazy: [],
|
|
529
|
+
attributes: [
|
|
530
|
+
{
|
|
531
|
+
object_id: 'a',
|
|
532
|
+
name: 'attr_a',
|
|
533
|
+
type: 'Boolean',
|
|
534
|
+
metadata: {
|
|
535
|
+
accuracy: {
|
|
536
|
+
value: 0.8,
|
|
537
|
+
type: 'Float'
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
object_id: '.1.0.0.1',
|
|
543
|
+
name: 'psBatteryVoltage',
|
|
544
|
+
type: 'Number'
|
|
545
|
+
}
|
|
546
|
+
],
|
|
547
|
+
static_attributes: []
|
|
548
|
+
}
|
|
549
|
+
]
|
|
550
|
+
},
|
|
551
|
+
headers: {
|
|
552
|
+
'fiware-service': globalEnv.service,
|
|
553
|
+
'fiware-servicepath': globalEnv.servicePath
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
should: [
|
|
557
|
+
{
|
|
558
|
+
shouldName:
|
|
559
|
+
'A - WHEN sending defined object_ids with special format names (measures) through http IT should send measures to Context Broker preserving value types, name mappings and metadatas',
|
|
560
|
+
type: 'single',
|
|
561
|
+
measure: {
|
|
562
|
+
url: 'http://localhost:' + config.http.port + '/iot/json',
|
|
563
|
+
method: 'POST',
|
|
564
|
+
qs: {
|
|
565
|
+
i: globalEnv.deviceId,
|
|
566
|
+
k: globalEnv.apikey
|
|
567
|
+
},
|
|
568
|
+
json: {
|
|
569
|
+
a: false,
|
|
570
|
+
'.1.0.0.1': 23.5
|
|
571
|
+
}
|
|
572
|
+
},
|
|
573
|
+
expectation: {
|
|
574
|
+
id: globalEnv.entity_name,
|
|
575
|
+
type: globalEnv.entity_type,
|
|
576
|
+
attr_a: {
|
|
577
|
+
value: false,
|
|
578
|
+
type: 'Boolean',
|
|
579
|
+
metadata: {
|
|
580
|
+
accuracy: {
|
|
581
|
+
value: 0.8,
|
|
582
|
+
type: 'Float'
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
},
|
|
586
|
+
psBatteryVoltage: {
|
|
587
|
+
type: 'Number',
|
|
588
|
+
value: 23.5
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
]
|
|
593
|
+
},
|
|
516
594
|
{
|
|
517
595
|
describeName: '0022 - Simple group with active attributes and multimeasures',
|
|
518
596
|
provision: {
|
|
@@ -1690,7 +1768,6 @@ const testCases = [
|
|
|
1690
1768
|
},
|
|
1691
1769
|
{
|
|
1692
1770
|
describeName: '0170 - Simple group with active attribute + JEXL expression referencing context attributes',
|
|
1693
|
-
skip: 'lib', // Explanation in #1523
|
|
1694
1771
|
provision: {
|
|
1695
1772
|
url: 'http://localhost:' + config.iota.server.port + '/iot/services',
|
|
1696
1773
|
method: 'POST',
|
|
@@ -1750,9 +1827,101 @@ const testCases = [
|
|
|
1750
1827
|
}
|
|
1751
1828
|
]
|
|
1752
1829
|
},
|
|
1830
|
+
{
|
|
1831
|
+
describeName:
|
|
1832
|
+
'0175 - Simple group with active attribute + JEXL expression referencing metadata context attributes',
|
|
1833
|
+
provision: {
|
|
1834
|
+
url: 'http://localhost:' + config.iota.server.port + '/iot/services',
|
|
1835
|
+
method: 'POST',
|
|
1836
|
+
json: {
|
|
1837
|
+
services: [
|
|
1838
|
+
{
|
|
1839
|
+
resource: '/iot/json',
|
|
1840
|
+
apikey: globalEnv.apikey,
|
|
1841
|
+
entity_type: globalEnv.entity_type,
|
|
1842
|
+
commands: [],
|
|
1843
|
+
lazy: [],
|
|
1844
|
+
static_attributes: [
|
|
1845
|
+
{
|
|
1846
|
+
name: 'st_attr1',
|
|
1847
|
+
type: 'Number',
|
|
1848
|
+
value: 1.5,
|
|
1849
|
+
metadata: {
|
|
1850
|
+
coef1: {
|
|
1851
|
+
value: 0.8,
|
|
1852
|
+
type: 'Float'
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
},
|
|
1856
|
+
{
|
|
1857
|
+
name: 'st_attr',
|
|
1858
|
+
type: 'Number',
|
|
1859
|
+
value: 1.5,
|
|
1860
|
+
metadata: {
|
|
1861
|
+
coef: {
|
|
1862
|
+
value: 0.8,
|
|
1863
|
+
type: 'Float'
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
},
|
|
1867
|
+
{
|
|
1868
|
+
name: 'st_attr2',
|
|
1869
|
+
type: 'Number',
|
|
1870
|
+
value: 1.5,
|
|
1871
|
+
metadata: {
|
|
1872
|
+
coef2: {
|
|
1873
|
+
value: 0.8,
|
|
1874
|
+
type: 'Float'
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
],
|
|
1879
|
+
attributes: [
|
|
1880
|
+
{
|
|
1881
|
+
object_id: 'a',
|
|
1882
|
+
name: 'attr_a',
|
|
1883
|
+
type: 'Number',
|
|
1884
|
+
expression: 'a*st_attr*metadata.st_attr.coef'
|
|
1885
|
+
}
|
|
1886
|
+
],
|
|
1887
|
+
explicitAttrs: "['attr_a']"
|
|
1888
|
+
}
|
|
1889
|
+
]
|
|
1890
|
+
},
|
|
1891
|
+
headers: {
|
|
1892
|
+
'fiware-service': globalEnv.service,
|
|
1893
|
+
'fiware-servicepath': globalEnv.servicePath
|
|
1894
|
+
}
|
|
1895
|
+
},
|
|
1896
|
+
should: [
|
|
1897
|
+
{
|
|
1898
|
+
shouldName:
|
|
1899
|
+
'A - WHEN sending a value (number) through http IT should apply the expression using the context attributes value and send to Context Broker the value "39.60" ',
|
|
1900
|
+
type: 'single',
|
|
1901
|
+
measure: {
|
|
1902
|
+
url: 'http://localhost:' + config.http.port + '/iot/json',
|
|
1903
|
+
method: 'POST',
|
|
1904
|
+
qs: {
|
|
1905
|
+
i: globalEnv.deviceId,
|
|
1906
|
+
k: globalEnv.apikey
|
|
1907
|
+
},
|
|
1908
|
+
json: {
|
|
1909
|
+
a: 33
|
|
1910
|
+
}
|
|
1911
|
+
},
|
|
1912
|
+
expectation: {
|
|
1913
|
+
id: globalEnv.entity_name,
|
|
1914
|
+
type: globalEnv.entity_type,
|
|
1915
|
+
attr_a: {
|
|
1916
|
+
value: 39.6,
|
|
1917
|
+
type: 'Number'
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
]
|
|
1922
|
+
},
|
|
1753
1923
|
{
|
|
1754
1924
|
describeName: '0180 - Simple group with active attributes + JEXL multiples expressions at same time',
|
|
1755
|
-
skip: 'lib', // Explanation in #1523
|
|
1756
1925
|
provision: {
|
|
1757
1926
|
url: 'http://localhost:' + config.iota.server.port + '/iot/services',
|
|
1758
1927
|
method: 'POST',
|
|
@@ -4125,7 +4294,7 @@ const testCases = [
|
|
|
4125
4294
|
type: 'Number',
|
|
4126
4295
|
entity_name: 'TestType:TestDevice2',
|
|
4127
4296
|
entity_type: 'TestType',
|
|
4128
|
-
expression: 'type+":"+(t*2*static_a)'
|
|
4297
|
+
expression: 'type+":"+(t*2*static_a)'
|
|
4129
4298
|
}
|
|
4130
4299
|
],
|
|
4131
4300
|
static_attributes: [
|
|
@@ -4211,7 +4380,7 @@ const testCases = [
|
|
|
4211
4380
|
object_id: 't',
|
|
4212
4381
|
name: 'temperature',
|
|
4213
4382
|
type: 'Number',
|
|
4214
|
-
entity_name: 'type+":"+(t*2*static_a)',
|
|
4383
|
+
entity_name: 'type+":"+(t*2*static_a)',
|
|
4215
4384
|
entity_type: 'TestType'
|
|
4216
4385
|
}
|
|
4217
4386
|
],
|
|
@@ -4483,6 +4652,78 @@ const testCases = [
|
|
|
4483
4652
|
}
|
|
4484
4653
|
}
|
|
4485
4654
|
]
|
|
4655
|
+
},
|
|
4656
|
+
// 0900 - JEXL FUNCTION TESTS
|
|
4657
|
+
{
|
|
4658
|
+
describeName: '0900 - JEXL function - valuePicker and valuePickerMulti',
|
|
4659
|
+
provision: {
|
|
4660
|
+
url: 'http://localhost:' + config.iota.server.port + '/iot/services',
|
|
4661
|
+
method: 'POST',
|
|
4662
|
+
json: {
|
|
4663
|
+
services: [
|
|
4664
|
+
{
|
|
4665
|
+
resource: '/iot/json',
|
|
4666
|
+
apikey: globalEnv.apikey,
|
|
4667
|
+
entity_type: globalEnv.entity_type,
|
|
4668
|
+
explicitAttrs: true,
|
|
4669
|
+
commands: [],
|
|
4670
|
+
lazy: [],
|
|
4671
|
+
attributes: [
|
|
4672
|
+
{
|
|
4673
|
+
object_id: 'single',
|
|
4674
|
+
name: 'single',
|
|
4675
|
+
type: 'Number',
|
|
4676
|
+
expression: '{alarm1:alarm1,alarm2:alarm2,alarm3:alarm3}|valuePicker(true)'
|
|
4677
|
+
},
|
|
4678
|
+
{
|
|
4679
|
+
object_id: 'multi',
|
|
4680
|
+
name: 'multi',
|
|
4681
|
+
type: 'Number',
|
|
4682
|
+
expression: "a|valuePickerMulti([true,1,'on','nok'])"
|
|
4683
|
+
}
|
|
4684
|
+
],
|
|
4685
|
+
static_attributes: []
|
|
4686
|
+
}
|
|
4687
|
+
]
|
|
4688
|
+
},
|
|
4689
|
+
headers: {
|
|
4690
|
+
'fiware-service': globalEnv.service,
|
|
4691
|
+
'fiware-servicepath': globalEnv.servicePath
|
|
4692
|
+
}
|
|
4693
|
+
},
|
|
4694
|
+
should: [
|
|
4695
|
+
{
|
|
4696
|
+
shouldName:
|
|
4697
|
+
'A - WHEN sending a boolean value (true) through http IT should send to Context Broker the value 3 ',
|
|
4698
|
+
type: 'single',
|
|
4699
|
+
measure: {
|
|
4700
|
+
url: 'http://localhost:' + config.http.port + '/iot/json',
|
|
4701
|
+
method: 'POST',
|
|
4702
|
+
qs: {
|
|
4703
|
+
i: globalEnv.deviceId,
|
|
4704
|
+
k: globalEnv.apikey
|
|
4705
|
+
},
|
|
4706
|
+
json: {
|
|
4707
|
+
a: { n1: true, n2: 1, n3: 'on', n4: 'nok', n5: 'ok', n6: true, n7: false, n8: 0 },
|
|
4708
|
+
alarm1: true,
|
|
4709
|
+
alarm2: false,
|
|
4710
|
+
alarm3: true
|
|
4711
|
+
}
|
|
4712
|
+
},
|
|
4713
|
+
expectation: {
|
|
4714
|
+
id: globalEnv.entity_name,
|
|
4715
|
+
type: globalEnv.entity_type,
|
|
4716
|
+
single: {
|
|
4717
|
+
value: ['alarm1', 'alarm3'],
|
|
4718
|
+
type: 'Number'
|
|
4719
|
+
},
|
|
4720
|
+
multi: {
|
|
4721
|
+
value: ['n1', 'n2', 'n3', 'n4', 'n6'],
|
|
4722
|
+
type: 'Number'
|
|
4723
|
+
}
|
|
4724
|
+
}
|
|
4725
|
+
}
|
|
4726
|
+
]
|
|
4486
4727
|
}
|
|
4487
4728
|
];
|
|
4488
4729
|
|
|
@@ -25,19 +25,7 @@
|
|
|
25
25
|
{
|
|
26
26
|
"name":"location",
|
|
27
27
|
"type":"geo:point",
|
|
28
|
-
"expression": "${latitude}, ${longitude}"
|
|
29
|
-
"reverse": [
|
|
30
|
-
{
|
|
31
|
-
"object_id":"latitude",
|
|
32
|
-
"type": "string",
|
|
33
|
-
"expression": "${trim(substr(@location, indexOf(@location, \",\") + 1, length(@location)))}"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"object_id":"longitude",
|
|
37
|
-
"type": "string",
|
|
38
|
-
"expression": "${trim(substr(@location, 0, indexOf(@location, \",\")))}"
|
|
39
|
-
}
|
|
40
|
-
]
|
|
28
|
+
"expression": "${latitude}, ${longitude}"
|
|
41
29
|
}
|
|
42
30
|
],
|
|
43
31
|
"static_attributes": [],
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"groups": [
|
|
3
|
+
{
|
|
4
|
+
"resource": "/deviceTest",
|
|
5
|
+
"apikey": "801230BJKL23Y9090DSFL123HJK09H324HV8732",
|
|
6
|
+
"entity_type": "Light",
|
|
7
|
+
"trust": "8970A9078A803H3BL98PINEQRW8342HBAMS",
|
|
8
|
+
"cbHost": "http://unexistentHost:1026",
|
|
9
|
+
"commands": [
|
|
10
|
+
{
|
|
11
|
+
"name": "wheel1",
|
|
12
|
+
"type": "Wheel"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"lazy": [
|
|
16
|
+
{
|
|
17
|
+
"name": "luminescence",
|
|
18
|
+
"type": "Lumens"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"attributes": [
|
|
22
|
+
{
|
|
23
|
+
"name": "status",
|
|
24
|
+
"type": "Boolean"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"resource": "/deviceTest",
|
|
30
|
+
"apikey": "23HJK3Y9090DSFL173209HV8801232",
|
|
31
|
+
"entity_type": "Termometer",
|
|
32
|
+
"trust": "BL9803H3QRW8342HBAMS8A8",
|
|
33
|
+
"cbHost": "http://unexistentHost:1026",
|
|
34
|
+
"commands": [
|
|
35
|
+
{
|
|
36
|
+
"name": "temperature",
|
|
37
|
+
"type": "degrees"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"lazy": [],
|
|
41
|
+
"attributes": []
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"groups": [
|
|
3
|
+
{
|
|
4
|
+
"resource": "/deviceDuplicateGroup",
|
|
5
|
+
"apikey": "JK09H3L12K09H3L123HJK0732L123HJK38K09H3",
|
|
6
|
+
"entity_type": "CommandMachinery",
|
|
7
|
+
"trust": "8970A9078A803H3BL98PINEQRW8342HBAMS",
|
|
8
|
+
"commands": [
|
|
9
|
+
{
|
|
10
|
+
"name": "wheel1",
|
|
11
|
+
"type": "Wheel"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"lazy": [
|
|
15
|
+
{
|
|
16
|
+
"name": "luminescence",
|
|
17
|
+
"type": "Lumens"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"attributes": [
|
|
21
|
+
{
|
|
22
|
+
"name": "status",
|
|
23
|
+
"type": "Boolean"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"static_attributes": [
|
|
27
|
+
{
|
|
28
|
+
"name": "bootstrapServer",
|
|
29
|
+
"type": "Address",
|
|
30
|
+
"value": "127.0.0.1"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"groups": [
|
|
3
|
+
{
|
|
4
|
+
"resource": "/deviceTest",
|
|
5
|
+
"apikey": "801230BJKL23Y9090DSFL123HJK09H324HV8732",
|
|
6
|
+
"entity_type": "SensorMachine",
|
|
7
|
+
"trust": "8970A9078A803H3BL98PINEQRW8342HBAMS",
|
|
8
|
+
"cbHost": "http://unexistentHost:1026",
|
|
9
|
+
"commands": [
|
|
10
|
+
{
|
|
11
|
+
"name": "wheel1",
|
|
12
|
+
"type": "Wheel"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"lazy": [
|
|
16
|
+
{
|
|
17
|
+
"name": "luminescence",
|
|
18
|
+
"type": "Lumens"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"attributes": [
|
|
22
|
+
{
|
|
23
|
+
"name": "status",
|
|
24
|
+
"type": "Boolean"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"static_attributes": [
|
|
28
|
+
{
|
|
29
|
+
"name": "bootstrapServer",
|
|
30
|
+
"type": "Address",
|
|
31
|
+
"value": "127.0.0.1"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"groups": [
|
|
3
|
+
{
|
|
4
|
+
"resource": "/deviceTest",
|
|
5
|
+
"apikey": "754KL23Y9090DSFL123HSFL12380KL23Y2",
|
|
6
|
+
"entity_type": "AnotherMachine",
|
|
7
|
+
"trust": "8970A9078A803H3BL98PINEQRW8342HBAMS",
|
|
8
|
+
"cbHost": "http://unexistentHost:1026",
|
|
9
|
+
"commands": [
|
|
10
|
+
{
|
|
11
|
+
"name": "wheel1",
|
|
12
|
+
"type": "Wheel"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"lazy": [
|
|
16
|
+
{
|
|
17
|
+
"name": "luminescence",
|
|
18
|
+
"type": "Lumens"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"attributes": [
|
|
22
|
+
{
|
|
23
|
+
"name": "status",
|
|
24
|
+
"type": "Boolean"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"static_attributes": [
|
|
28
|
+
{
|
|
29
|
+
"name": "bootstrapServer",
|
|
30
|
+
"type": "Address",
|
|
31
|
+
"value": "127.0.0.1"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|