iotagent-node-lib 2.18.0 → 2.19.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 -2
- package/doc/advanced-topics.md +122 -53
- package/doc/api.md +52 -52
- package/doc/development.md +8 -9
- package/doc/expressionLanguage.md +514 -316
- package/doc/installationguide.md +66 -64
- package/doc/usermanual.md +48 -16
- package/docker/Mosquitto/Dockerfile +1 -0
- package/docker/Mosquitto/README.md +1 -0
- package/docker/Mosquitto/startMosquitto.sh +6 -4
- package/lib/command/commandLine.js +1 -1
- package/lib/fiware-iotagent-lib.js +3 -0
- package/lib/jexlTranformsMap.js +9 -1
- package/lib/model/Device.js +4 -1
- package/lib/model/Group.js +19 -1
- package/lib/plugins/expressionParser.js +6 -4
- package/lib/plugins/expressionPlugin.js +8 -1
- package/lib/plugins/jexlParser.js +3 -1
- package/lib/request-shim.js +111 -0
- package/lib/services/common/genericMiddleware.js +6 -2
- package/lib/services/common/iotManagerService.js +1 -1
- package/lib/services/common/securityServiceKeystone.js +1 -1
- package/lib/services/common/securityServiceOAuth2.js +3 -2
- package/lib/services/devices/deviceRegistryMongoDB.js +1 -0
- package/lib/services/devices/devices-NGSI-LD.js +1 -1
- package/lib/services/devices/devices-NGSI-v2.js +2 -6
- package/lib/services/devices/registrationUtils.js +0 -2
- package/lib/services/ngsi/entities-NGSI-LD.js +95 -11
- package/lib/services/ngsi/entities-NGSI-v2.js +93 -8
- package/lib/services/ngsi/ngsiService.js +3 -2
- package/lib/services/northBound/contextServer-NGSI-LD.js +3 -2
- package/lib/services/northBound/deviceProvisioningServer.js +29 -6
- package/lib/services/northBound/northboundServer.js +2 -0
- package/lib/services/northBound/restUtils.js +1 -1
- package/package.json +4 -4
- package/test/tools/utils.js +2 -0
- package/test/unit/expressions/jexlExpression-test.js +5 -5
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +1 -1
- package/test/unit/general/deviceService-test.js +2 -5
- package/test/unit/general/loglevel-api_test.js +6 -11
- package/test/unit/general/migration-test.js +1 -0
- package/test/unit/general/startup-test.js +1 -0
- package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +1 -0
- package/test/unit/mongodb/mongodb-group-registry-test.js +1 -1
- package/test/unit/mongodb/mongodb-registry-test.js +2 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin12a.json +7 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin13.json +13 -13
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin1a.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin29.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin31.json +15 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +17 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin33.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin34.json +17 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4a.json +36 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin7.json +16 -16
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin8a.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin15.json +25 -0
- package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +1018 -0
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +2 -2
- package/test/unit/ngsi-ld/general/deviceService-test.js +1 -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 +1 -0
- package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +3 -1
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +2 -1
- package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +2 -6
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +1 -0
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +1 -0
- package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +1 -0
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +4 -3
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +1 -0
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +3 -2
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +61 -0
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +2 -1
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +3 -2
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +42 -54
- package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +2 -1
- package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +4 -4
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +3 -5
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +12 -18
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin17.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +16 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +22 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +25 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +25 -0
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +4 -4
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +500 -0
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +3 -2
- package/test/unit/ngsiv2/general/deviceService-test.js +9 -8
- 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 +1 -0
- package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +3 -1
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +14 -18
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +3 -1
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +1 -0
- package/test/unit/ngsiv2/ngsiService/queryDeviceInformationInCb-test.js +0 -1
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +4 -3
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +3 -2
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +210 -0
- package/test/unit/ngsiv2/plugins/translation-inPlugins_test.js +1 -1
- package/test/unit/ngsiv2/provisioning/device-group-api-test.js +3 -2
- package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +2 -1
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +2 -1
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +3 -2
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +4 -3
- package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +42 -53
- package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +2 -1
- package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +4 -4
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +3 -4
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +13 -19
- package/test/unit/plugins/capture-configuration-inPlugins_test.js +3 -1
- package/test/unit/plugins/capture-provision-inPlugins_test.js +2 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin20.json +0 -25
|
@@ -27,16 +27,18 @@
|
|
|
27
27
|
|
|
28
28
|
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
29
29
|
const utils = require('../../../tools/utils');
|
|
30
|
+
const request = utils.request;
|
|
30
31
|
const async = require('async');
|
|
31
32
|
const apply = async.apply;
|
|
32
33
|
const should = require('should');
|
|
33
34
|
const logger = require('logops');
|
|
34
35
|
const nock = require('nock');
|
|
35
36
|
const mongoUtils = require('../../mongodb/mongoDBUtils');
|
|
36
|
-
|
|
37
|
+
|
|
37
38
|
const timekeeper = require('timekeeper');
|
|
38
39
|
let contextBrokerMock;
|
|
39
40
|
const iotAgentConfig = {
|
|
41
|
+
logLevel: 'FATAL',
|
|
40
42
|
contextBroker: {
|
|
41
43
|
host: '192.168.1.1',
|
|
42
44
|
port: '1026',
|
|
@@ -235,12 +237,11 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
235
237
|
const options = {
|
|
236
238
|
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query',
|
|
237
239
|
method: 'POST',
|
|
238
|
-
json: true,
|
|
239
240
|
headers: {
|
|
240
241
|
'fiware-service': 'smartgondor',
|
|
241
242
|
'fiware-servicepath': 'gardens'
|
|
242
243
|
},
|
|
243
|
-
|
|
244
|
+
json: {
|
|
244
245
|
entities: [
|
|
245
246
|
{
|
|
246
247
|
id: 'Light:light1'
|
|
@@ -307,12 +308,12 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
307
308
|
const options = {
|
|
308
309
|
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query',
|
|
309
310
|
method: 'POST',
|
|
310
|
-
|
|
311
|
+
|
|
311
312
|
headers: {
|
|
312
313
|
'fiware-service': 'smartgondor',
|
|
313
314
|
'fiware-servicepath': 'gardens'
|
|
314
315
|
},
|
|
315
|
-
|
|
316
|
+
json: {
|
|
316
317
|
entities: [
|
|
317
318
|
{
|
|
318
319
|
id: 'Light:light1'
|
|
@@ -370,12 +371,12 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
370
371
|
const options = {
|
|
371
372
|
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query',
|
|
372
373
|
method: 'POST',
|
|
373
|
-
|
|
374
|
+
|
|
374
375
|
headers: {
|
|
375
376
|
'fiware-service': 'smartgondor',
|
|
376
377
|
'fiware-servicepath': 'gardens'
|
|
377
378
|
},
|
|
378
|
-
|
|
379
|
+
json: {
|
|
379
380
|
entities: [
|
|
380
381
|
{
|
|
381
382
|
id: 'Light:light1'
|
|
@@ -441,12 +442,11 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
441
442
|
const options = {
|
|
442
443
|
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query',
|
|
443
444
|
method: 'POST',
|
|
444
|
-
json: true,
|
|
445
445
|
headers: {
|
|
446
446
|
'fiware-service': 'smartgondor',
|
|
447
447
|
'fiware-servicepath': 'gardens'
|
|
448
448
|
},
|
|
449
|
-
|
|
449
|
+
json: {
|
|
450
450
|
entities: [
|
|
451
451
|
{
|
|
452
452
|
id: 'Motion:motion1'
|
|
@@ -580,12 +580,11 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
580
580
|
const options = {
|
|
581
581
|
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query',
|
|
582
582
|
method: 'POST',
|
|
583
|
-
json: true,
|
|
584
583
|
headers: {
|
|
585
584
|
'fiware-service': 'smartgondor',
|
|
586
585
|
'fiware-servicepath': 'gardens'
|
|
587
586
|
},
|
|
588
|
-
|
|
587
|
+
json: {
|
|
589
588
|
entities: [
|
|
590
589
|
{
|
|
591
590
|
idPattern: '.*'
|
|
@@ -663,12 +662,11 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
663
662
|
const options = {
|
|
664
663
|
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query',
|
|
665
664
|
method: 'POST',
|
|
666
|
-
json: true,
|
|
667
665
|
headers: {
|
|
668
666
|
'fiware-service': 'smartgondor',
|
|
669
667
|
'fiware-servicepath': 'gardens'
|
|
670
668
|
},
|
|
671
|
-
|
|
669
|
+
json: {
|
|
672
670
|
entities: [
|
|
673
671
|
{
|
|
674
672
|
idPattern: '.*',
|
|
@@ -747,12 +745,11 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
747
745
|
const options = {
|
|
748
746
|
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/query',
|
|
749
747
|
method: 'POST',
|
|
750
|
-
json: true,
|
|
751
748
|
headers: {
|
|
752
749
|
'fiware-service': 'smartgondor',
|
|
753
750
|
'fiware-servicepath': 'gardens'
|
|
754
751
|
},
|
|
755
|
-
|
|
752
|
+
json: {
|
|
756
753
|
entities: [
|
|
757
754
|
{
|
|
758
755
|
id: 'Light:light1',
|
|
@@ -1084,9 +1081,8 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
1084
1081
|
});
|
|
1085
1082
|
|
|
1086
1083
|
request(options, function (error, response, body) {
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
parsedBody.description.should.equal('Unsupported content type in the context request: text/plain');
|
|
1084
|
+
body.error.should.equal('UNSUPPORTED_CONTENT_TYPE');
|
|
1085
|
+
body.description.should.equal('Unsupported content type in the context request: text/plain');
|
|
1090
1086
|
done();
|
|
1091
1087
|
});
|
|
1092
1088
|
});
|
|
@@ -27,14 +27,16 @@
|
|
|
27
27
|
|
|
28
28
|
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
29
29
|
const utils = require('../../../tools/utils');
|
|
30
|
+
const request = utils.request;
|
|
30
31
|
const should = require('should');
|
|
31
32
|
const logger = require('logops');
|
|
32
33
|
const nock = require('nock');
|
|
33
34
|
const mongoUtils = require('../../mongodb/mongoDBUtils');
|
|
34
|
-
|
|
35
|
+
|
|
35
36
|
let contextBrokerMock;
|
|
36
37
|
let statusAttributeMock;
|
|
37
38
|
const iotAgentConfig = {
|
|
39
|
+
logLevel: 'FATAL',
|
|
38
40
|
contextBroker: {
|
|
39
41
|
host: '192.168.1.1',
|
|
40
42
|
port: '1026',
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
29
29
|
const utils = require('../../../tools/utils');
|
|
30
|
+
const request = utils.request;
|
|
30
31
|
const timekeeper = require('timekeeper');
|
|
31
32
|
const should = require('should');
|
|
32
33
|
const logger = require('logops');
|
|
@@ -187,7 +187,6 @@ describe('NGSI-v2 - Query device information in the Context Broker', function ()
|
|
|
187
187
|
|
|
188
188
|
it('should return a ENTITY_GENERIC_ERROR', function (done) {
|
|
189
189
|
iotAgentLib.query('light3', 'Light', '', attributes, function (error) {
|
|
190
|
-
console.error(error);
|
|
191
190
|
should.exist(error);
|
|
192
191
|
should.exist(error.name);
|
|
193
192
|
should.exist(error.code);
|
|
@@ -27,8 +27,9 @@
|
|
|
27
27
|
|
|
28
28
|
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
29
29
|
const utils = require('../../../tools/utils');
|
|
30
|
+
const request = utils.request;
|
|
30
31
|
const should = require('should');
|
|
31
|
-
|
|
32
|
+
|
|
32
33
|
const nock = require('nock');
|
|
33
34
|
let contextBrokerMock;
|
|
34
35
|
const iotAgentConfig = {
|
|
@@ -133,7 +134,7 @@ describe('NGSI-v2 - Subscription tests', function () {
|
|
|
133
134
|
contextBrokerMock
|
|
134
135
|
.matchHeader('fiware-service', 'smartgondor')
|
|
135
136
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
136
|
-
.delete('/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8')
|
|
137
|
+
.delete('/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8', '')
|
|
137
138
|
.reply(204);
|
|
138
139
|
|
|
139
140
|
done();
|
|
@@ -171,7 +172,7 @@ describe('NGSI-v2 - Subscription tests', function () {
|
|
|
171
172
|
contextBrokerMock
|
|
172
173
|
.matchHeader('fiware-service', 'smartgondor')
|
|
173
174
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
174
|
-
.delete('/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8')
|
|
175
|
+
.delete('/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8', '')
|
|
175
176
|
.reply(204);
|
|
176
177
|
|
|
177
178
|
done();
|
|
@@ -27,10 +27,11 @@
|
|
|
27
27
|
|
|
28
28
|
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
29
29
|
const utils = require('../../../tools/utils');
|
|
30
|
+
const request = utils.request;
|
|
30
31
|
const should = require('should');
|
|
31
32
|
const logger = require('logops');
|
|
32
33
|
const nock = require('nock');
|
|
33
|
-
|
|
34
|
+
|
|
34
35
|
let contextBrokerMock;
|
|
35
36
|
const iotAgentConfig = {
|
|
36
37
|
contextBroker: {
|
|
@@ -147,7 +148,7 @@ describe('NGSI-v2 - Bidirectional data plugin', function () {
|
|
|
147
148
|
contextBrokerMock
|
|
148
149
|
.matchHeader('fiware-service', 'smartgondor')
|
|
149
150
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
150
|
-
.delete('/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8')
|
|
151
|
+
.delete('/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8', '')
|
|
151
152
|
.reply(204);
|
|
152
153
|
});
|
|
153
154
|
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
29
29
|
const utils = require('../../../tools/utils');
|
|
30
|
+
const request = utils.request;
|
|
30
31
|
const should = require('should');
|
|
31
32
|
const logger = require('logops');
|
|
32
33
|
const nock = require('nock');
|
|
@@ -242,6 +243,46 @@ const iotAgentConfig = {
|
|
|
242
243
|
}
|
|
243
244
|
]
|
|
244
245
|
},
|
|
246
|
+
WeatherStation9Jexl: {
|
|
247
|
+
commands: [],
|
|
248
|
+
type: 'WeatherStation',
|
|
249
|
+
expressionLanguage: 'jexl',
|
|
250
|
+
lazy: [],
|
|
251
|
+
static: [
|
|
252
|
+
{
|
|
253
|
+
name: 'st1',
|
|
254
|
+
type: 'Number',
|
|
255
|
+
value: 1
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: 'st2',
|
|
259
|
+
type: 'Number',
|
|
260
|
+
value: 2
|
|
261
|
+
}
|
|
262
|
+
],
|
|
263
|
+
active: [
|
|
264
|
+
{
|
|
265
|
+
object_id: 'v1',
|
|
266
|
+
name: 'vol',
|
|
267
|
+
expression: 'st1 * 100',
|
|
268
|
+
type: 'Number',
|
|
269
|
+
entity_name: 'WeatherStation1'
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
object_id: 'v2',
|
|
273
|
+
name: 'vol',
|
|
274
|
+
expression: 'st2 * 100',
|
|
275
|
+
type: 'Number',
|
|
276
|
+
entity_name: 'WeatherStation2'
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
object_id: 'v',
|
|
280
|
+
name: 'vol',
|
|
281
|
+
expression: 'v * 100',
|
|
282
|
+
type: 'Number'
|
|
283
|
+
}
|
|
284
|
+
]
|
|
285
|
+
},
|
|
245
286
|
Sensor001: {
|
|
246
287
|
commands: [],
|
|
247
288
|
type: 'Sensor',
|
|
@@ -422,6 +463,58 @@ const iotAgentConfig = {
|
|
|
422
463
|
type: 'Number'
|
|
423
464
|
}
|
|
424
465
|
]
|
|
466
|
+
},
|
|
467
|
+
GPS: {
|
|
468
|
+
commands: [],
|
|
469
|
+
type: 'GPS',
|
|
470
|
+
lazy: [],
|
|
471
|
+
active: [
|
|
472
|
+
{
|
|
473
|
+
name: 'explicit',
|
|
474
|
+
type: 'number',
|
|
475
|
+
entity_name: 'SO5',
|
|
476
|
+
object_id: 'x'
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
name: 'explicit',
|
|
480
|
+
type: 'number',
|
|
481
|
+
entity_name: 'SO6',
|
|
482
|
+
object_id: 'y'
|
|
483
|
+
}
|
|
484
|
+
],
|
|
485
|
+
explicitAttrs: true
|
|
486
|
+
},
|
|
487
|
+
GPS2: {
|
|
488
|
+
commands: [],
|
|
489
|
+
type: 'GPS',
|
|
490
|
+
lazy: [],
|
|
491
|
+
active: [
|
|
492
|
+
{
|
|
493
|
+
name: 'foo',
|
|
494
|
+
type: 'text',
|
|
495
|
+
object_id: 'f'
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
name: 'attr1',
|
|
499
|
+
type: 'number',
|
|
500
|
+
entity_name: 'SO5',
|
|
501
|
+
object_id: 'x'
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
name: 'attr2',
|
|
505
|
+
type: 'number',
|
|
506
|
+
entity_name: 'SO6',
|
|
507
|
+
object_id: 'y'
|
|
508
|
+
}
|
|
509
|
+
],
|
|
510
|
+
static: [
|
|
511
|
+
{
|
|
512
|
+
name: 'bar',
|
|
513
|
+
type: 'text',
|
|
514
|
+
value: 'b'
|
|
515
|
+
}
|
|
516
|
+
],
|
|
517
|
+
explicitAttrs: '[ "attr1", "attr2" ]'
|
|
425
518
|
}
|
|
426
519
|
},
|
|
427
520
|
service: 'smartgondor',
|
|
@@ -899,6 +992,39 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
|
|
|
899
992
|
});
|
|
900
993
|
});
|
|
901
994
|
|
|
995
|
+
describe('When an update comes for a multientity defined with an expression (multi values / multiple entities / same attribute) - JEXL with static', function () {
|
|
996
|
+
const values = [
|
|
997
|
+
{
|
|
998
|
+
name: 'v',
|
|
999
|
+
type: 'Number',
|
|
1000
|
+
value: 0
|
|
1001
|
+
}
|
|
1002
|
+
];
|
|
1003
|
+
|
|
1004
|
+
beforeEach(function () {
|
|
1005
|
+
nock.cleanAll();
|
|
1006
|
+
|
|
1007
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1008
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1009
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1010
|
+
.post(
|
|
1011
|
+
'/v2/op/update',
|
|
1012
|
+
utils.readExampleFile(
|
|
1013
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json'
|
|
1014
|
+
)
|
|
1015
|
+
)
|
|
1016
|
+
.reply(204);
|
|
1017
|
+
});
|
|
1018
|
+
|
|
1019
|
+
it('should send the update value to the resulting value of the expression', function (done) {
|
|
1020
|
+
iotAgentLib.update('ws9', 'WeatherStation9Jexl', '', values, function (error) {
|
|
1021
|
+
should.not.exist(error);
|
|
1022
|
+
contextBrokerMock.done();
|
|
1023
|
+
done();
|
|
1024
|
+
});
|
|
1025
|
+
});
|
|
1026
|
+
});
|
|
1027
|
+
|
|
902
1028
|
beforeEach(function () {
|
|
903
1029
|
nock.cleanAll();
|
|
904
1030
|
|
|
@@ -995,6 +1121,90 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
|
|
|
995
1121
|
});
|
|
996
1122
|
});
|
|
997
1123
|
|
|
1124
|
+
describe('When an update comes for a multientity measurement explicitAttrs for one entity', function () {
|
|
1125
|
+
const values = [
|
|
1126
|
+
{
|
|
1127
|
+
name: 'x',
|
|
1128
|
+
type: 'Number',
|
|
1129
|
+
value: 52
|
|
1130
|
+
},
|
|
1131
|
+
{
|
|
1132
|
+
name: 'y',
|
|
1133
|
+
type: 'Number',
|
|
1134
|
+
value: 13
|
|
1135
|
+
},
|
|
1136
|
+
{
|
|
1137
|
+
name: 'z',
|
|
1138
|
+
type: 'Number',
|
|
1139
|
+
value: 12
|
|
1140
|
+
}
|
|
1141
|
+
];
|
|
1142
|
+
|
|
1143
|
+
beforeEach(function () {
|
|
1144
|
+
nock.cleanAll();
|
|
1145
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1146
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1147
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1148
|
+
.post(
|
|
1149
|
+
'/v2/op/update',
|
|
1150
|
+
utils.readExampleFile(
|
|
1151
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json'
|
|
1152
|
+
)
|
|
1153
|
+
)
|
|
1154
|
+
.reply(204);
|
|
1155
|
+
});
|
|
1156
|
+
|
|
1157
|
+
it('should remove hidden attrs from the value', function (done) {
|
|
1158
|
+
iotAgentLib.update('gps1', 'GPS', '', values, function (error) {
|
|
1159
|
+
should.not.exist(error);
|
|
1160
|
+
contextBrokerMock.done();
|
|
1161
|
+
done();
|
|
1162
|
+
});
|
|
1163
|
+
});
|
|
1164
|
+
});
|
|
1165
|
+
|
|
1166
|
+
describe('When an update comes for a multientity measurement explicitAttrs as jexl for one entity', function () {
|
|
1167
|
+
const values = [
|
|
1168
|
+
{
|
|
1169
|
+
name: 'x',
|
|
1170
|
+
type: 'Number',
|
|
1171
|
+
value: 52
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
name: 'y',
|
|
1175
|
+
type: 'Number',
|
|
1176
|
+
value: 13
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
name: 'z',
|
|
1180
|
+
type: 'Number',
|
|
1181
|
+
value: 12
|
|
1182
|
+
}
|
|
1183
|
+
];
|
|
1184
|
+
|
|
1185
|
+
beforeEach(function () {
|
|
1186
|
+
nock.cleanAll();
|
|
1187
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1188
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1189
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1190
|
+
.post(
|
|
1191
|
+
'/v2/op/update',
|
|
1192
|
+
utils.readExampleFile(
|
|
1193
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json'
|
|
1194
|
+
)
|
|
1195
|
+
)
|
|
1196
|
+
.reply(204);
|
|
1197
|
+
});
|
|
1198
|
+
|
|
1199
|
+
it('should remove hidden attrs from the value', function (done) {
|
|
1200
|
+
iotAgentLib.update('gps1', 'GPS2', '', values, function (error) {
|
|
1201
|
+
should.not.exist(error);
|
|
1202
|
+
contextBrokerMock.done();
|
|
1203
|
+
done();
|
|
1204
|
+
});
|
|
1205
|
+
});
|
|
1206
|
+
});
|
|
1207
|
+
|
|
998
1208
|
describe(
|
|
999
1209
|
'When an update comes for a multientity measurement and there are attributes with' +
|
|
1000
1210
|
' the same name but different alias and mapped to different CB entities',
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
27
27
|
const utils = require('../../../tools/utils');
|
|
28
|
+
const request = utils.request;
|
|
28
29
|
const should = require('should');
|
|
29
30
|
const logger = require('logops');
|
|
30
31
|
const nock = require('nock');
|
|
@@ -246,7 +247,6 @@ describe('NGSI-v2 - Data Mapping Plugins: translation', function () {
|
|
|
246
247
|
it('should call the middleware', function (done) {
|
|
247
248
|
function testMiddleware(entity, typeInformation, callback) {
|
|
248
249
|
entity.dimming.value = entity.dimming.value + '%';
|
|
249
|
-
|
|
250
250
|
callback(null, entity, typeInformation);
|
|
251
251
|
}
|
|
252
252
|
|
|
@@ -28,8 +28,9 @@ const _ = require('underscore');
|
|
|
28
28
|
const async = require('async');
|
|
29
29
|
const nock = require('nock');
|
|
30
30
|
const utils = require('../../../tools/utils');
|
|
31
|
+
const request = utils.request;
|
|
31
32
|
const groupRegistryMemory = require('../../../../lib/services/groups/groupRegistryMemory');
|
|
32
|
-
|
|
33
|
+
|
|
33
34
|
const should = require('should');
|
|
34
35
|
const iotAgentConfig = {
|
|
35
36
|
logLevel: 'FATAL',
|
|
@@ -424,7 +425,7 @@ describe('NGSI-v2 - Device Group Configuration API', function () {
|
|
|
424
425
|
contextBrokerMock
|
|
425
426
|
.matchHeader('fiware-service', 'testservice')
|
|
426
427
|
.matchHeader('fiware-servicepath', '/testingPath')
|
|
427
|
-
.delete('/v2/registrations/6319a7f5254b05844116584d')
|
|
428
|
+
.delete('/v2/registrations/6319a7f5254b05844116584d', '')
|
|
428
429
|
.reply(204);
|
|
429
430
|
|
|
430
431
|
contextBrokerMock
|
|
@@ -25,10 +25,11 @@
|
|
|
25
25
|
|
|
26
26
|
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
27
27
|
const utils = require('../../../tools/utils');
|
|
28
|
+
const request = utils.request;
|
|
28
29
|
const should = require('should');
|
|
29
30
|
const async = require('async');
|
|
30
31
|
const groupRegistryMemory = require('../../../../lib/services/groups/groupRegistryMemory');
|
|
31
|
-
|
|
32
|
+
|
|
32
33
|
const groupCreation = {
|
|
33
34
|
url: 'http://localhost:4041/iot/services',
|
|
34
35
|
method: 'POST',
|
|
@@ -27,9 +27,10 @@
|
|
|
27
27
|
|
|
28
28
|
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
29
29
|
const utils = require('../../../tools/utils');
|
|
30
|
+
const request = utils.request;
|
|
30
31
|
const should = require('should');
|
|
31
32
|
const nock = require('nock');
|
|
32
|
-
|
|
33
|
+
|
|
33
34
|
const moment = require('moment');
|
|
34
35
|
let contextBrokerMock;
|
|
35
36
|
const iotAgentConfig = {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
29
29
|
const utils = require('../../../tools/utils');
|
|
30
|
+
const request = utils.request;
|
|
30
31
|
const should = require('should');
|
|
31
32
|
const logger = require('logops');
|
|
32
33
|
const nock = require('nock');
|
|
@@ -289,7 +290,7 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () {
|
|
|
289
290
|
contextBrokerMock.post('/v2/entities?options=upsert').reply(204);
|
|
290
291
|
|
|
291
292
|
contextBrokerMock
|
|
292
|
-
.delete('/v2/registrations/6319a7f5254b05844116584d')
|
|
293
|
+
.delete('/v2/registrations/6319a7f5254b05844116584d', '')
|
|
293
294
|
.reply(204, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });
|
|
294
295
|
|
|
295
296
|
iotAgentLib.activate(iotAgentConfig, function (error) {
|
|
@@ -334,7 +335,7 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () {
|
|
|
334
335
|
// provisioning folder
|
|
335
336
|
contextBrokerMock.post('/v2/entities?options=upsert').reply(204);
|
|
336
337
|
|
|
337
|
-
contextBrokerMock.delete('/v2/registrations/6319a7f5254b05844116584d').reply(500);
|
|
338
|
+
contextBrokerMock.delete('/v2/registrations/6319a7f5254b05844116584d', '').reply(500);
|
|
338
339
|
|
|
339
340
|
iotAgentLib.activate(iotAgentConfig, function (error) {
|
|
340
341
|
async.series(
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
29
29
|
const utils = require('../../../tools/utils');
|
|
30
|
+
const request = utils.request;
|
|
30
31
|
const should = require('should');
|
|
31
32
|
const logger = require('logops');
|
|
32
33
|
const nock = require('nock');
|
|
@@ -188,7 +189,7 @@ describe('NGSI-v2 - IoT Agent Device Update Registration', function () {
|
|
|
188
189
|
contextBrokerMock
|
|
189
190
|
.matchHeader('fiware-service', 'smartgondor')
|
|
190
191
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
191
|
-
.delete('/v2/registrations/6319a7f5254b05844116584d')
|
|
192
|
+
.delete('/v2/registrations/6319a7f5254b05844116584d', '')
|
|
192
193
|
.reply(204);
|
|
193
194
|
|
|
194
195
|
contextBrokerMock
|
|
@@ -243,7 +244,7 @@ describe('NGSI-v2 - IoT Agent Device Update Registration', function () {
|
|
|
243
244
|
contextBrokerMock
|
|
244
245
|
.matchHeader('fiware-service', 'smartgondor')
|
|
245
246
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
246
|
-
.delete('/v2/registrations/6319a7f5254b05844116584d')
|
|
247
|
+
.delete('/v2/registrations/6319a7f5254b05844116584d', '')
|
|
247
248
|
.reply(204);
|
|
248
249
|
|
|
249
250
|
contextBrokerMock
|
|
@@ -296,7 +297,7 @@ describe('NGSI-v2 - IoT Agent Device Update Registration', function () {
|
|
|
296
297
|
// FIXME: When https://github.com/telefonicaid/fiware-orion/issues/3007 is merged into master branch,
|
|
297
298
|
// this function should use the new API. This is just a temporary solution which implies deleting the
|
|
298
299
|
// registration and creating a new one.
|
|
299
|
-
contextBrokerMock.delete('/v2/registrations/6319a7f5254b05844116584d').reply(500, {});
|
|
300
|
+
contextBrokerMock.delete('/v2/registrations/6319a7f5254b05844116584d', '').reply(500, {});
|
|
300
301
|
|
|
301
302
|
contextBrokerMock
|
|
302
303
|
.matchHeader('fiware-service', 'smartgondor')
|