iotagent-node-lib 2.26.0 → 3.1.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/.github/workflows/ci.yml +1 -0
- package/CHANGES_NEXT_RELEASE +2 -0
- package/docker-compose-dev.yml +1 -1
- 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 +586 -199
- package/lib/services/ngsi/entities-NGSI-v2.js +607 -297
- package/lib/services/ngsi/ngsiUtils.js +15 -22
- package/package.json +2 -2
- package/test/unit/general/config-multi-core-test.js +2 -1
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +2 -1
- package/test/unit/general/deviceService-test.js +2 -1
- package/test/unit/general/loglevel-api_test.js +2 -3
- package/test/unit/general/startup-test.js +2 -1
- package/test/unit/general/statistics-persistence_test.js +1 -0
- package/test/unit/general/statistics-service_test.js +1 -0
- package/test/unit/lazyAndCommands/commandRegistry_test.js +1 -0
- package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +1 -0
- package/test/unit/mongodb/mongodb-connectionoptions-test.js +1 -0
- package/test/unit/mongodb/mongodb-group-registry-test.js +1 -0
- package/test/unit/mongodb/mongodb-registry-test.js +2 -1
- 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 +4 -6
- package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +1 -7
- package/test/unit/ngsi-ld/general/config-jsonld-contexts-test.js +2 -1
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +2 -1
- package/test/unit/ngsi-ld/general/deviceService-test.js +2 -1
- package/test/unit/ngsi-ld/general/https-support-test.js +2 -1
- package/test/unit/ngsi-ld/general/iotam-autoregistration-test.js +2 -1
- package/test/unit/ngsi-ld/general/startup-test.js +3 -2
- package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +2 -1
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +5 -7
- package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +8 -6
- package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +18 -22
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +17 -4
- package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +32 -34
- package/test/unit/ngsi-ld/ngsiService/staticAttributes-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/unsupported-endpoints-test.js +11 -15
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +2 -3
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +2 -1
- package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +2 -32
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +20 -19
- package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +21 -7
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +2 -1
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +15 -12
- package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +1 -0
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +13 -7
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json +2 -2
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +6 -0
- 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 +6 -6
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +7 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +7 -1
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +2 -4
- package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +4 -8
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +5 -9
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +2 -1
- package/test/unit/ngsiv2/general/deviceService-test.js +2 -1
- package/test/unit/ngsiv2/general/https-support-test.js +2 -1
- package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +2 -1
- package/test/unit/ngsiv2/general/startup-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +8 -6
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +2 -1
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +3 -2
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +2 -1
- package/test/unit/ngsiv2/ngsiService/queryDeviceInformationInCb-test.js +2 -1
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +2 -1
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +2 -1
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +2 -3
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +2 -5
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +2 -33
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +7 -16
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +3 -2
- package/test/unit/ngsiv2/provisioning/device-group-api-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +1 -0
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +2 -1
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +15 -12
- package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +1 -0
- package/test/unit/plugins/capture-configuration-inPlugins_test.js +2 -1
- package/test/unit/plugins/capture-provision-inPlugins_test.js +2 -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
|
@@ -37,7 +37,8 @@ const iotAgentConfig = {
|
|
|
37
37
|
jsonLdContext: 'http://context.json-ld'
|
|
38
38
|
},
|
|
39
39
|
server: {
|
|
40
|
-
port: 4041
|
|
40
|
+
port: 4041,
|
|
41
|
+
host: 'localhost'
|
|
41
42
|
},
|
|
42
43
|
types: {
|
|
43
44
|
Light: {
|
|
@@ -123,8 +124,6 @@ describe('NGSI-LD - Timestamp compression plugin', function () {
|
|
|
123
124
|
logger.setLevel('FATAL');
|
|
124
125
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
125
126
|
iotAgentLib.clearAll(function () {
|
|
126
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.compressTimestamp.updateNgsi2);
|
|
127
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.compressTimestamp.queryNgsi2);
|
|
128
127
|
done();
|
|
129
128
|
});
|
|
130
129
|
});
|
|
@@ -214,33 +213,4 @@ describe('NGSI-LD - Timestamp compression plugin', function () {
|
|
|
214
213
|
});
|
|
215
214
|
});
|
|
216
215
|
});
|
|
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
216
|
});
|
|
@@ -41,7 +41,8 @@ const iotAgentConfig = {
|
|
|
41
41
|
jsonLdContext: 'http://context.json-ld'
|
|
42
42
|
},
|
|
43
43
|
server: {
|
|
44
|
-
port: 4041
|
|
44
|
+
port: 4041,
|
|
45
|
+
host: 'localhost'
|
|
45
46
|
},
|
|
46
47
|
types: {
|
|
47
48
|
WeatherStation: {
|
|
@@ -246,9 +247,6 @@ describe('NGSI-LD - Multi-entity plugin', function () {
|
|
|
246
247
|
logger.setLevel('FATAL');
|
|
247
248
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
248
249
|
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
250
|
done();
|
|
253
251
|
});
|
|
254
252
|
});
|
|
@@ -614,15 +612,9 @@ describe('NGSI-LD - Multi-entity plugin', function () {
|
|
|
614
612
|
|
|
615
613
|
describe('NGSI-LD - Multi-entity plugin is executed before timestamp process plugin', function () {
|
|
616
614
|
beforeEach(function (done) {
|
|
617
|
-
logger.setLevel('FATAL');
|
|
618
|
-
|
|
619
615
|
iotAgentConfig.timestamp = true;
|
|
620
616
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
621
617
|
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
618
|
done();
|
|
627
619
|
});
|
|
628
620
|
});
|
|
@@ -731,13 +723,26 @@ describe('NGSI-LD - Multi-entity plugin is executed before timestamp process plu
|
|
|
731
723
|
it('should propagate user provider timestamp to mapped entities', function (done) {
|
|
732
724
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
733
725
|
.matchHeader('fiware-service', 'smartgondor')
|
|
734
|
-
.post(
|
|
735
|
-
|
|
736
|
-
utils.readExampleFile(
|
|
726
|
+
.post('/ngsi-ld/v1/entityOperations/upsert/?options=update', function (body) {
|
|
727
|
+
const expectedBody = utils.readExampleFile(
|
|
737
728
|
'./test/unit/ngsi-ld/examples' +
|
|
738
729
|
'/contextRequests/updateContextMultientityTimestampPlugin3.json'
|
|
739
|
-
)
|
|
740
|
-
|
|
730
|
+
);
|
|
731
|
+
|
|
732
|
+
// Note that TimeInstant fields are not included in the json used by this mock as they are dynamic
|
|
733
|
+
// fields. The following code just checks that TimeInstant fields are present.
|
|
734
|
+
if (!body[1].humidity.observedAt) {
|
|
735
|
+
return false;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
const timeInstantAtt = body[1].humidity.observedAt;
|
|
739
|
+
if (moment(timeInstantAtt, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid) {
|
|
740
|
+
delete body[1].humidity.observedAt;
|
|
741
|
+
delete expectedBody[1].humidity.observedAt;
|
|
742
|
+
return JSON.stringify(body) === JSON.stringify(expectedBody);
|
|
743
|
+
}
|
|
744
|
+
return false;
|
|
745
|
+
})
|
|
741
746
|
.reply(204);
|
|
742
747
|
|
|
743
748
|
const tsValue = [
|
|
@@ -772,10 +777,6 @@ describe('NGSI-LD - Multi-entity plugin is executed for a command update for a r
|
|
|
772
777
|
timekeeper.freeze(time);
|
|
773
778
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
774
779
|
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
780
|
done();
|
|
780
781
|
});
|
|
781
782
|
});
|
|
@@ -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: {
|
|
@@ -37,7 +38,8 @@ const iotAgentConfig = {
|
|
|
37
38
|
jsonLdContext: 'http://context.json-ld'
|
|
38
39
|
},
|
|
39
40
|
server: {
|
|
40
|
-
port: 4041
|
|
41
|
+
port: 4041,
|
|
42
|
+
host: 'localhost'
|
|
41
43
|
},
|
|
42
44
|
types: {
|
|
43
45
|
Light: {
|
|
@@ -68,7 +70,6 @@ describe('NGSI-LD - Timestamp processing plugin', function () {
|
|
|
68
70
|
|
|
69
71
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
70
72
|
iotAgentLib.clearAll(function () {
|
|
71
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.timestampProcess.update);
|
|
72
73
|
done();
|
|
73
74
|
});
|
|
74
75
|
});
|
|
@@ -98,12 +99,25 @@ describe('NGSI-LD - Timestamp processing plugin', function () {
|
|
|
98
99
|
|
|
99
100
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
100
101
|
.matchHeader('fiware-service', 'smartgondor')
|
|
101
|
-
.post(
|
|
102
|
-
|
|
103
|
-
utils.readExampleFile(
|
|
102
|
+
.post('/ngsi-ld/v1/entityOperations/upsert/?options=update', function (body) {
|
|
103
|
+
const expectedBody = utils.readExampleFile(
|
|
104
104
|
'./test/unit/ngsi-ld/examples/contextRequests/updateContextProcessTimestamp.json'
|
|
105
|
-
)
|
|
106
|
-
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
// Note that TimeInstant fields are not included in the json used by this mock as they are dynamic
|
|
108
|
+
// fields. The following code just checks that TimeInstant fields are present.
|
|
109
|
+
if (!body[0].state.observedAt) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const timeInstantAtt = body[0].state.observedAt;
|
|
114
|
+
if (moment(timeInstantAtt, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid) {
|
|
115
|
+
delete body[0].state.observedAt;
|
|
116
|
+
delete expectedBody[0].state.observedAt;
|
|
117
|
+
return JSON.stringify(body) === JSON.stringify(expectedBody);
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
})
|
|
107
121
|
.reply(204);
|
|
108
122
|
});
|
|
109
123
|
|
|
@@ -40,7 +40,8 @@ const iotAgentConfig = {
|
|
|
40
40
|
jsonLdContext: 'http://context.json-ld'
|
|
41
41
|
},
|
|
42
42
|
server: {
|
|
43
|
-
port: 4041
|
|
43
|
+
port: 4041,
|
|
44
|
+
host: 'localhost'
|
|
44
45
|
},
|
|
45
46
|
types: {
|
|
46
47
|
Light: {
|
|
@@ -244,17 +245,19 @@ describe('NGSI-LD - IoT Agent Device Update Registration', function () {
|
|
|
244
245
|
});
|
|
245
246
|
it('should store the new values in the registry', function (done) {
|
|
246
247
|
iotAgentLib.updateRegister(deviceCommandUpdated, false, function (error, data) {
|
|
247
|
-
iotAgentLib.getDevice(
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
248
|
+
iotAgentLib.getDevice(
|
|
249
|
+
deviceCommandUpdated.id,
|
|
250
|
+
'smartgondor',
|
|
251
|
+
'gardens',
|
|
252
|
+
function (error, deviceResult) {
|
|
253
|
+
should.not.exist(error);
|
|
254
|
+
should.exist(deviceResult);
|
|
255
|
+
deviceResult.internalId.should.equal(deviceUpdated.internalId);
|
|
256
|
+
deviceResult.commands[0].name.should.equal('move');
|
|
257
|
+
deviceResult.active[0].name.should.equal('temperature');
|
|
258
|
+
done();
|
|
259
|
+
}
|
|
260
|
+
);
|
|
258
261
|
});
|
|
259
262
|
});
|
|
260
263
|
});
|
|
@@ -40,6 +40,7 @@ const iotAgentConfig = {
|
|
|
40
40
|
server: {
|
|
41
41
|
name: 'testAgent',
|
|
42
42
|
port: 4041,
|
|
43
|
+
host: 'localhost',
|
|
43
44
|
baseRoot: '/'
|
|
44
45
|
},
|
|
45
46
|
types: {},
|
|
@@ -268,13 +269,18 @@ describe('Mixed Mode: ngsiVersion test', function () {
|
|
|
268
269
|
});
|
|
269
270
|
});
|
|
270
271
|
it('should operate using NGSI-v2', function (done) {
|
|
271
|
-
iotAgentLib.update(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
272
|
+
iotAgentLib.update(
|
|
273
|
+
'light2',
|
|
274
|
+
'Device',
|
|
275
|
+
'v2-test',
|
|
276
|
+
values,
|
|
277
|
+
{ ngsiVersion: 'v2', type: 'Device' },
|
|
278
|
+
function (error) {
|
|
279
|
+
should.not.exist(error);
|
|
280
|
+
contextBrokerMock.done();
|
|
281
|
+
done();
|
|
282
|
+
}
|
|
283
|
+
);
|
|
278
284
|
});
|
|
279
285
|
});
|
|
280
286
|
});
|
|
@@ -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
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"state":{
|
|
3
3
|
"type": "Boolean",
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
"value": true,
|
|
5
|
+
"metadata": {
|
|
6
|
+
"TimeInstant": {
|
|
7
|
+
"type": "DateTime",
|
|
8
|
+
"value": "2016-05-30T16:25:22.304Z"
|
|
9
|
+
}
|
|
9
10
|
}
|
|
10
|
-
}
|
|
11
11
|
},
|
|
12
12
|
"TimeInstant":
|
|
13
13
|
{
|