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
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2014 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, seehttp://www.gnu.org/licenses/.
|
|
19
|
-
*
|
|
20
|
-
* For those usages not covered by the GNU Affero General Public License
|
|
21
|
-
* please contact with::[contacto@tid.es]
|
|
22
|
-
*
|
|
23
|
-
* Developed by: Federico M. Facca - Martel Innovate
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/* jshint camelcase: false */
|
|
27
|
-
|
|
28
|
-
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
29
|
-
const utils = require('../../../tools/utils');
|
|
30
|
-
const should = require('should');
|
|
31
|
-
const logger = require('logops');
|
|
32
|
-
const nock = require('nock');
|
|
33
|
-
let contextBrokerMock;
|
|
34
|
-
const iotAgentConfigJexl = {
|
|
35
|
-
contextBroker: {
|
|
36
|
-
host: '192.168.1.1',
|
|
37
|
-
port: '1026',
|
|
38
|
-
ngsiVersion: 'v2'
|
|
39
|
-
},
|
|
40
|
-
server: {
|
|
41
|
-
port: 4041,
|
|
42
|
-
host: 'localhost'
|
|
43
|
-
},
|
|
44
|
-
defaultExpressionLanguage: 'jexl',
|
|
45
|
-
types: {
|
|
46
|
-
WeatherStationLegacy: {
|
|
47
|
-
commands: [],
|
|
48
|
-
type: 'WeatherStation',
|
|
49
|
-
expressionLanguage: 'legacy',
|
|
50
|
-
lazy: [],
|
|
51
|
-
active: [
|
|
52
|
-
{
|
|
53
|
-
object_id: 'p',
|
|
54
|
-
name: 'pressure',
|
|
55
|
-
type: 'Number',
|
|
56
|
-
expression: '${@pressure * 20}'
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
},
|
|
60
|
-
WeatherStationJexl: {
|
|
61
|
-
commands: [],
|
|
62
|
-
type: 'WeatherStation',
|
|
63
|
-
lazy: [],
|
|
64
|
-
active: [
|
|
65
|
-
{
|
|
66
|
-
object_id: 'p',
|
|
67
|
-
name: 'pressure',
|
|
68
|
-
type: 'Number',
|
|
69
|
-
expression: 'pressure * 20'
|
|
70
|
-
}
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
service: 'smartgondor',
|
|
75
|
-
subservice: 'gardens',
|
|
76
|
-
providerUrl: 'http://smartgondor.com',
|
|
77
|
-
deviceRegistrationDuration: 'P1M',
|
|
78
|
-
throttling: 'PT5S'
|
|
79
|
-
};
|
|
80
|
-
const iotAgentConfigLegacy = {
|
|
81
|
-
contextBroker: {
|
|
82
|
-
host: '192.168.1.1',
|
|
83
|
-
port: '1026',
|
|
84
|
-
ngsiVersion: 'v2'
|
|
85
|
-
},
|
|
86
|
-
server: {
|
|
87
|
-
port: 4041,
|
|
88
|
-
host: 'localhost'
|
|
89
|
-
},
|
|
90
|
-
types: {
|
|
91
|
-
WeatherStationLegacy: {
|
|
92
|
-
commands: [],
|
|
93
|
-
type: 'WeatherStation',
|
|
94
|
-
lazy: [],
|
|
95
|
-
active: [
|
|
96
|
-
{
|
|
97
|
-
object_id: 'p',
|
|
98
|
-
name: 'pressure',
|
|
99
|
-
type: 'Number',
|
|
100
|
-
expression: '${@pressure * 20}'
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
},
|
|
104
|
-
WeatherStationJexl: {
|
|
105
|
-
commands: [],
|
|
106
|
-
type: 'WeatherStation',
|
|
107
|
-
expressionLanguage: 'jexl',
|
|
108
|
-
lazy: [],
|
|
109
|
-
active: [
|
|
110
|
-
{
|
|
111
|
-
object_id: 'p',
|
|
112
|
-
name: 'pressure',
|
|
113
|
-
type: 'Number',
|
|
114
|
-
expression: 'pressure * 20'
|
|
115
|
-
}
|
|
116
|
-
]
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
service: 'smartgondor',
|
|
120
|
-
subservice: 'gardens',
|
|
121
|
-
providerUrl: 'http://smartgondor.com',
|
|
122
|
-
deviceRegistrationDuration: 'P1M',
|
|
123
|
-
throttling: 'PT5S'
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
describe('Combine Jexl and legacy expressions (default JEXL) - NGSI v2', function () {
|
|
127
|
-
beforeEach(function (done) {
|
|
128
|
-
logger.setLevel('FATAL');
|
|
129
|
-
|
|
130
|
-
iotAgentLib.activate(iotAgentConfigJexl, function () {
|
|
131
|
-
iotAgentLib.clearAll(function () {
|
|
132
|
-
done();
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
afterEach(function (done) {
|
|
138
|
-
iotAgentLib.clearAll(function () {
|
|
139
|
-
iotAgentLib.deactivate(done);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
describe('When an update comes for type with expression "legacy"', function () {
|
|
144
|
-
const values = [
|
|
145
|
-
{
|
|
146
|
-
name: 'p',
|
|
147
|
-
type: 'Number',
|
|
148
|
-
value: 52
|
|
149
|
-
}
|
|
150
|
-
];
|
|
151
|
-
|
|
152
|
-
beforeEach(function () {
|
|
153
|
-
nock.cleanAll();
|
|
154
|
-
|
|
155
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
156
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
157
|
-
.matchHeader('fiware-servicepath', 'gardens')
|
|
158
|
-
.patch(
|
|
159
|
-
'/v2/entities/ws1/attrs',
|
|
160
|
-
utils.readExampleFile(
|
|
161
|
-
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin15.json'
|
|
162
|
-
)
|
|
163
|
-
)
|
|
164
|
-
.query({ type: 'WeatherStation' })
|
|
165
|
-
.reply(204);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('should apply the legacy expression before sending the values', function (done) {
|
|
169
|
-
iotAgentLib.update('ws1', 'WeatherStationLegacy', '', values, function (error) {
|
|
170
|
-
should.not.exist(error);
|
|
171
|
-
contextBrokerMock.done();
|
|
172
|
-
done();
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
describe('When an update comes for type with expression "JEXL" - default', function () {
|
|
178
|
-
const values = [
|
|
179
|
-
{
|
|
180
|
-
name: 'p',
|
|
181
|
-
type: 'Number',
|
|
182
|
-
value: 52
|
|
183
|
-
}
|
|
184
|
-
];
|
|
185
|
-
|
|
186
|
-
beforeEach(function () {
|
|
187
|
-
nock.cleanAll();
|
|
188
|
-
|
|
189
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
190
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
191
|
-
.matchHeader('fiware-servicepath', 'gardens')
|
|
192
|
-
.patch(
|
|
193
|
-
'/v2/entities/ws2/attrs',
|
|
194
|
-
utils.readExampleFile(
|
|
195
|
-
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin15.json'
|
|
196
|
-
)
|
|
197
|
-
)
|
|
198
|
-
.query({ type: 'WeatherStation' })
|
|
199
|
-
.reply(204);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('should apply the default (JEXL) expression before sending the values', function (done) {
|
|
203
|
-
iotAgentLib.update('ws2', 'WeatherStationJexl', '', values, function (error) {
|
|
204
|
-
should.not.exist(error);
|
|
205
|
-
contextBrokerMock.done();
|
|
206
|
-
done();
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
describe('Combine Jexl and legacy expressions (default Legacy) - NGSI v2', function () {
|
|
213
|
-
beforeEach(function (done) {
|
|
214
|
-
logger.setLevel('FATAL');
|
|
215
|
-
|
|
216
|
-
iotAgentLib.activate(iotAgentConfigLegacy, function () {
|
|
217
|
-
iotAgentLib.clearAll(function () {
|
|
218
|
-
done();
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
afterEach(function (done) {
|
|
224
|
-
iotAgentLib.clearAll(function () {
|
|
225
|
-
iotAgentLib.deactivate(done);
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
describe('When an update comes for type with expression "legacy" - default', function () {
|
|
230
|
-
const values = [
|
|
231
|
-
{
|
|
232
|
-
name: 'p',
|
|
233
|
-
type: 'Number',
|
|
234
|
-
value: 52
|
|
235
|
-
}
|
|
236
|
-
];
|
|
237
|
-
|
|
238
|
-
beforeEach(function () {
|
|
239
|
-
nock.cleanAll();
|
|
240
|
-
|
|
241
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
242
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
243
|
-
.matchHeader('fiware-servicepath', 'gardens')
|
|
244
|
-
.patch(
|
|
245
|
-
'/v2/entities/ws3/attrs',
|
|
246
|
-
utils.readExampleFile(
|
|
247
|
-
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin15.json'
|
|
248
|
-
)
|
|
249
|
-
)
|
|
250
|
-
.query({ type: 'WeatherStation' })
|
|
251
|
-
.reply(204);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('should apply the legacy expression before sending the values', function (done) {
|
|
255
|
-
iotAgentLib.update('ws3', 'WeatherStationLegacy', '', values, function (error) {
|
|
256
|
-
should.not.exist(error);
|
|
257
|
-
contextBrokerMock.done();
|
|
258
|
-
done();
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
describe('When an update comes for type with expression "JEXL"', function () {
|
|
264
|
-
const values = [
|
|
265
|
-
{
|
|
266
|
-
name: 'p',
|
|
267
|
-
type: 'Number',
|
|
268
|
-
value: 52
|
|
269
|
-
}
|
|
270
|
-
];
|
|
271
|
-
|
|
272
|
-
beforeEach(function () {
|
|
273
|
-
nock.cleanAll();
|
|
274
|
-
|
|
275
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
276
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
277
|
-
.matchHeader('fiware-servicepath', 'gardens')
|
|
278
|
-
.patch(
|
|
279
|
-
'/v2/entities/ws4/attrs',
|
|
280
|
-
utils.readExampleFile(
|
|
281
|
-
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin15.json'
|
|
282
|
-
)
|
|
283
|
-
)
|
|
284
|
-
.query({ type: 'WeatherStation' })
|
|
285
|
-
.reply(204);
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it('should apply the default (JEXL) expression before sending the values', function (done) {
|
|
289
|
-
iotAgentLib.update('ws4', 'WeatherStationJexl', '', values, function (error) {
|
|
290
|
-
should.not.exist(error);
|
|
291
|
-
contextBrokerMock.done();
|
|
292
|
-
done();
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
});
|