iotagent-node-lib 3.1.0 → 3.3.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/ISSUE_TEMPLATE/bug_report.yml +134 -0
- package/.github/ISSUE_TEMPLATE/config.yml +16 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +55 -0
- package/.github/advanced-issue-labeler.yml +30 -0
- package/.github/workflows/issue-labeler.yml +43 -0
- package/CHANGES_NEXT_RELEASE +0 -2
- package/config.js +5 -5
- package/doc/api.md +1483 -298
- package/doc/deprecated.md +7 -1
- package/doc/development.md +120 -0
- package/doc/howto.md +58 -62
- package/doc/installationguide.md +3 -11
- package/doc/requirements.txt +1 -1
- package/docker/Mosquitto/Dockerfile +1 -1
- package/lib/commonConfig.js +7 -10
- package/lib/fiware-iotagent-lib.js +0 -10
- package/lib/jexlTranformsMap.js +2 -1
- package/lib/model/Device.js +0 -1
- package/lib/model/Group.js +0 -1
- package/lib/model/dbConn.js +1 -7
- 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/common/iotManagerService.js +0 -1
- package/lib/services/devices/deviceRegistryMongoDB.js +10 -10
- package/lib/services/devices/deviceService.js +16 -20
- package/lib/services/devices/devices-NGSI-v2.js +2 -5
- package/lib/services/ngsi/entities-NGSI-LD.js +16 -60
- package/lib/services/ngsi/entities-NGSI-v2.js +179 -119
- package/lib/services/northBound/deviceProvisioningServer.js +17 -17
- package/lib/templates/createDevice.json +5 -6
- package/lib/templates/createDeviceLax.json +6 -8
- package/lib/templates/deviceGroup.json +1 -5
- package/lib/templates/updateDevice.json +9 -2
- package/lib/templates/updateDeviceLax.json +14 -5
- package/package.json +1 -1
- package/scripts/legacy_expression_tool/README.md +262 -0
- package/scripts/legacy_expression_tool/legacy_expression_tool.py +423 -0
- package/scripts/legacy_expression_tool/requirements.txt +3 -0
- package/test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json +5 -5
- package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +4 -4
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +3 -13
- package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +0 -2
- package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +31 -30
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +8 -8
- package/test/unit/ngsi-ld/plugins/custom-plugin_test.js +152 -0
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +1 -1
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +33 -37
- package/test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice4.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContext.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext1.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext4.json +4 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContext5.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext6.json +10 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin2.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin4.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin5.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin6.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin7.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin9.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast1.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast2.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast3.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast4.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast5.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast6.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast7.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandError.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandExpired.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandFinish.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus2.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp1.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp2.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +2 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +22 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json +1 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json +42 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +33 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionSkip.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityJexlExpressionPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin17.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +37 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin9.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributes.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestamp.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalse.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalseTimeInstant.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampTimezone.json +3 -1
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +355 -75
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +18 -51
- package/test/unit/ngsiv2/general/https-support-test.js +1 -5
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +4 -10
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +9 -26
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +143 -57
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +14 -21
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +3 -5
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +1 -10
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +20 -30
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +6 -69
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +4 -6
- package/test/unit/ngsiv2/plugins/custom-plugin_test.js +150 -0
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +87 -16
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -3
- package/test/unit/ngsiv2/provisioning/device-group-api-test.js +2 -3
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +15 -55
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +1 -7
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +2 -9
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -11
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +0 -7
- package/test/unit/plugins/capture-provision-inPlugins_test.js +0 -6
- 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 -882
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +0 -951
- package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +0 -296
|
@@ -240,11 +240,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
|
|
|
240
240
|
let longitudeFound = false;
|
|
241
241
|
|
|
242
242
|
for (let i = 0; i < values.length; i++) {
|
|
243
|
-
if (values[i].name === 'latitude' && values[i].type === '
|
|
243
|
+
if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
|
|
244
244
|
latitudeFound = true;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
if (values[i].name === 'longitude' && values[i].type === '
|
|
247
|
+
if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
|
|
248
248
|
longitudeFound = true;
|
|
249
249
|
}
|
|
250
250
|
}
|
|
@@ -348,11 +348,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
|
|
|
348
348
|
let longitudeFound = false;
|
|
349
349
|
|
|
350
350
|
for (let i = 0; i < values.length; i++) {
|
|
351
|
-
if (values[i].name === 'latitude' && values[i].type === '
|
|
351
|
+
if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
|
|
352
352
|
latitudeFound = true;
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
if (values[i].name === 'longitude' && values[i].type === '
|
|
355
|
+
if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
|
|
356
356
|
longitudeFound = true;
|
|
357
357
|
}
|
|
358
358
|
}
|
|
@@ -461,11 +461,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
|
|
|
461
461
|
let longitudeFound = false;
|
|
462
462
|
|
|
463
463
|
for (let i = 0; i < values.length; i++) {
|
|
464
|
-
if (values[i].name === 'latitude' && values[i].type === '
|
|
464
|
+
if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
|
|
465
465
|
latitudeFound = true;
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
-
if (values[i].name === 'longitude' && values[i].type === '
|
|
468
|
+
if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
|
|
469
469
|
longitudeFound = true;
|
|
470
470
|
}
|
|
471
471
|
}
|
|
@@ -603,11 +603,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
|
|
|
603
603
|
let longitudeFound = false;
|
|
604
604
|
|
|
605
605
|
for (let i = 0; i < values.length; i++) {
|
|
606
|
-
if (values[i].name === 'latitude' && values[i].type === '
|
|
606
|
+
if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
|
|
607
607
|
latitudeFound = true;
|
|
608
608
|
}
|
|
609
609
|
|
|
610
|
-
if (values[i].name === 'longitude' && values[i].type === '
|
|
610
|
+
if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
|
|
611
611
|
longitudeFound = true;
|
|
612
612
|
}
|
|
613
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
|
+
});
|
|
@@ -189,8 +189,7 @@ describe('Mixed Mode: ngsiVersion test', function () {
|
|
|
189
189
|
nock.cleanAll();
|
|
190
190
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
191
191
|
.matchHeader('fiware-service', 'smartgondor')
|
|
192
|
-
.
|
|
193
|
-
.query({ type: 'Device' })
|
|
192
|
+
.post('/v2/entities?options=upsert')
|
|
194
193
|
.reply(204);
|
|
195
194
|
|
|
196
195
|
request(optionsCreationDefault, function (error, response, body) {
|
|
@@ -211,8 +210,7 @@ describe('Mixed Mode: ngsiVersion test', function () {
|
|
|
211
210
|
nock.cleanAll();
|
|
212
211
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
213
212
|
.matchHeader('fiware-service', 'smartgondor')
|
|
214
|
-
.
|
|
215
|
-
.query({ type: 'Device' })
|
|
213
|
+
.post('/v2/entities?options=upsert')
|
|
216
214
|
.reply(204);
|
|
217
215
|
|
|
218
216
|
request(optionsCreationV2, function (error, response, body) {
|
|
@@ -248,39 +246,37 @@ describe('Mixed Mode: ngsiVersion test', function () {
|
|
|
248
246
|
});
|
|
249
247
|
});
|
|
250
248
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
249
|
+
// FIXME: ngisld may use also upsert when update entities in appendMode true (default behaviour)
|
|
250
|
+
// describe('When a new NGSI-LD device group is provisioned and overridden', function () {
|
|
251
|
+
// beforeEach(function (done) {
|
|
252
|
+
// nock.cleanAll();
|
|
254
253
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
254
|
+
// contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
255
|
+
// .matchHeader('fiware-service', 'smartgondor')
|
|
256
|
+
// .matchHeader('fiware-servicepath', 'gardens')
|
|
257
|
+
// .post('/v2/entities?options=upsert')
|
|
258
|
+
// .reply(204);
|
|
260
259
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
);
|
|
284
|
-
});
|
|
285
|
-
});
|
|
260
|
+
// contextBrokerMock = nock('http://192.168.1.1:1026').post('/v2/entities?options=upsert').reply(204);
|
|
261
|
+
// request(optionsCreationLD, function (error, response, body) {
|
|
262
|
+
// request(deviceCreationV2, function (error, response, body) {
|
|
263
|
+
// done();
|
|
264
|
+
// });
|
|
265
|
+
// });
|
|
266
|
+
// });
|
|
267
|
+
// it('should operate using NGSI-v2', function (done) {
|
|
268
|
+
// iotAgentLib.update(
|
|
269
|
+
// 'light2',
|
|
270
|
+
// 'Device',
|
|
271
|
+
// 'v2-test',
|
|
272
|
+
// values,
|
|
273
|
+
// { ngsiVersion: 'v2', type: 'Device' },
|
|
274
|
+
// function (error) {
|
|
275
|
+
// should.not.exist(error);
|
|
276
|
+
// contextBrokerMock.done();
|
|
277
|
+
// done();
|
|
278
|
+
// }
|
|
279
|
+
// );
|
|
280
|
+
// });
|
|
281
|
+
// });
|
|
286
282
|
});
|