iotagent-node-lib 2.26.0 → 3.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.
- package/lib/fiware-iotagent-lib.js +0 -5
- package/lib/plugins/compressTimestamp.js +2 -7
- package/lib/plugins/expressionParser.js +0 -47
- package/lib/plugins/expressionPlugin.js +6 -78
- package/lib/plugins/jexlParser.js +0 -36
- package/lib/plugins/pluginUtils.js +0 -119
- package/lib/services/ngsi/entities-NGSI-LD.js +600 -199
- package/lib/services/ngsi/entities-NGSI-v2.js +620 -298
- package/lib/services/ngsi/ngsiUtils.js +15 -22
- package/package.json +1 -1
- package/test/unit/general/loglevel-api_test.js +0 -2
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin1.json +0 -5
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast10.json +1 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast8.json +1 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast9.json +1 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +16 -15
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4.json +8 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4a.json +34 -34
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin5.json +8 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin6.json +0 -20
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin7.json +0 -5
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin8.json +10 -10
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +8 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +5 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextProcessTimestamp.json +4 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextTimestampOverride.json +4 -3
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +4 -3
- package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +2 -5
- package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +1 -7
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +15 -3
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +0 -2
- package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +0 -31
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +18 -18
- package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +19 -6
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json +2 -2
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +4 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +0 -16
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +8 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +42 -42
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +7 -7
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +0 -5
- package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +1 -7
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +0 -3
- package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +0 -6
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +1 -7
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +0 -2
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +0 -4
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +0 -32
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +5 -15
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +1 -1
- package/lib/plugins/addEvent.js +0 -32
- package/lib/plugins/attributeAlias.js +0 -107
- package/lib/plugins/multiEntity.js +0 -255
- package/lib/plugins/timestampProcessPlugin.js +0 -95
- package/test/unit/ngsi-ld/plugins/event-plugin_test.js +0 -116
- package/test/unit/ngsiv2/plugins/event-plugin_test.js +0 -118
- package/test/unit/ngsiv2/plugins/translation-inPlugins_test.js +0 -262
|
@@ -90,10 +90,10 @@ function isFloat(value) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
-
* It casts attribute values which are reported using JSON
|
|
93
|
+
* It casts attribute values which are reported using JSON parsing
|
|
94
94
|
*
|
|
95
95
|
* @param {String} payload The payload
|
|
96
|
-
* @return {String} New payload where attributes's values are casted to the corresponding JSON
|
|
96
|
+
* @return {String} New payload where attributes's values are casted to the corresponding JSON values
|
|
97
97
|
*/
|
|
98
98
|
function castJsonNativeAttributes(payload) {
|
|
99
99
|
if (!config.getConfig().autocast) {
|
|
@@ -105,28 +105,13 @@ function castJsonNativeAttributes(payload) {
|
|
|
105
105
|
/* eslint-disable-next-line no-prototype-builtins */
|
|
106
106
|
payload.hasOwnProperty(key) &&
|
|
107
107
|
payload[key].value &&
|
|
108
|
-
payload[key].type &&
|
|
109
108
|
typeof payload[key].value === 'string'
|
|
110
109
|
) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
payload[key].value = payload[key].value === 'true' || payload[key].value === '1';
|
|
117
|
-
} else if (payload[key].type === 'None') {
|
|
118
|
-
payload[key].value = null;
|
|
119
|
-
} else if (payload[key].type === 'Array' || payload[key].type === 'Object') {
|
|
120
|
-
try {
|
|
121
|
-
const parsedValue = JSON.parse(payload[key].value);
|
|
122
|
-
payload[key].value = parsedValue;
|
|
123
|
-
} catch (e) {
|
|
124
|
-
logger.error(
|
|
125
|
-
context,
|
|
126
|
-
'Bad attribute value type. Expecting JSON Array or JSON Object. Received:%s',
|
|
127
|
-
payload[key].value
|
|
128
|
-
);
|
|
129
|
-
}
|
|
110
|
+
try {
|
|
111
|
+
const parsedValue = JSON.parse(payload[key].value);
|
|
112
|
+
payload[key].value = parsedValue;
|
|
113
|
+
} catch (e) {
|
|
114
|
+
// Keep value as is
|
|
130
115
|
}
|
|
131
116
|
}
|
|
132
117
|
}
|
|
@@ -223,6 +208,14 @@ function getMetaData(typeInformation, name, metadata) {
|
|
|
223
208
|
}
|
|
224
209
|
}
|
|
225
210
|
}
|
|
211
|
+
if (typeInformation.lazy) {
|
|
212
|
+
for (i = 0; i < typeInformation.lazy.length; i++) {
|
|
213
|
+
/* jshint camelcase: false */
|
|
214
|
+
if (name === typeInformation.lazy[i].object_id) {
|
|
215
|
+
return typeInformation.lazy[i].metadata;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
226
219
|
if (typeInformation.staticAttributes) {
|
|
227
220
|
for (i = 0; i < typeInformation.staticAttributes.length; i++) {
|
|
228
221
|
if (name === typeInformation.staticAttributes[i].name) {
|
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": "
|
|
5
|
+
"version": "3.0.0",
|
|
6
6
|
"homepage": "https://github.com/telefonicaid/iotagent-node-lib",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"fiware",
|
|
@@ -73,8 +73,6 @@ describe('Log level API', function () {
|
|
|
73
73
|
|
|
74
74
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
75
75
|
iotAgentLib.clearAll(function () {
|
|
76
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
77
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
78
76
|
done();
|
|
79
77
|
});
|
|
80
78
|
});
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
},
|
|
15
|
+
"observedAt": "1970-01-01T00:00:00.001Z"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
17
18
|
]
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"@context": "http://context.json-ld",
|
|
4
|
-
"
|
|
4
|
+
"id": "urn:ngsi-ld:WeatherStation:ws1",
|
|
5
|
+
"type": "WeatherStation",
|
|
6
|
+
"weather": {
|
|
5
7
|
"type": "Property",
|
|
6
8
|
"value": {
|
|
7
|
-
"@type": "
|
|
8
|
-
"@value": "
|
|
9
|
+
"@type": "Summary",
|
|
10
|
+
"@value": "Humidity 6 and pressure 1040"
|
|
9
11
|
}
|
|
10
12
|
},
|
|
11
|
-
"id": "urn:ngsi-ld:WeatherStation:ws1",
|
|
12
13
|
"pressure25": {
|
|
13
14
|
"type": "Property",
|
|
14
15
|
"value": 52
|
|
15
16
|
},
|
|
16
|
-
"
|
|
17
|
-
"weather": {
|
|
17
|
+
"humidity12": {
|
|
18
18
|
"type": "Property",
|
|
19
19
|
"value": {
|
|
20
|
-
"@type": "
|
|
21
|
-
"@value": "
|
|
20
|
+
"@type": "Percentage",
|
|
21
|
+
"@value": "12"
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"type": "
|
|
10
|
-
"value":
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"type": "WeatherStation"
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"id": "urn:ngsi-ld:WeatherStation:ws1",
|
|
5
|
+
"type": "WeatherStation",
|
|
6
|
+
"weather": {
|
|
7
|
+
"type": "Property",
|
|
8
|
+
"value": {
|
|
9
|
+
"@type": "Summary",
|
|
10
|
+
"@value": "Humidity 6 and pressure 1040"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"pressure25": {
|
|
14
|
+
"type": "Property",
|
|
15
|
+
"value": 52
|
|
16
|
+
},
|
|
17
|
+
"humidity12": {
|
|
18
|
+
"type": "Property",
|
|
19
|
+
"value": {
|
|
20
|
+
"@type": "Percentage",
|
|
21
|
+
"@value": "12"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"alive": {
|
|
25
|
+
"type": "Property",
|
|
26
|
+
"value": {
|
|
27
|
+
"@type": "None",
|
|
28
|
+
"@value": "undefined"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"updated": {
|
|
32
|
+
"type": "Property",
|
|
33
|
+
"value": true
|
|
35
34
|
}
|
|
36
|
-
|
|
35
|
+
}
|
|
36
|
+
]
|
|
@@ -6,26 +6,26 @@
|
|
|
6
6
|
},
|
|
7
7
|
{
|
|
8
8
|
"@context": "http://context.json-ld",
|
|
9
|
-
"id": "urn:ngsi-ld:Higrometer:
|
|
9
|
+
"id": "urn:ngsi-ld:Higrometer:Higro2000",
|
|
10
|
+
"type": "Higrometer",
|
|
10
11
|
"pressure": {
|
|
11
12
|
"type": "Property",
|
|
12
13
|
"value": {
|
|
13
14
|
"@type": "Hgmm",
|
|
14
|
-
"@value": "
|
|
15
|
+
"@value": "16"
|
|
15
16
|
}
|
|
16
|
-
}
|
|
17
|
-
"type": "Higrometer"
|
|
17
|
+
}
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"@context": "http://context.json-ld",
|
|
21
|
-
"id": "urn:ngsi-ld:Higrometer:
|
|
21
|
+
"id": "urn:ngsi-ld:Higrometer:Higro2002",
|
|
22
|
+
"type": "Higrometer",
|
|
22
23
|
"pressure": {
|
|
23
24
|
"type": "Property",
|
|
24
25
|
"value": {
|
|
25
26
|
"@type": "Hgmm",
|
|
26
|
-
"@value": "
|
|
27
|
+
"@value": "17"
|
|
27
28
|
}
|
|
28
|
-
}
|
|
29
|
-
"type": "Higrometer"
|
|
29
|
+
}
|
|
30
30
|
}
|
|
31
31
|
]
|
|
@@ -12,25 +12,5 @@
|
|
|
12
12
|
"type": "Property",
|
|
13
13
|
"value": 38
|
|
14
14
|
}
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"@context": "http://context.json-ld",
|
|
18
|
-
"id": "urn:ngsi-ld:WM:SO2",
|
|
19
|
-
"type": "WM"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"@context": "http://context.json-ld",
|
|
23
|
-
"id": "urn:ngsi-ld:WM:SO3",
|
|
24
|
-
"type": "WM"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"@context": "http://context.json-ld",
|
|
28
|
-
"id": "urn:ngsi-ld:WM:SO4",
|
|
29
|
-
"type": "WM"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"@context": "http://context.json-ld",
|
|
33
|
-
"id": "urn:ngsi-ld:WM:SO5",
|
|
34
|
-
"type": "WM"
|
|
35
15
|
}
|
|
36
16
|
]
|
|
@@ -6,27 +6,27 @@
|
|
|
6
6
|
},
|
|
7
7
|
{
|
|
8
8
|
"@context": "http://context.json-ld",
|
|
9
|
-
"id": "urn:ngsi-ld:Higrometer:
|
|
9
|
+
"id": "urn:ngsi-ld:Higrometer:Higro2000",
|
|
10
|
+
"type": "Higrometer",
|
|
10
11
|
"pressure": {
|
|
11
12
|
"type": "Property",
|
|
12
|
-
"unitCode": "Hgmm",
|
|
13
13
|
"value": {
|
|
14
14
|
"@type": "Hgmm",
|
|
15
|
-
"@value": "
|
|
15
|
+
"@value": "16"
|
|
16
16
|
}
|
|
17
|
-
}
|
|
18
|
-
"type": "Higrometer"
|
|
17
|
+
}
|
|
19
18
|
},
|
|
20
19
|
{
|
|
21
20
|
"@context": "http://context.json-ld",
|
|
22
|
-
"id": "urn:ngsi-ld:Higrometer:
|
|
21
|
+
"id": "urn:ngsi-ld:Higrometer:Higro2002",
|
|
22
|
+
"type": "Higrometer",
|
|
23
23
|
"pressure": {
|
|
24
24
|
"type": "Property",
|
|
25
25
|
"value": {
|
|
26
26
|
"@type": "Hgmm",
|
|
27
|
-
"@value": "
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
"@value": "17"
|
|
28
|
+
},
|
|
29
|
+
"unitCode": "Hgmm"
|
|
30
|
+
}
|
|
31
31
|
}
|
|
32
32
|
]
|
package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin1.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"@context": "http://context.json-ld",
|
|
4
|
+
"id": "urn:ngsi-ld:WeatherStation:ws4",
|
|
5
|
+
"type": "WeatherStation",
|
|
4
6
|
"pressure": {
|
|
5
7
|
"type": "Property",
|
|
6
8
|
"value": {
|
|
@@ -8,20 +10,19 @@
|
|
|
8
10
|
"@value": "52"
|
|
9
11
|
},
|
|
10
12
|
"observedAt": "2016-05-30T16:25:22.304Z"
|
|
11
|
-
}
|
|
12
|
-
"id": "urn:ngsi-ld:WeatherStation:ws4",
|
|
13
|
-
"type": "WeatherStation"
|
|
13
|
+
}
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"@context": "http://context.json-ld",
|
|
17
|
+
"id": "urn:ngsi-ld:Higrometer:Higro2000",
|
|
18
|
+
"type": "Higrometer",
|
|
17
19
|
"humidity": {
|
|
18
20
|
"type": "Property",
|
|
19
21
|
"value": {
|
|
20
22
|
"@type": "Percentage",
|
|
21
23
|
"@value": "12"
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"type": "Higrometer"
|
|
24
|
+
},
|
|
25
|
+
"observedAt": "2023-03-21T18:30:30.948Z"
|
|
26
|
+
}
|
|
26
27
|
}
|
|
27
28
|
]
|
package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json
CHANGED
|
@@ -6,14 +6,15 @@
|
|
|
6
6
|
},
|
|
7
7
|
{
|
|
8
8
|
"@context": "http://context.json-ld",
|
|
9
|
+
"id": "urn:ngsi-ld:Higrometer:Higro2000",
|
|
10
|
+
"type": "Higrometer",
|
|
9
11
|
"humidity": {
|
|
10
12
|
"type": "Property",
|
|
11
13
|
"value": {
|
|
12
14
|
"@type": "Percentage",
|
|
13
15
|
"@value": "12"
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"type": "Higrometer"
|
|
16
|
+
},
|
|
17
|
+
"observedAt": "2023-03-21T16:54:11.464Z"
|
|
18
|
+
}
|
|
18
19
|
}
|
|
19
20
|
]
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
{
|
|
3
3
|
"@context": "http://context.json-ld",
|
|
4
4
|
"id": "urn:ngsi-ld:Light:light1",
|
|
5
|
+
"type": "Light",
|
|
5
6
|
"state": {
|
|
6
|
-
"observedAt": "2016-05-30T16:25:22.304Z",
|
|
7
7
|
"type": "Property",
|
|
8
|
-
"value": true
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
"value": true,
|
|
9
|
+
"observedAt": "2016-05-30T16:25:22.304Z"
|
|
10
|
+
}
|
|
11
11
|
}
|
|
12
12
|
]
|
|
@@ -198,9 +198,6 @@ describe('NGSI-LD - Expression-based transformations plugin', function () {
|
|
|
198
198
|
|
|
199
199
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
200
200
|
iotAgentLib.clearAll(function () {
|
|
201
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
202
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
203
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
204
201
|
done();
|
|
205
202
|
});
|
|
206
203
|
});
|
|
@@ -746,13 +743,13 @@ describe('NGSI-LD - Expression-based transformations plugin', function () {
|
|
|
746
743
|
});
|
|
747
744
|
});
|
|
748
745
|
|
|
749
|
-
describe('When an update comes for attributes without expressions and
|
|
746
|
+
describe('When an update comes for attributes without expressions and Array type', function () {
|
|
750
747
|
// Case: Update for a JSON array attribute without expression
|
|
751
748
|
|
|
752
749
|
const values = [
|
|
753
750
|
{
|
|
754
751
|
name: 'r',
|
|
755
|
-
type: '
|
|
752
|
+
type: 'Array',
|
|
756
753
|
value: ['v0.1', 'v0.2', 'v0.3']
|
|
757
754
|
}
|
|
758
755
|
];
|
|
@@ -293,13 +293,10 @@ const iotAgentConfigTS = {
|
|
|
293
293
|
|
|
294
294
|
describe('NGSI-LD: JEXL', function () {
|
|
295
295
|
beforeEach(function (done) {
|
|
296
|
-
logger.setLevel('FATAL');
|
|
296
|
+
//logger.setLevel('FATAL');
|
|
297
297
|
|
|
298
298
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
299
299
|
iotAgentLib.clearAll(function () {
|
|
300
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
301
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
302
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
303
300
|
done();
|
|
304
301
|
});
|
|
305
302
|
});
|
|
@@ -964,9 +961,6 @@ describe('NGSI-LD: JEXL - Timestamps', function () {
|
|
|
964
961
|
|
|
965
962
|
iotAgentLib.activate(iotAgentConfigTS, function () {
|
|
966
963
|
iotAgentLib.clearAll(function () {
|
|
967
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
968
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
969
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
970
964
|
done();
|
|
971
965
|
});
|
|
972
966
|
});
|
|
@@ -75,6 +75,18 @@ const iotAgentConfig = {
|
|
|
75
75
|
{
|
|
76
76
|
name: 'configuration',
|
|
77
77
|
type: 'Object'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'date',
|
|
81
|
+
type: 'Date'
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'time',
|
|
85
|
+
type: 'Time'
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'dateTime',
|
|
89
|
+
type: 'DateTime'
|
|
78
90
|
}
|
|
79
91
|
]
|
|
80
92
|
}
|
|
@@ -327,7 +339,7 @@ describe('NGSI-LD - JSON native types autocast test', function () {
|
|
|
327
339
|
describe('When the IoT Agent receives new information from a device. Observation with Time type', function () {
|
|
328
340
|
const values = [
|
|
329
341
|
{
|
|
330
|
-
name: '
|
|
342
|
+
name: 'time',
|
|
331
343
|
type: 'Time',
|
|
332
344
|
value: '2016-04-30T14:59:46.000Z'
|
|
333
345
|
}
|
|
@@ -360,7 +372,7 @@ describe('NGSI-LD - JSON native types autocast test', function () {
|
|
|
360
372
|
describe('When the IoT Agent receives new information from a device. Observation with DateTime type', function () {
|
|
361
373
|
const values = [
|
|
362
374
|
{
|
|
363
|
-
name: '
|
|
375
|
+
name: 'dateTime',
|
|
364
376
|
type: 'DateTime',
|
|
365
377
|
value: '2016-04-30Z'
|
|
366
378
|
}
|
|
@@ -393,7 +405,7 @@ describe('NGSI-LD - JSON native types autocast test', function () {
|
|
|
393
405
|
describe('When the IoT Agent receives new information from a device. Observation with Date type', function () {
|
|
394
406
|
const values = [
|
|
395
407
|
{
|
|
396
|
-
name: '
|
|
408
|
+
name: 'date',
|
|
397
409
|
type: 'Date',
|
|
398
410
|
value: '2016-04-30T14:59:46.000Z'
|
|
399
411
|
}
|
|
@@ -117,8 +117,6 @@ describe('NGSI-LD - Attribute alias plugin', function () {
|
|
|
117
117
|
|
|
118
118
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
119
119
|
iotAgentLib.clearAll(function () {
|
|
120
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
121
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
122
120
|
done();
|
|
123
121
|
});
|
|
124
122
|
});
|
|
@@ -123,8 +123,6 @@ describe('NGSI-LD - Timestamp compression plugin', function () {
|
|
|
123
123
|
logger.setLevel('FATAL');
|
|
124
124
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
125
125
|
iotAgentLib.clearAll(function () {
|
|
126
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.compressTimestamp.updateNgsi2);
|
|
127
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.compressTimestamp.queryNgsi2);
|
|
128
126
|
done();
|
|
129
127
|
});
|
|
130
128
|
});
|
|
@@ -214,33 +212,4 @@ describe('NGSI-LD - Timestamp compression plugin', function () {
|
|
|
214
212
|
});
|
|
215
213
|
});
|
|
216
214
|
});
|
|
217
|
-
|
|
218
|
-
describe('When a query comes for a timestamp through the plugin', function () {
|
|
219
|
-
const values = ['state', 'TheTargetValue'];
|
|
220
|
-
|
|
221
|
-
beforeEach(function () {
|
|
222
|
-
nock.cleanAll();
|
|
223
|
-
|
|
224
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
225
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
226
|
-
.get('/ngsi-ld/v1/entities/urn:ngsi-ld:Light:light1?attrs=state,TheTargetValue')
|
|
227
|
-
.reply(
|
|
228
|
-
200,
|
|
229
|
-
utils.readExampleFile(
|
|
230
|
-
'./test/unit/ngsi-ld/examples/contextResponses/queryContextCompressTimestamp1Success.json'
|
|
231
|
-
)
|
|
232
|
-
);
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it('should return an entity with all its timestamps without separators (basic format)', function (done) {
|
|
236
|
-
iotAgentLib.query('light1', 'Light', '', values, function (error, response) {
|
|
237
|
-
should.not.exist(error);
|
|
238
|
-
should.exist(response);
|
|
239
|
-
should.exist(response.TheTargetValue);
|
|
240
|
-
should.exist(response.TheTargetValue.value);
|
|
241
|
-
response.TheTargetValue.value.should.equal('20071103T131805');
|
|
242
|
-
done();
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
215
|
});
|