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
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"id": "urn:ngsi-ld:WeatherStation:ws1",
|
|
5
|
+
"type": "WeatherStation",
|
|
6
|
+
"pressure": {
|
|
7
|
+
"type": "Property",
|
|
8
|
+
"value": 1040
|
|
9
|
+
},
|
|
10
|
+
"humidity": {
|
|
11
|
+
"type": "Property",
|
|
12
|
+
"value": {
|
|
13
|
+
"@type": "Percentage",
|
|
14
|
+
"@value": "12"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"weather": {
|
|
18
|
+
"type": "Property",
|
|
19
|
+
"value": {
|
|
20
|
+
"@type": "Summary",
|
|
21
|
+
"@value": "Humidity 6 and pressure 20800"
|
|
22
|
+
}
|
|
24
23
|
}
|
|
24
|
+
}
|
|
25
25
|
]
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"@context": "http://context.json-ld",
|
|
4
|
+
"id": "urn:ngsi-ld:WeatherStation:ws1",
|
|
5
|
+
"type": "WeatherStation",
|
|
4
6
|
"pressure": {
|
|
5
7
|
"type": "Property",
|
|
6
8
|
"value": 1040
|
|
@@ -9,10 +11,8 @@
|
|
|
9
11
|
"type": "Property",
|
|
10
12
|
"value": {
|
|
11
13
|
"@type": "Summary",
|
|
12
|
-
"@value": "Humidity NaN and pressure
|
|
14
|
+
"@value": "Humidity NaN and pressure 20800"
|
|
13
15
|
}
|
|
14
|
-
}
|
|
15
|
-
"id": "urn:ngsi-ld:WeatherStation:ws1",
|
|
16
|
-
"type": "WeatherStation"
|
|
16
|
+
}
|
|
17
17
|
}
|
|
18
18
|
]
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"observedAt": "1970-01-01T00:00:00.001Z"
|
|
16
|
-
}
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"id": "urn:ngsi-ld:GPS:gps1",
|
|
5
|
+
"type": "GPS",
|
|
6
|
+
"location": {
|
|
7
|
+
"type": "GeoProperty",
|
|
8
|
+
"value": {
|
|
9
|
+
"coordinates": [
|
|
10
|
+
13,
|
|
11
|
+
52
|
|
12
|
+
],
|
|
13
|
+
"type": "Point"
|
|
14
|
+
}
|
|
17
15
|
}
|
|
16
|
+
}
|
|
18
17
|
]
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"type": "WeatherStation"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"@context": "http://context.json-ld",
|
|
16
|
-
"humidity": {
|
|
17
|
-
"type": "Property",
|
|
18
|
-
"value": {
|
|
19
|
-
"@type": "Percentage",
|
|
20
|
-
"@value": "12"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"id": "urn:ngsi-ld:Higrometer:Higro2000",
|
|
24
|
-
"type": "Higrometer"
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"id": "urn:ngsi-ld:WeatherStation:ws4",
|
|
5
|
+
"type": "WeatherStation",
|
|
6
|
+
"pressure": {
|
|
7
|
+
"type": "Property",
|
|
8
|
+
"value": {
|
|
9
|
+
"@type": "Hgmm",
|
|
10
|
+
"@value": "52"
|
|
11
|
+
}
|
|
25
12
|
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"@context": "http://context.json-ld",
|
|
16
|
+
"id": "urn:ngsi-ld:Higrometer:Higro2000",
|
|
17
|
+
"type": "Higrometer",
|
|
18
|
+
"humidity": {
|
|
19
|
+
"type": "Property",
|
|
20
|
+
"value": {
|
|
21
|
+
"@type": "Percentage",
|
|
22
|
+
"@value": "12"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
26
|
]
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
"value": {
|
|
13
|
-
"@type": "Hgmm",
|
|
14
|
-
"@value": "16"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"type": "Higrometer"
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"id": "urn:ngsi-ld:Higrometer:Higro2000",
|
|
5
|
+
"type": "Higrometer",
|
|
6
|
+
"pressure": {
|
|
7
|
+
"type": "Property",
|
|
8
|
+
"value": {
|
|
9
|
+
"@type": "Hgmm",
|
|
10
|
+
"@value": "16"
|
|
11
|
+
}
|
|
18
12
|
}
|
|
13
|
+
}
|
|
19
14
|
]
|
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
"type": "Property",
|
|
13
|
-
"value": {
|
|
14
|
-
"@type": "Hgmm",
|
|
15
|
-
"@value": "16"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"@context": "http://context.json-ld",
|
|
21
|
-
"id": "urn:ngsi-ld:Higrometer:Higro2002",
|
|
22
|
-
"type": "Higrometer",
|
|
23
|
-
"pressure": {
|
|
24
|
-
"type": "Property",
|
|
25
|
-
"value": {
|
|
26
|
-
"@type": "Hgmm",
|
|
27
|
-
"@value": "17"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"id": "urn:ngsi-ld:Higrometer:Higro2002",
|
|
5
|
+
"type": "Higrometer",
|
|
6
|
+
"pressure": {
|
|
7
|
+
"type": "Property",
|
|
8
|
+
"value": {
|
|
9
|
+
"@type": "Hgmm",
|
|
10
|
+
"@value": "17"
|
|
11
|
+
}
|
|
30
12
|
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"@context": "http://context.json-ld",
|
|
16
|
+
"id": "urn:ngsi-ld:Higrometer:Higro2000",
|
|
17
|
+
"type": "Higrometer",
|
|
18
|
+
"pressure": {
|
|
19
|
+
"type": "Property",
|
|
20
|
+
"value": {
|
|
21
|
+
"@type": "Hgmm",
|
|
22
|
+
"@value": "16"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
31
26
|
]
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"id": "urn:ngsi-ld:WM:SO1",
|
|
10
|
-
"type": "WM",
|
|
11
|
-
"vol": {
|
|
12
|
-
"type": "Property",
|
|
13
|
-
"value": 38
|
|
14
|
-
}
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"id": "urn:ngsi-ld:WM:SO1",
|
|
5
|
+
"type": "WM",
|
|
6
|
+
"vol": {
|
|
7
|
+
"type": "Property",
|
|
8
|
+
"value": 38
|
|
15
9
|
}
|
|
10
|
+
}
|
|
16
11
|
]
|
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"value": {
|
|
14
|
-
"@type": "Hgmm",
|
|
15
|
-
"@value": "16"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"@context": "http://context.json-ld",
|
|
21
|
-
"id": "urn:ngsi-ld:Higrometer:Higro2002",
|
|
22
|
-
"type": "Higrometer",
|
|
23
|
-
"pressure": {
|
|
24
|
-
"type": "Property",
|
|
25
|
-
"value": {
|
|
26
|
-
"@type": "Hgmm",
|
|
27
|
-
"@value": "17"
|
|
28
|
-
},
|
|
29
|
-
"unitCode": "Hgmm"
|
|
30
|
-
}
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"id": "urn:ngsi-ld:Higrometer:Higro2002",
|
|
5
|
+
"type": "Higrometer",
|
|
6
|
+
"pressure": {
|
|
7
|
+
"type": "Property",
|
|
8
|
+
"value": {
|
|
9
|
+
"@type": "Hgmm",
|
|
10
|
+
"@value": "17"
|
|
11
|
+
},
|
|
12
|
+
"unitCode": "Hgmm"
|
|
31
13
|
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"@context": "http://context.json-ld",
|
|
17
|
+
"id": "urn:ngsi-ld:Higrometer:Higro2000",
|
|
18
|
+
"type": "Higrometer",
|
|
19
|
+
"pressure": {
|
|
20
|
+
"type": "Property",
|
|
21
|
+
"value": {
|
|
22
|
+
"@type": "Hgmm",
|
|
23
|
+
"@value": "16"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
32
27
|
]
|
package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"value": {
|
|
14
|
-
"@type": "Percentage",
|
|
15
|
-
"@value": "12"
|
|
16
|
-
},
|
|
17
|
-
"observedAt": "2023-03-21T16:54:11.464Z"
|
|
18
|
-
}
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"id": "urn:ngsi-ld:Higrometer:Higro2000",
|
|
5
|
+
"type": "Higrometer",
|
|
6
|
+
"humidity": {
|
|
7
|
+
"type": "Property",
|
|
8
|
+
"value": {
|
|
9
|
+
"@type": "Percentage",
|
|
10
|
+
"@value": "12"
|
|
11
|
+
},
|
|
12
|
+
"observedAt": "2024-06-25T16:04:13.914Z"
|
|
19
13
|
}
|
|
14
|
+
}
|
|
20
15
|
]
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"@context": "http://context.json-ld",
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
"value": 87,
|
|
7
|
-
"providedBy": {
|
|
8
|
-
"type": "Relationship",
|
|
9
|
-
"object": "urn:ngsi-ld:Lamp:lamp1"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
4
|
+
"id": "urn:ngsi-ld:Lamp:lamp1",
|
|
5
|
+
"type": "Lamp",
|
|
12
6
|
"controlledAsset": {
|
|
13
7
|
"type": "Relationship",
|
|
14
8
|
"object": "urn:ngsi-ld:Building:001"
|
|
@@ -21,8 +15,15 @@
|
|
|
21
15
|
"value": "bell"
|
|
22
16
|
}
|
|
23
17
|
},
|
|
24
|
-
"
|
|
25
|
-
|
|
18
|
+
"luminosity": {
|
|
19
|
+
"type": "Property",
|
|
20
|
+
"value": 87,
|
|
21
|
+
"unitCode": "CAL",
|
|
22
|
+
"providedBy": {
|
|
23
|
+
"type": "Relationship",
|
|
24
|
+
"object": "urn:ngsi-ld:Lamp:lamp1"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
26
27
|
},
|
|
27
28
|
{
|
|
28
29
|
"@context": "http://context.json-ld",
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
"luminosity": {
|
|
32
33
|
"type": "Property",
|
|
33
34
|
"value": 87,
|
|
35
|
+
"unitCode": "CAL",
|
|
34
36
|
"providedBy": {
|
|
35
37
|
"type": "Relationship",
|
|
36
38
|
"object": "urn:ngsi-ld:Lamp:lamp1"
|
|
@@ -306,40 +306,6 @@ describe('NGSI-LD: JEXL', function () {
|
|
|
306
306
|
});
|
|
307
307
|
});
|
|
308
308
|
|
|
309
|
-
describe('When an update comes for expressions with syntax errors', function () {
|
|
310
|
-
// Case: Update for an attribute with bad expression
|
|
311
|
-
const values = [
|
|
312
|
-
{
|
|
313
|
-
name: 'p',
|
|
314
|
-
type: 'centigrades',
|
|
315
|
-
value: '52'
|
|
316
|
-
}
|
|
317
|
-
];
|
|
318
|
-
|
|
319
|
-
beforeEach(function () {
|
|
320
|
-
nock.cleanAll();
|
|
321
|
-
|
|
322
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
323
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
324
|
-
.matchHeader('fiware-servicepath', 'gardens')
|
|
325
|
-
.post(
|
|
326
|
-
'/ngsi-ld/v1/entityOperations/upsert/?options=update',
|
|
327
|
-
utils.readExampleFile(
|
|
328
|
-
'./test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin30.json'
|
|
329
|
-
)
|
|
330
|
-
)
|
|
331
|
-
.reply(204);
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
it('should ignore the expression before sending the values', function (done) {
|
|
335
|
-
iotAgentLib.update('light1', 'LightError', '', values, function (error) {
|
|
336
|
-
should.not.exist(error);
|
|
337
|
-
contextBrokerMock.done();
|
|
338
|
-
done();
|
|
339
|
-
});
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
|
|
343
309
|
describe('When there are expression attributes that are just calculated (not sent by the device)', function () {
|
|
344
310
|
// Case: Expression which results is sent as a new attribute
|
|
345
311
|
const values = [
|
|
@@ -557,41 +523,6 @@ describe('NGSI-LD: JEXL', function () {
|
|
|
557
523
|
});
|
|
558
524
|
});
|
|
559
525
|
|
|
560
|
-
describe('When an update comes for attributes without expressions and NULL type', function () {
|
|
561
|
-
// Case: Update for a Null attribute without expression
|
|
562
|
-
|
|
563
|
-
const values = [
|
|
564
|
-
{
|
|
565
|
-
name: 'a',
|
|
566
|
-
type: 'None',
|
|
567
|
-
value: null
|
|
568
|
-
}
|
|
569
|
-
];
|
|
570
|
-
|
|
571
|
-
beforeEach(function () {
|
|
572
|
-
nock.cleanAll();
|
|
573
|
-
|
|
574
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
575
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
576
|
-
.matchHeader('fiware-servicepath', 'gardens')
|
|
577
|
-
.post(
|
|
578
|
-
'/ngsi-ld/v1/entityOperations/upsert/?options=update',
|
|
579
|
-
utils.readExampleFile(
|
|
580
|
-
'./test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin5.json'
|
|
581
|
-
)
|
|
582
|
-
)
|
|
583
|
-
.reply(204);
|
|
584
|
-
});
|
|
585
|
-
|
|
586
|
-
it('should apply the expression before sending the values', function (done) {
|
|
587
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
588
|
-
should.not.exist(error);
|
|
589
|
-
contextBrokerMock.done();
|
|
590
|
-
done();
|
|
591
|
-
});
|
|
592
|
-
});
|
|
593
|
-
});
|
|
594
|
-
|
|
595
526
|
describe('When an update comes for attributes without expressions and Boolean type', function () {
|
|
596
527
|
// Case: Update for a Boolean attribute without expression
|
|
597
528
|
|
|
@@ -696,39 +627,6 @@ describe('NGSI-LD: JEXL', function () {
|
|
|
696
627
|
});
|
|
697
628
|
});
|
|
698
629
|
|
|
699
|
-
describe('When there are expressions including other attributes and they are not updated', function () {
|
|
700
|
-
const values = [
|
|
701
|
-
{
|
|
702
|
-
name: 'x',
|
|
703
|
-
type: 'Number',
|
|
704
|
-
value: 0.44
|
|
705
|
-
}
|
|
706
|
-
];
|
|
707
|
-
|
|
708
|
-
beforeEach(function () {
|
|
709
|
-
nock.cleanAll();
|
|
710
|
-
|
|
711
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
712
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
713
|
-
.matchHeader('fiware-servicepath', 'gardens')
|
|
714
|
-
.post(
|
|
715
|
-
'/ngsi-ld/v1/entityOperations/upsert/?options=update',
|
|
716
|
-
utils.readExampleFile(
|
|
717
|
-
'./test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin12a.json'
|
|
718
|
-
)
|
|
719
|
-
)
|
|
720
|
-
.reply(204);
|
|
721
|
-
});
|
|
722
|
-
|
|
723
|
-
it('should apply the expression before sending the values', function (done) {
|
|
724
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
725
|
-
should.not.exist(error);
|
|
726
|
-
contextBrokerMock.done();
|
|
727
|
-
done();
|
|
728
|
-
});
|
|
729
|
-
});
|
|
730
|
-
});
|
|
731
|
-
|
|
732
630
|
describe('When there are expressions including other attributes and they are updated', function () {
|
|
733
631
|
const values = [
|
|
734
632
|
{
|
|
@@ -696,17 +696,16 @@ describe('NGSI-LD - Multi-entity plugin is executed before timestamp process plu
|
|
|
696
696
|
'./test/unit/ngsi-ld/examples' +
|
|
697
697
|
'/contextRequests/updateContextMultientityTimestampPlugin2.json'
|
|
698
698
|
);
|
|
699
|
-
|
|
700
699
|
// Note that TimeInstant fields are not included in the json used by this mock as they are dynamic
|
|
701
700
|
// fields. The following code just checks that TimeInstant fields are present.
|
|
702
|
-
if (!body[
|
|
701
|
+
if (!body[0].humidity.observedAt) {
|
|
703
702
|
return false;
|
|
704
703
|
}
|
|
705
704
|
|
|
706
|
-
const timeInstantAtt = body[
|
|
705
|
+
const timeInstantAtt = body[0].humidity.observedAt;
|
|
707
706
|
if (moment(timeInstantAtt, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid) {
|
|
708
|
-
delete body[
|
|
709
|
-
delete expectedBody[
|
|
707
|
+
delete body[0].humidity.observedAt;
|
|
708
|
+
delete expectedBody[0].humidity.observedAt;
|
|
710
709
|
return JSON.stringify(body) === JSON.stringify(expectedBody);
|
|
711
710
|
}
|
|
712
711
|
return false;
|
|
@@ -184,11 +184,9 @@ describe('NGSI-LD - Device provisioning API: List provisioned devices', function
|
|
|
184
184
|
should.exist(body.devices[2].attributes[0].entity_name);
|
|
185
185
|
should.exist(body.devices[2].attributes[0].entity_type);
|
|
186
186
|
should.exist(body.devices[2].attributes[1].expression);
|
|
187
|
-
should.exist(body.devices[2].attributes[2].reverse);
|
|
188
187
|
body.devices[2].attributes[0].entity_name.should.equal('Higro2000');
|
|
189
188
|
body.devices[2].attributes[0].entity_type.should.equal('Higrometer');
|
|
190
189
|
body.devices[2].attributes[1].expression.should.equal('${@humidity * 20}');
|
|
191
|
-
body.devices[2].attributes[2].reverse.length.should.equal(2);
|
|
192
190
|
done();
|
|
193
191
|
});
|
|
194
192
|
});
|
|
@@ -245,11 +243,9 @@ describe('NGSI-LD - Device provisioning API: List provisioned devices', function
|
|
|
245
243
|
should.exist(body.attributes[0].entity_name);
|
|
246
244
|
should.exist(body.attributes[0].entity_type);
|
|
247
245
|
should.exist(body.attributes[1].expression);
|
|
248
|
-
should.exist(body.attributes[2].reverse);
|
|
249
246
|
body.attributes[0].entity_name.should.equal('Higro2000');
|
|
250
247
|
body.attributes[0].entity_type.should.equal('Higrometer');
|
|
251
248
|
body.attributes[1].expression.should.equal('${@humidity * 20}');
|
|
252
|
-
body.attributes[2].reverse.length.should.equal(2);
|
|
253
249
|
done();
|
|
254
250
|
});
|
|
255
251
|
});
|