iotagent-node-lib 3.0.0 → 3.2.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/config.js +5 -5
- package/doc/api.md +1540 -298
- package/doc/deprecated.md +3 -1
- package/doc/development.md +120 -0
- package/doc/installationguide.md +3 -6
- package/docker-compose-dev.yml +1 -1
- package/lib/commonConfig.js +7 -10
- package/lib/fiware-iotagent-lib.js +0 -10
- package/lib/jexlTranformsMap.js +2 -1
- package/lib/plugins/bidirectionalData.js +8 -26
- package/lib/plugins/expressionPlugin.js +8 -40
- package/lib/plugins/jexlParser.js +28 -0
- package/lib/services/commands/commandService.js +1 -1
- package/lib/services/devices/deviceService.js +2 -1
- package/lib/services/ngsi/entities-NGSI-LD.js +15 -73
- package/lib/services/ngsi/entities-NGSI-v2.js +149 -124
- package/lib/services/northBound/deviceProvisioningServer.js +17 -14
- package/lib/templates/createDevice.json +5 -2
- package/lib/templates/createDeviceLax.json +7 -5
- package/lib/templates/updateDevice.json +5 -2
- package/lib/templates/updateDeviceLax.json +3 -5
- package/package.json +2 -2
- package/test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json +5 -5
- package/test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice4.json +1 -0
- package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +4 -4
- 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 -1
- 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/expressions/jexlBasedTransformations-test.js +0 -2
- 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 +2 -1
- 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 -1
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +10 -9
- package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +2 -1
- package/test/unit/ngsi-ld/plugins/custom-plugin_test.js +152 -0
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +3 -2
- package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +2 -1
- 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/createMinimumProvisionedDevice4.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +0 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +20 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json +42 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +32 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +37 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +7 -1
- 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/jexlBasedTransformations-test.js +232 -8
- 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 +3 -3
- 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 -1
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +8 -7
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +2 -1
- package/test/unit/ngsiv2/plugins/custom-plugin_test.js +151 -0
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +87 -13
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -1
- 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 +12 -3
- 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/doc/advanced-topics.md +0 -626
- package/doc/expressionLanguage.md +0 -762
- package/lib/plugins/expressionParser.js +0 -205
- package/test/unit/expressions/expression-test.js +0 -197
- package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +0 -881
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +0 -950
- package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +0 -294
|
@@ -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
|
service: 'smartgondor',
|
|
@@ -48,7 +49,6 @@ const iotAgentConfig = {
|
|
|
48
49
|
providerUrl: 'http://smartgondor.com'
|
|
49
50
|
};
|
|
50
51
|
|
|
51
|
-
|
|
52
52
|
const iotAgentConfigWithLimitedSupport = {
|
|
53
53
|
contextBroker: {
|
|
54
54
|
host: '192.168.1.1',
|
|
@@ -58,10 +58,11 @@ const iotAgentConfigWithLimitedSupport = {
|
|
|
58
58
|
},
|
|
59
59
|
server: {
|
|
60
60
|
port: 4041,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
host: 'localhost',
|
|
62
|
+
ldSupport: {
|
|
63
|
+
null: false,
|
|
64
|
+
datasetId: false
|
|
65
|
+
}
|
|
65
66
|
},
|
|
66
67
|
types: {
|
|
67
68
|
Robot: {
|
|
@@ -91,7 +92,6 @@ const device = {
|
|
|
91
92
|
service: 'smartgondor'
|
|
92
93
|
};
|
|
93
94
|
|
|
94
|
-
|
|
95
95
|
describe('NGSI-LD - Unsupported Endpoints', function () {
|
|
96
96
|
beforeEach(function (done) {
|
|
97
97
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
@@ -153,7 +153,6 @@ describe('NGSI-LD - Unsupported Endpoints', function () {
|
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
-
|
|
157
156
|
it('PUT /entities/<entity-id> includes an NGSI-LD Null should return a valid NSGI-LD error message', function (done) {
|
|
158
157
|
const options = {
|
|
159
158
|
url:
|
|
@@ -162,7 +161,7 @@ describe('NGSI-LD - Unsupported Endpoints', function () {
|
|
|
162
161
|
'/ngsi-ld/v1/entities/urn:ngsi-ld:entity/attrs/att',
|
|
163
162
|
method: 'PUT',
|
|
164
163
|
json: {
|
|
165
|
-
|
|
164
|
+
value: 'urn:ngsi-ld:null'
|
|
166
165
|
},
|
|
167
166
|
headers: {
|
|
168
167
|
'fiware-service': 'smartgondor',
|
|
@@ -194,7 +193,6 @@ describe('NGSI-LD - Limiting Support', function () {
|
|
|
194
193
|
.post('/ngsi-ld/v1/entityOperations/upsert/')
|
|
195
194
|
.reply(204);
|
|
196
195
|
|
|
197
|
-
|
|
198
196
|
iotAgentLib.activate(iotAgentConfigWithLimitedSupport, function () {
|
|
199
197
|
iotAgentLib.clearAll(function () {
|
|
200
198
|
done();
|
|
@@ -217,7 +215,7 @@ describe('NGSI-LD - Limiting Support', function () {
|
|
|
217
215
|
'/ngsi-ld/v1/entities/urn:ngsi-ld:Robot:r2d2/attrs/position',
|
|
218
216
|
method: 'PATCH',
|
|
219
217
|
json: {
|
|
220
|
-
|
|
218
|
+
value: 'urn:ngsi-ld:null'
|
|
221
219
|
},
|
|
222
220
|
headers: {
|
|
223
221
|
'fiware-service': 'smartgondor',
|
|
@@ -235,9 +233,8 @@ describe('NGSI-LD - Limiting Support', function () {
|
|
|
235
233
|
done();
|
|
236
234
|
});
|
|
237
235
|
});
|
|
238
|
-
|
|
239
236
|
});
|
|
240
|
-
});
|
|
237
|
+
});
|
|
241
238
|
describe('When sending a payload including a datasetId when datasetIds are unsupported ', function () {
|
|
242
239
|
it('should return a valid NSGI-LD error message', function (done) {
|
|
243
240
|
const options = {
|
|
@@ -276,7 +273,6 @@ describe('NGSI-LD - Limiting Support', function () {
|
|
|
276
273
|
done();
|
|
277
274
|
});
|
|
278
275
|
});
|
|
279
|
-
|
|
280
276
|
});
|
|
281
|
-
});
|
|
277
|
+
});
|
|
282
278
|
});
|
|
@@ -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
|
service: 'smartgondor',
|
|
@@ -239,11 +240,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
|
|
|
239
240
|
let longitudeFound = false;
|
|
240
241
|
|
|
241
242
|
for (let i = 0; i < values.length; i++) {
|
|
242
|
-
if (values[i].name === 'latitude' && values[i].type === '
|
|
243
|
+
if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
|
|
243
244
|
latitudeFound = true;
|
|
244
245
|
}
|
|
245
246
|
|
|
246
|
-
if (values[i].name === 'longitude' && values[i].type === '
|
|
247
|
+
if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
|
|
247
248
|
longitudeFound = true;
|
|
248
249
|
}
|
|
249
250
|
}
|
|
@@ -347,11 +348,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
|
|
|
347
348
|
let longitudeFound = false;
|
|
348
349
|
|
|
349
350
|
for (let i = 0; i < values.length; i++) {
|
|
350
|
-
if (values[i].name === 'latitude' && values[i].type === '
|
|
351
|
+
if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
|
|
351
352
|
latitudeFound = true;
|
|
352
353
|
}
|
|
353
354
|
|
|
354
|
-
if (values[i].name === 'longitude' && values[i].type === '
|
|
355
|
+
if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
|
|
355
356
|
longitudeFound = true;
|
|
356
357
|
}
|
|
357
358
|
}
|
|
@@ -460,11 +461,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
|
|
|
460
461
|
let longitudeFound = false;
|
|
461
462
|
|
|
462
463
|
for (let i = 0; i < values.length; i++) {
|
|
463
|
-
if (values[i].name === 'latitude' && values[i].type === '
|
|
464
|
+
if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
|
|
464
465
|
latitudeFound = true;
|
|
465
466
|
}
|
|
466
467
|
|
|
467
|
-
if (values[i].name === 'longitude' && values[i].type === '
|
|
468
|
+
if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
|
|
468
469
|
longitudeFound = true;
|
|
469
470
|
}
|
|
470
471
|
}
|
|
@@ -602,11 +603,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
|
|
|
602
603
|
let longitudeFound = false;
|
|
603
604
|
|
|
604
605
|
for (let i = 0; i < values.length; i++) {
|
|
605
|
-
if (values[i].name === 'latitude' && values[i].type === '
|
|
606
|
+
if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
|
|
606
607
|
latitudeFound = true;
|
|
607
608
|
}
|
|
608
609
|
|
|
609
|
-
if (values[i].name === 'longitude' && values[i].type === '
|
|
610
|
+
if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
|
|
610
611
|
longitudeFound = true;
|
|
611
612
|
}
|
|
612
613
|
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2015 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
|
+
* Modified by: Daniel Calvo - ATOS Research & Innovation
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
27
|
+
const should = require('should');
|
|
28
|
+
const logger = require('logops');
|
|
29
|
+
const nock = require('nock');
|
|
30
|
+
let contextBrokerMock;
|
|
31
|
+
const iotAgentConfig = {
|
|
32
|
+
contextBroker: {
|
|
33
|
+
host: '192.168.1.1',
|
|
34
|
+
port: '1026',
|
|
35
|
+
ngsiVersion: 'ld',
|
|
36
|
+
jsonLdContext: 'http://context.json-ld'
|
|
37
|
+
},
|
|
38
|
+
server: {
|
|
39
|
+
port: 4041
|
|
40
|
+
},
|
|
41
|
+
types: {
|
|
42
|
+
Light: {
|
|
43
|
+
commands: [],
|
|
44
|
+
type: 'Light',
|
|
45
|
+
lazy: [
|
|
46
|
+
{
|
|
47
|
+
name: 'temperature',
|
|
48
|
+
type: 'centigrades'
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
active: [
|
|
52
|
+
{
|
|
53
|
+
name: 'pressure',
|
|
54
|
+
type: 'Hgmm'
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
service: 'smartgondor',
|
|
60
|
+
subservice: 'gardens',
|
|
61
|
+
providerUrl: 'http://smartgondor.com'
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
describe('NGSI-LD - Custom plugin', function () {
|
|
65
|
+
let updateInvoked = false;
|
|
66
|
+
let queryInvoked = false;
|
|
67
|
+
|
|
68
|
+
function updatePlugin(entity, typeInformation, callback) {
|
|
69
|
+
updateInvoked = true;
|
|
70
|
+
return callback(null, entity, typeInformation);
|
|
71
|
+
}
|
|
72
|
+
function queryPlugin(entity, typeInformation, callback) {
|
|
73
|
+
queryInvoked = true;
|
|
74
|
+
return callback(null, entity, typeInformation);
|
|
75
|
+
}
|
|
76
|
+
beforeEach(function (done) {
|
|
77
|
+
logger.setLevel('FATAL');
|
|
78
|
+
|
|
79
|
+
iotAgentLib.activate(iotAgentConfig, function () {
|
|
80
|
+
iotAgentLib.clearAll(function () {
|
|
81
|
+
iotAgentLib.addUpdateMiddleware(updatePlugin);
|
|
82
|
+
iotAgentLib.addQueryMiddleware(queryPlugin);
|
|
83
|
+
done();
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
afterEach(function (done) {
|
|
89
|
+
iotAgentLib.clearAll(function () {
|
|
90
|
+
iotAgentLib.deactivate(done);
|
|
91
|
+
updateInvoked = false;
|
|
92
|
+
queryInvoked = false;
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
describe('When an update occurs', function () {
|
|
96
|
+
const values = [
|
|
97
|
+
{
|
|
98
|
+
name: 'state',
|
|
99
|
+
type: 'Boolean',
|
|
100
|
+
value: 'true'
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'dimming',
|
|
104
|
+
type: 'Number',
|
|
105
|
+
value: 23
|
|
106
|
+
}
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
beforeEach(function () {
|
|
110
|
+
nock.cleanAll();
|
|
111
|
+
|
|
112
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
113
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
114
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
115
|
+
.post('/ngsi-ld/v1/entityOperations/upsert/')
|
|
116
|
+
.query({ options: 'update' })
|
|
117
|
+
.reply(204);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('should invoke the plugin', function (done) {
|
|
121
|
+
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
122
|
+
should.not.exist(error);
|
|
123
|
+
contextBrokerMock.done();
|
|
124
|
+
updateInvoked.should.equal(true);
|
|
125
|
+
done();
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
describe('When an query occurs', function () {
|
|
130
|
+
beforeEach(function () {
|
|
131
|
+
nock.cleanAll();
|
|
132
|
+
|
|
133
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
134
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
135
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
136
|
+
.get('/ngsi-ld/v1/entities/urn:ngsi-ld:Light:light1')
|
|
137
|
+
.query({ attrs: 'state,dimming' })
|
|
138
|
+
.reply(200, { state: 'good', dimming: '23' });
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should invoke the plugin', function (done) {
|
|
142
|
+
const attributes = ['state', 'dimming'];
|
|
143
|
+
iotAgentLib.query('light1', 'Light', '', attributes, function (error) {
|
|
144
|
+
should.not.exist(error);
|
|
145
|
+
contextBrokerMock.done();
|
|
146
|
+
should.not.exist(error);
|
|
147
|
+
queryInvoked.should.equal(true);
|
|
148
|
+
done();
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
@@ -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: {
|
|
@@ -95,7 +96,7 @@ const iotAgentConfig = {
|
|
|
95
96
|
object_id: 'h',
|
|
96
97
|
name: 'humidity',
|
|
97
98
|
type: 'Percentage',
|
|
98
|
-
entity_name: 'Station Number
|
|
99
|
+
entity_name: '"Station Number "+sn*10'
|
|
99
100
|
}
|
|
100
101
|
]
|
|
101
102
|
},
|
|
@@ -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
|
});
|
|
@@ -1,2 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
+
"TimeInstant": {
|
|
3
|
+
"type": "DateTime",
|
|
4
|
+
"value": "2015-08-05T07:35:01.468+00:00"
|
|
5
|
+
},
|
|
6
|
+
"location": {
|
|
7
|
+
"value": {
|
|
8
|
+
"coordinates": [
|
|
9
|
+
13,
|
|
10
|
+
52
|
|
11
|
+
],
|
|
12
|
+
"type": "Point"
|
|
13
|
+
},
|
|
14
|
+
"type": "geo:json",
|
|
15
|
+
"metadata": {
|
|
16
|
+
"TimeInstant": {
|
|
17
|
+
"type": "DateTime",
|
|
18
|
+
"value": "2015-08-05T07:35:01.468+00:00"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
2
22
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"entities": [
|
|
3
|
+
{
|
|
4
|
+
"id": "water1",
|
|
5
|
+
"type": "WaterTank",
|
|
6
|
+
"contB": {
|
|
7
|
+
"value": "31450.000",
|
|
8
|
+
"type": "Number",
|
|
9
|
+
"metadata": {
|
|
10
|
+
"TimeInstant": {
|
|
11
|
+
"type": "DateTime",
|
|
12
|
+
"value": "2015-08-05T07:35:01.468Z"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"TimeInstant": {
|
|
17
|
+
"type": "DateTime",
|
|
18
|
+
"value": "2015-08-05T07:35:01.468Z"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "PA_B_0001",
|
|
23
|
+
"type": "WaterTank",
|
|
24
|
+
"waterLeavingTanks": {
|
|
25
|
+
"value": 3145,
|
|
26
|
+
"type": "Number",
|
|
27
|
+
"metadata": {
|
|
28
|
+
"TimeInstant": {
|
|
29
|
+
"type": "DateTime",
|
|
30
|
+
"value": "2015-08-05T07:35:01.468Z"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"TimeInstant": {
|
|
35
|
+
"type": "DateTime",
|
|
36
|
+
"value": "2015-08-05T07:35:01.468Z"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"actionType": "update"
|
|
41
|
+
}
|
|
42
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"TimeInstant": {
|
|
3
|
+
"type": "DateTime",
|
|
4
|
+
"value": "2015-08-05T07:35:01.468+00:00"
|
|
5
|
+
},
|
|
6
|
+
"location": {
|
|
7
|
+
"value": {
|
|
8
|
+
"coordinates": [
|
|
9
|
+
13,
|
|
10
|
+
52
|
|
11
|
+
],
|
|
12
|
+
"type": "Point"
|
|
13
|
+
},
|
|
14
|
+
"type": "geo:json",
|
|
15
|
+
"metadata": {
|
|
16
|
+
"TimeInstant": {
|
|
17
|
+
"type": "DateTime",
|
|
18
|
+
"value": "2015-08-05T07:35:01.468+00:00"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"temperature": {
|
|
23
|
+
"value": null,
|
|
24
|
+
"type": "Number",
|
|
25
|
+
"metadata": {
|
|
26
|
+
"TimeInstant": {
|
|
27
|
+
"type": "DateTime",
|
|
28
|
+
"value": "2015-08-05T07:35:01.468+00:00"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|