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
|
@@ -246,9 +246,6 @@ describe('NGSI-LD - Multi-entity plugin', function () {
|
|
|
246
246
|
logger.setLevel('FATAL');
|
|
247
247
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
248
248
|
iotAgentLib.clearAll(function () {
|
|
249
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
250
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
251
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.multiEntity.update);
|
|
252
249
|
done();
|
|
253
250
|
});
|
|
254
251
|
});
|
|
@@ -614,15 +611,9 @@ describe('NGSI-LD - Multi-entity plugin', function () {
|
|
|
614
611
|
|
|
615
612
|
describe('NGSI-LD - Multi-entity plugin is executed before timestamp process plugin', function () {
|
|
616
613
|
beforeEach(function (done) {
|
|
617
|
-
logger.setLevel('FATAL');
|
|
618
|
-
|
|
619
614
|
iotAgentConfig.timestamp = true;
|
|
620
615
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
621
616
|
iotAgentLib.clearAll(function () {
|
|
622
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
623
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
624
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.multiEntity.update);
|
|
625
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.timestampProcess.update);
|
|
626
617
|
done();
|
|
627
618
|
});
|
|
628
619
|
});
|
|
@@ -731,13 +722,26 @@ describe('NGSI-LD - Multi-entity plugin is executed before timestamp process plu
|
|
|
731
722
|
it('should propagate user provider timestamp to mapped entities', function (done) {
|
|
732
723
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
733
724
|
.matchHeader('fiware-service', 'smartgondor')
|
|
734
|
-
.post(
|
|
735
|
-
|
|
736
|
-
utils.readExampleFile(
|
|
725
|
+
.post('/ngsi-ld/v1/entityOperations/upsert/?options=update', function (body) {
|
|
726
|
+
const expectedBody = utils.readExampleFile(
|
|
737
727
|
'./test/unit/ngsi-ld/examples' +
|
|
738
728
|
'/contextRequests/updateContextMultientityTimestampPlugin3.json'
|
|
739
|
-
)
|
|
740
|
-
|
|
729
|
+
);
|
|
730
|
+
|
|
731
|
+
// Note that TimeInstant fields are not included in the json used by this mock as they are dynamic
|
|
732
|
+
// fields. The following code just checks that TimeInstant fields are present.
|
|
733
|
+
if (!body[1].humidity.observedAt) {
|
|
734
|
+
return false;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
const timeInstantAtt = body[1].humidity.observedAt;
|
|
738
|
+
if (moment(timeInstantAtt, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid) {
|
|
739
|
+
delete body[1].humidity.observedAt;
|
|
740
|
+
delete expectedBody[1].humidity.observedAt;
|
|
741
|
+
return JSON.stringify(body) === JSON.stringify(expectedBody);
|
|
742
|
+
}
|
|
743
|
+
return false;
|
|
744
|
+
})
|
|
741
745
|
.reply(204);
|
|
742
746
|
|
|
743
747
|
const tsValue = [
|
|
@@ -772,10 +776,6 @@ describe('NGSI-LD - Multi-entity plugin is executed for a command update for a r
|
|
|
772
776
|
timekeeper.freeze(time);
|
|
773
777
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
774
778
|
iotAgentLib.clearAll(function () {
|
|
775
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
776
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
777
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.multiEntity.update);
|
|
778
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.timestampProcess.update);
|
|
779
779
|
done();
|
|
780
780
|
});
|
|
781
781
|
});
|
|
@@ -28,6 +28,7 @@ const utils = require('../../../tools/utils');
|
|
|
28
28
|
const should = require('should');
|
|
29
29
|
const logger = require('logops');
|
|
30
30
|
const nock = require('nock');
|
|
31
|
+
const moment = require('moment');
|
|
31
32
|
let contextBrokerMock;
|
|
32
33
|
const iotAgentConfig = {
|
|
33
34
|
contextBroker: {
|
|
@@ -68,7 +69,6 @@ describe('NGSI-LD - Timestamp processing plugin', function () {
|
|
|
68
69
|
|
|
69
70
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
70
71
|
iotAgentLib.clearAll(function () {
|
|
71
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.timestampProcess.update);
|
|
72
72
|
done();
|
|
73
73
|
});
|
|
74
74
|
});
|
|
@@ -98,12 +98,25 @@ describe('NGSI-LD - Timestamp processing plugin', function () {
|
|
|
98
98
|
|
|
99
99
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
100
100
|
.matchHeader('fiware-service', 'smartgondor')
|
|
101
|
-
.post(
|
|
102
|
-
|
|
103
|
-
utils.readExampleFile(
|
|
101
|
+
.post('/ngsi-ld/v1/entityOperations/upsert/?options=update', function (body) {
|
|
102
|
+
const expectedBody = utils.readExampleFile(
|
|
104
103
|
'./test/unit/ngsi-ld/examples/contextRequests/updateContextProcessTimestamp.json'
|
|
105
|
-
)
|
|
106
|
-
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// Note that TimeInstant fields are not included in the json used by this mock as they are dynamic
|
|
107
|
+
// fields. The following code just checks that TimeInstant fields are present.
|
|
108
|
+
if (!body[0].state.observedAt) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const timeInstantAtt = body[0].state.observedAt;
|
|
113
|
+
if (moment(timeInstantAtt, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid) {
|
|
114
|
+
delete body[0].state.observedAt;
|
|
115
|
+
delete expectedBody[0].state.observedAt;
|
|
116
|
+
return JSON.stringify(body) === JSON.stringify(expectedBody);
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
})
|
|
107
120
|
.reply(204);
|
|
108
121
|
});
|
|
109
122
|
|
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
"type": "WeatherStation"
|
|
6
6
|
},
|
|
7
7
|
{
|
|
8
|
-
"id": "
|
|
8
|
+
"id": "Higro2000",
|
|
9
9
|
"type": "Higrometer",
|
|
10
10
|
"pressure": {
|
|
11
11
|
"type": "Hgmm",
|
|
12
|
-
"value": "
|
|
12
|
+
"value": "16"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
|
-
"id": "
|
|
16
|
+
"id": "Higro2002",
|
|
17
17
|
"type": "Higrometer",
|
|
18
18
|
"pressure": {
|
|
19
19
|
"type": "Hgmm",
|
|
20
|
-
"value": "
|
|
20
|
+
"value": "17"
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
]
|
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
"id": "ws7",
|
|
6
6
|
"type": "WeatherStation"
|
|
7
7
|
},
|
|
8
|
+
{
|
|
9
|
+
"pressure": {
|
|
10
|
+
"type": "Hgmm",
|
|
11
|
+
"value": "16"
|
|
12
|
+
},
|
|
13
|
+
"type": "Higrometer",
|
|
14
|
+
"id": "Higro2000"
|
|
15
|
+
},
|
|
8
16
|
{
|
|
9
17
|
"pressure": {
|
|
10
18
|
"type": "Hgmm",
|
|
@@ -18,14 +26,6 @@
|
|
|
18
26
|
},
|
|
19
27
|
"type": "Higrometer",
|
|
20
28
|
"id": "Higro2002"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"pressure": {
|
|
24
|
-
"type": "Hgmm",
|
|
25
|
-
"value": "16"
|
|
26
|
-
},
|
|
27
|
-
"type": "Higrometer",
|
|
28
|
-
"id": "Higro2000"
|
|
29
29
|
}
|
|
30
30
|
]
|
|
31
31
|
}
|
package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
"entities": [
|
|
3
|
+
{
|
|
4
|
+
"id": "ws4",
|
|
5
|
+
"type": "WeatherStation",
|
|
6
|
+
"TimeInstant": {
|
|
7
|
+
"type": "DateTime",
|
|
8
|
+
"value": "2016-05-30T16:25:22.304Z"
|
|
9
|
+
},
|
|
10
|
+
"pressure": {
|
|
11
|
+
"value": "52",
|
|
12
|
+
"type": "Hgmm",
|
|
13
|
+
"metadata": {
|
|
14
|
+
"TimeInstant": {
|
|
15
|
+
"type": "DateTime",
|
|
16
|
+
"value": "2016-05-30T16:25:22.304Z"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "Higro2000",
|
|
23
|
+
"type": "Higrometer",
|
|
24
|
+
"humidity": {
|
|
25
|
+
"value": "12",
|
|
26
|
+
"type": "Percentage",
|
|
27
|
+
"metadata": {
|
|
28
|
+
"unitCode": {
|
|
29
|
+
"type": "Text",
|
|
30
|
+
"value": "Hgmm"
|
|
31
|
+
},
|
|
32
|
+
"TimeInstant": {
|
|
33
|
+
"type": "DateTime",
|
|
34
|
+
"value": "2016-05-30T16:25:22.304Z"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"TimeInstant": {
|
|
39
|
+
"type": "DateTime",
|
|
40
|
+
"value": "2016-05-30T16:25:22.304Z"
|
|
41
|
+
}
|
|
13
42
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"type": "DateTime",
|
|
17
|
-
"value": "2016-05-30T16:25:22.304Z"
|
|
18
|
-
},
|
|
19
|
-
"id": "ws4",
|
|
20
|
-
"type": "WeatherStation"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"humidity": {
|
|
24
|
-
"type": "Percentage",
|
|
25
|
-
"value": "12",
|
|
26
|
-
"metadata": {
|
|
27
|
-
"unitCode": {
|
|
28
|
-
"type": "Text",
|
|
29
|
-
"value": "Hgmm"
|
|
30
|
-
},
|
|
31
|
-
"TimeInstant": {
|
|
32
|
-
"type": "DateTime",
|
|
33
|
-
"value": "2016-05-30T16:25:22.304Z"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"TimeInstant": {
|
|
38
|
-
"type": "DateTime",
|
|
39
|
-
"value": "2016-05-30T16:25:22.304Z"
|
|
40
|
-
},
|
|
41
|
-
"id": "Higro2000",
|
|
42
|
-
"type": "Higrometer"
|
|
43
|
-
}
|
|
44
|
-
]
|
|
43
|
+
],
|
|
44
|
+
"actionType": "update"
|
|
45
45
|
}
|
package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"actionType": "update",
|
|
3
2
|
"entities": [
|
|
4
3
|
{
|
|
5
4
|
"id": "ws4",
|
|
6
5
|
"type": "WeatherStation"
|
|
7
6
|
},
|
|
8
7
|
{
|
|
9
|
-
"
|
|
10
|
-
|
|
8
|
+
"id": "Higro2000",
|
|
9
|
+
"type": "Higrometer",
|
|
10
|
+
"humidity": {
|
|
11
11
|
"value": "12",
|
|
12
|
+
"type": "Percentage",
|
|
12
13
|
"metadata": {
|
|
13
14
|
"TimeInstant": {
|
|
14
15
|
"type": "DateTime",
|
|
@@ -20,9 +21,8 @@
|
|
|
20
21
|
"TimeInstant": {
|
|
21
22
|
"type": "DateTime",
|
|
22
23
|
"value": "2018-06-13T13:28:34.611Z"
|
|
23
|
-
}
|
|
24
|
-
"id": "Higro2000",
|
|
25
|
-
"type": "Higrometer"
|
|
24
|
+
}
|
|
26
25
|
}
|
|
27
|
-
]
|
|
26
|
+
],
|
|
27
|
+
"actionType": "update"
|
|
28
28
|
}
|
package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"actionType": "update",
|
|
3
|
-
"entities": [{
|
|
4
|
-
"id": "sensorCommand",
|
|
5
|
-
"type": "SensorCommand",
|
|
6
2
|
"PING_status": {
|
|
7
3
|
"type": "commandStatus",
|
|
8
4
|
"value": "OK",
|
|
@@ -27,5 +23,4 @@
|
|
|
27
23
|
"type": "DateTime",
|
|
28
24
|
"value": "2015-08-05T07:35:01.468Z"
|
|
29
25
|
}
|
|
30
|
-
}]
|
|
31
26
|
}
|
|
@@ -197,9 +197,6 @@ describe('NGSI-v2 - Expression-based transformations plugin', function () {
|
|
|
197
197
|
|
|
198
198
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
199
199
|
iotAgentLib.clearAll(function () {
|
|
200
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
201
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
202
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
203
200
|
done();
|
|
204
201
|
});
|
|
205
202
|
});
|
|
@@ -127,9 +127,6 @@ describe('Combine Jexl and legacy expressions (default JEXL) - NGSI v2', functio
|
|
|
127
127
|
|
|
128
128
|
iotAgentLib.activate(iotAgentConfigJexl, function () {
|
|
129
129
|
iotAgentLib.clearAll(function () {
|
|
130
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
131
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
132
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
133
130
|
done();
|
|
134
131
|
});
|
|
135
132
|
});
|
|
@@ -216,9 +213,6 @@ describe('Combine Jexl and legacy expressions (default Legacy) - NGSI v2', funct
|
|
|
216
213
|
|
|
217
214
|
iotAgentLib.activate(iotAgentConfigLegacy, function () {
|
|
218
215
|
iotAgentLib.clearAll(function () {
|
|
219
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
220
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
221
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
222
216
|
done();
|
|
223
217
|
});
|
|
224
218
|
});
|
|
@@ -346,7 +346,7 @@ const iotAgentConfig = {
|
|
|
346
346
|
expression: "{coordinates: [lon,lat], type: 'Point'}"
|
|
347
347
|
}
|
|
348
348
|
],
|
|
349
|
-
explicitAttrs: true
|
|
349
|
+
explicitAttrs: 'TimeInstant == null ? [] : true' // which is true
|
|
350
350
|
},
|
|
351
351
|
GPS7: {
|
|
352
352
|
commands: [],
|
|
@@ -418,9 +418,6 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
418
418
|
|
|
419
419
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
420
420
|
iotAgentLib.clearAll(function () {
|
|
421
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
422
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
423
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
424
421
|
done();
|
|
425
422
|
});
|
|
426
423
|
});
|
|
@@ -1316,9 +1313,6 @@ describe('Java expression language (JEXL) based transformations plugin - Timesta
|
|
|
1316
1313
|
|
|
1317
1314
|
iotAgentLib.activate(iotAgentConfigTS, function () {
|
|
1318
1315
|
iotAgentLib.clearAll(function () {
|
|
1319
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
1320
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
1321
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
1322
1316
|
done();
|
|
1323
1317
|
});
|
|
1324
1318
|
});
|
|
@@ -115,8 +115,6 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
115
115
|
|
|
116
116
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
117
117
|
iotAgentLib.clearAll(function () {
|
|
118
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
119
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
120
118
|
done();
|
|
121
119
|
});
|
|
122
120
|
});
|
|
@@ -241,7 +241,6 @@ describe('NGSI-v2 - Bidirectional data plugin', function () {
|
|
|
241
241
|
let transformedHandler = false;
|
|
242
242
|
|
|
243
243
|
function mockedHandler(device, values, callback) {
|
|
244
|
-
|
|
245
244
|
let latitudeFound = false;
|
|
246
245
|
let longitudeFound = false;
|
|
247
246
|
|
|
@@ -271,7 +270,6 @@ describe('NGSI-v2 - Bidirectional data plugin', function () {
|
|
|
271
270
|
});
|
|
272
271
|
});
|
|
273
272
|
|
|
274
|
-
|
|
275
273
|
describe('When a notification with metadata arrives for a bidirectional attribute', function () {
|
|
276
274
|
const notificationOptions = {
|
|
277
275
|
url: 'http://localhost:' + iotAgentConfig.server.port + '/notify',
|
|
@@ -314,7 +312,6 @@ describe('NGSI-v2 - Bidirectional data plugin', function () {
|
|
|
314
312
|
|
|
315
313
|
it('should execute the original handler', function (done) {
|
|
316
314
|
function mockedHandler(device, notification, callback) {
|
|
317
|
-
|
|
318
315
|
notification[0].name.should.equal('location');
|
|
319
316
|
notification[0].value.should.equal('12.4, -9.6');
|
|
320
317
|
notification[0].metadata.qos.value.should.equal(1);
|
|
@@ -384,7 +381,6 @@ describe('NGSI-v2 - Bidirectional data plugin', function () {
|
|
|
384
381
|
});
|
|
385
382
|
});
|
|
386
383
|
|
|
387
|
-
|
|
388
384
|
describe('When a new Group provisioning request arrives with bidirectional attributes', function () {
|
|
389
385
|
const provisionGroup = {
|
|
390
386
|
url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/services',
|
|
@@ -122,8 +122,6 @@ describe('NGSI-v2 - Timestamp compression plugin', function () {
|
|
|
122
122
|
logger.setLevel('FATAL');
|
|
123
123
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
124
124
|
iotAgentLib.clearAll(function () {
|
|
125
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.compressTimestamp.updateNgsi2);
|
|
126
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.compressTimestamp.queryNgsi2);
|
|
127
125
|
done();
|
|
128
126
|
});
|
|
129
127
|
});
|
|
@@ -217,34 +215,4 @@ describe('NGSI-v2 - Timestamp compression plugin', function () {
|
|
|
217
215
|
});
|
|
218
216
|
});
|
|
219
217
|
});
|
|
220
|
-
|
|
221
|
-
describe('When a query comes for a timestamp through the plugin', function () {
|
|
222
|
-
const values = ['state', 'TheTargetValue'];
|
|
223
|
-
|
|
224
|
-
beforeEach(function () {
|
|
225
|
-
nock.cleanAll();
|
|
226
|
-
|
|
227
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
228
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
229
|
-
.matchHeader('fiware-servicepath', 'gardens')
|
|
230
|
-
.get('/v2/entities/light1/attrs?attrs=state,TheTargetValue&type=Light')
|
|
231
|
-
.reply(
|
|
232
|
-
200,
|
|
233
|
-
utils.readExampleFile(
|
|
234
|
-
'./test/unit/ngsiv2/examples/contextResponses/queryContextCompressTimestamp1Success.json'
|
|
235
|
-
)
|
|
236
|
-
);
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
it('should return an entity with all its timestamps without separators (basic format)', function (done) {
|
|
240
|
-
iotAgentLib.query('light1', 'Light', '', values, function (error, response) {
|
|
241
|
-
should.not.exist(error);
|
|
242
|
-
should.exist(response);
|
|
243
|
-
should.exist(response.TheTargetValue);
|
|
244
|
-
should.exist(response.TheTargetValue.value);
|
|
245
|
-
response.TheTargetValue.value.should.equal('20071103T131805');
|
|
246
|
-
done();
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
218
|
});
|
|
@@ -573,10 +573,6 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
|
|
|
573
573
|
|
|
574
574
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
575
575
|
iotAgentLib.clearAll(function () {
|
|
576
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
577
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
578
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
579
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.multiEntity.update);
|
|
580
576
|
done();
|
|
581
577
|
});
|
|
582
578
|
});
|
|
@@ -1117,6 +1113,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
|
|
|
1117
1113
|
.post(
|
|
1118
1114
|
'/v2/op/update',
|
|
1119
1115
|
utils.readExampleFile(
|
|
1116
|
+
// Updated test same case that updateContextMultientityPlugin4.json
|
|
1120
1117
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json'
|
|
1121
1118
|
)
|
|
1122
1119
|
)
|
|
@@ -1423,10 +1420,6 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu
|
|
|
1423
1420
|
iotAgentConfig.timestamp = true;
|
|
1424
1421
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
1425
1422
|
iotAgentLib.clearAll(function () {
|
|
1426
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
1427
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
1428
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.multiEntity.update);
|
|
1429
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.timestampProcess.update);
|
|
1430
1423
|
done();
|
|
1431
1424
|
});
|
|
1432
1425
|
});
|
|
@@ -1507,7 +1500,7 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu
|
|
|
1507
1500
|
});
|
|
1508
1501
|
});
|
|
1509
1502
|
|
|
1510
|
-
it('should send two context elements, one for each entity', function (done) {
|
|
1503
|
+
it('should send two context elements, one for each entity bis', function (done) {
|
|
1511
1504
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1512
1505
|
.matchHeader('fiware-service', 'smartgondor')
|
|
1513
1506
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
@@ -1589,10 +1582,6 @@ describe('NGSI-v2 - Multi-entity plugin is executed for a command update for a r
|
|
|
1589
1582
|
timekeeper.freeze(time);
|
|
1590
1583
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
1591
1584
|
iotAgentLib.clearAll(function () {
|
|
1592
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
1593
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
1594
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.multiEntity.update);
|
|
1595
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.timestampProcess.update);
|
|
1596
1585
|
done();
|
|
1597
1586
|
});
|
|
1598
1587
|
});
|
|
@@ -1609,8 +1598,9 @@ describe('NGSI-v2 - Multi-entity plugin is executed for a command update for a r
|
|
|
1609
1598
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1610
1599
|
.matchHeader('fiware-service', 'smartgondor')
|
|
1611
1600
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
1612
|
-
.
|
|
1613
|
-
'/v2/op/update',
|
|
1601
|
+
.patch(
|
|
1602
|
+
//'/v2/op/update',
|
|
1603
|
+
'/v2/entities/sensorCommand/attrs?type=SensorCommand',
|
|
1614
1604
|
utils.readExampleFile(
|
|
1615
1605
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json'
|
|
1616
1606
|
)
|
|
@@ -67,7 +67,6 @@ describe('NGSI-v2 - Timestamp processing plugin', function () {
|
|
|
67
67
|
|
|
68
68
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
69
69
|
iotAgentLib.clearAll(function () {
|
|
70
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.timestampProcess.update);
|
|
71
70
|
done();
|
|
72
71
|
});
|
|
73
72
|
});
|
|
@@ -100,6 +99,7 @@ describe('NGSI-v2 - Timestamp processing plugin', function () {
|
|
|
100
99
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
101
100
|
.patch(
|
|
102
101
|
'/v2/entities/light1/attrs',
|
|
102
|
+
// this tests breaks jexlBasedTransformation-test with uses updateContextExpressionPlugin32 which do not includes Timestamp in metadata attributes
|
|
103
103
|
utils.readExampleFile(
|
|
104
104
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json'
|
|
105
105
|
)
|
package/lib/plugins/addEvent.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2016 Telefonica Investigación y Desarrollo, S.A.U
|
|
3
|
-
*
|
|
4
|
-
* This file is part of fiware-iotagent-lib
|
|
5
|
-
*
|
|
6
|
-
* fiware-iotagent-lib 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
|
-
* fiware-iotagent-lib 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 fiware-iotagent-lib.
|
|
18
|
-
* If not, see http://www.gnu.org/licenses/.
|
|
19
|
-
*
|
|
20
|
-
* For those usages not covered by the GNU Affero General Public License
|
|
21
|
-
* please contact with::daniel.moranjimenez@telefonica.com
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
const pluginUtils = require('./pluginUtils');
|
|
25
|
-
const config = require('../commonConfig');
|
|
26
|
-
|
|
27
|
-
function addEvents() {
|
|
28
|
-
return new Date().toISOString();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
exports.update = pluginUtils.createUpdateFilter(addEvents, config.getConfig().eventType || 'Event');
|
|
32
|
-
exports.query = pluginUtils.identityFilter;
|