iotagent-node-lib 3.4.3 → 4.0.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/CHANGES_NEXT_RELEASE +0 -1
- package/README.md +4 -0
- package/doc/admin.md +1 -13
- package/doc/api.md +118 -14
- package/doc/devel/architecture.md +0 -12
- package/doc/index.md +1 -1
- package/doc/roadmap.md +22 -10
- package/lib/commonConfig.js +0 -11
- package/lib/model/Device.js +2 -1
- package/lib/model/Group.js +2 -1
- package/lib/model/dbConn.js +22 -11
- package/lib/plugins/expressionPlugin.js +0 -5
- package/lib/plugins/jexlParser.js +15 -31
- package/lib/services/common/genericMiddleware.js +14 -2
- package/lib/services/common/iotManagerService.js +2 -1
- package/lib/services/devices/deviceRegistryMongoDB.js +3 -1
- package/lib/services/devices/deviceService.js +16 -21
- package/lib/services/devices/devices-NGSI-LD.js +5 -98
- package/lib/services/devices/devices-NGSI-mixed.js +0 -14
- package/lib/services/devices/devices-NGSI-v2.js +3 -0
- package/lib/services/groups/groupRegistryMemory.js +0 -25
- package/lib/services/groups/groupRegistryMongoDB.js +20 -19
- package/lib/services/groups/groupService.js +3 -14
- package/lib/services/ngsi/entities-NGSI-LD.js +81 -6
- package/lib/services/ngsi/entities-NGSI-v2.js +304 -687
- package/lib/services/ngsi/ngsiUtils.js +0 -30
- package/lib/services/northBound/deviceProvisioningServer.js +6 -3
- package/lib/templates/createDevice.json +4 -0
- package/lib/templates/createDeviceLax.json +4 -0
- package/lib/templates/deviceGroup.json +4 -0
- package/lib/templates/updateDevice.json +4 -0
- package/lib/templates/updateDeviceLax.json +4 -0
- package/package.json +6 -2
- package/test/functional/README.md +378 -0
- package/test/functional/config-test.js +70 -0
- package/test/functional/functional-tests-runner.js +126 -0
- package/test/functional/functional-tests.js +241 -0
- package/test/functional/testCases.js +2944 -0
- package/test/functional/testUtils.js +251 -0
- package/test/tools/utils.js +25 -0
- package/test/unit/mongodb/mongodb-connectionoptions-test.js +35 -22
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +3 -34
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +8 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin7.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin8.json +1 -6
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +67 -87
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +7 -13
- package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +43 -43
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +19 -29
- package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +0 -1
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +35 -46
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +8 -9
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +96 -221
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +18 -27
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +8 -16
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +0 -13
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +4 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29b.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +0 -6
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34b.json +14 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +1 -11
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36b.json +13 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin37.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +1 -11
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10b.json +37 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +4 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +0 -3
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +10 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -5
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +8 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +0 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +7 -1
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +898 -28
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +188 -1
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +267 -0
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +19 -21
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +21 -24
- package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -21
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +4 -6
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +0 -438
- package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +0 -381
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +0 -311
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +0 -325
- package/test/unit/ngsiv2/ngsiService/geoproperties-test.js +0 -427
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +0 -217
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +0 -119
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -309
|
@@ -1,427 +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, see http://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
|
-
* Modified by: Daniel Calvo - ATOS Research & Innovation
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
27
|
-
// FIXME: #1012
|
|
28
|
-
//const utils = require('../../../tools/utils');
|
|
29
|
-
//const should = require('should');
|
|
30
|
-
const logger = require('logops');
|
|
31
|
-
//const nock = require('nock');
|
|
32
|
-
//let contextBrokerMock;
|
|
33
|
-
//const iotAgentConfig = {
|
|
34
|
-
// autocast: true,
|
|
35
|
-
// contextBroker: {
|
|
36
|
-
// host: '192.168.1.1',
|
|
37
|
-
// port: '1026',
|
|
38
|
-
// ngsiVersion: 'v2'
|
|
39
|
-
// },
|
|
40
|
-
// server: {
|
|
41
|
-
// port: 4041
|
|
42
|
-
// },
|
|
43
|
-
// types: {
|
|
44
|
-
// Light: {
|
|
45
|
-
// commands: [],
|
|
46
|
-
// type: 'Light',
|
|
47
|
-
// active: [
|
|
48
|
-
// {
|
|
49
|
-
// name: 'location',
|
|
50
|
-
// type: 'geo:json'
|
|
51
|
-
// }
|
|
52
|
-
// ]
|
|
53
|
-
// }
|
|
54
|
-
// },
|
|
55
|
-
// service: 'smartgondor',
|
|
56
|
-
// subservice: 'gardens',
|
|
57
|
-
// providerUrl: 'http://smartgondor.com'
|
|
58
|
-
//};
|
|
59
|
-
|
|
60
|
-
describe('NGSI-v2 - Geo-JSON types autocast test', function () {
|
|
61
|
-
beforeEach(function () {
|
|
62
|
-
logger.setLevel('FATAL');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
afterEach(function (done) {
|
|
66
|
-
iotAgentLib.deactivate(done);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// FIXME: #1012
|
|
70
|
-
// describe(
|
|
71
|
-
// 'When the IoT Agent receives new geo-information from a device.' +
|
|
72
|
-
// 'Location with geo:json type and String value',
|
|
73
|
-
// function () {
|
|
74
|
-
// const values = [
|
|
75
|
-
// {
|
|
76
|
-
// name: 'location',
|
|
77
|
-
// type: 'geo:json',
|
|
78
|
-
// value: '23,12.5'
|
|
79
|
-
// }
|
|
80
|
-
// ];
|
|
81
|
-
|
|
82
|
-
// beforeEach(function (done) {
|
|
83
|
-
// nock.cleanAll();
|
|
84
|
-
|
|
85
|
-
// contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
86
|
-
// .matchHeader('fiware-service', 'smartgondor')
|
|
87
|
-
// .post(
|
|
88
|
-
// '/v2/entities/light1/attrs',
|
|
89
|
-
// utils.readExampleFile(
|
|
90
|
-
// './test/unit/ngsiv2/examples/contextRequests/updateContextGeoproperties1.json'
|
|
91
|
-
// )
|
|
92
|
-
// )
|
|
93
|
-
// .query({ type: 'Light' })
|
|
94
|
-
// .reply(204);
|
|
95
|
-
|
|
96
|
-
// iotAgentLib.activate(iotAgentConfig, done);
|
|
97
|
-
// });
|
|
98
|
-
|
|
99
|
-
// it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
100
|
-
// iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
101
|
-
// should.not.exist(error);
|
|
102
|
-
// contextBrokerMock.done();
|
|
103
|
-
// done();
|
|
104
|
-
// });
|
|
105
|
-
// });
|
|
106
|
-
// }
|
|
107
|
-
// );
|
|
108
|
-
|
|
109
|
-
// describe(
|
|
110
|
-
// 'When the IoT Agent receives new geo-information from a device.' +
|
|
111
|
-
// 'Location with geo:json type and GeoJSON object value',
|
|
112
|
-
// function () {
|
|
113
|
-
// const values = [
|
|
114
|
-
// {
|
|
115
|
-
// name: 'location',
|
|
116
|
-
// type: 'geo:json',
|
|
117
|
-
// value: {
|
|
118
|
-
// type: 'Point',
|
|
119
|
-
// coordinates: [23, 12.5]
|
|
120
|
-
// }
|
|
121
|
-
// }
|
|
122
|
-
// ];
|
|
123
|
-
|
|
124
|
-
// beforeEach(function (done) {
|
|
125
|
-
// nock.cleanAll();
|
|
126
|
-
|
|
127
|
-
// contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
128
|
-
// .matchHeader('fiware-service', 'smartgondor')
|
|
129
|
-
// .post(
|
|
130
|
-
// '/v2/entities/light1/attrs',
|
|
131
|
-
// utils.readExampleFile(
|
|
132
|
-
// './test/unit/ngsiv2/examples/contextRequests/updateContextGeoproperties1.json'
|
|
133
|
-
// )
|
|
134
|
-
// )
|
|
135
|
-
// .query({ type: 'Light' })
|
|
136
|
-
// .reply(204);
|
|
137
|
-
|
|
138
|
-
// iotAgentLib.activate(iotAgentConfig, done);
|
|
139
|
-
// });
|
|
140
|
-
|
|
141
|
-
// it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
142
|
-
// iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
143
|
-
// should.not.exist(error);
|
|
144
|
-
// contextBrokerMock.done();
|
|
145
|
-
// done();
|
|
146
|
-
// });
|
|
147
|
-
// });
|
|
148
|
-
// }
|
|
149
|
-
// );
|
|
150
|
-
|
|
151
|
-
// describe('When the IoT Agent receives new geo-information from a device. Location with Point type and Array value', function () {
|
|
152
|
-
// const values = [
|
|
153
|
-
// {
|
|
154
|
-
// name: 'location',
|
|
155
|
-
// type: 'Point',
|
|
156
|
-
// value: [23, 12.5]
|
|
157
|
-
// }
|
|
158
|
-
// ];
|
|
159
|
-
|
|
160
|
-
// beforeEach(function (done) {
|
|
161
|
-
// nock.cleanAll();
|
|
162
|
-
|
|
163
|
-
// contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
164
|
-
// .matchHeader('fiware-service', 'smartgondor')
|
|
165
|
-
// .post(
|
|
166
|
-
// '/v2/entities/light1/attrs',
|
|
167
|
-
// utils.readExampleFile(
|
|
168
|
-
// './test/unit/ngsiv2/examples/contextRequests/updateContextGeoproperties1.json'
|
|
169
|
-
// )
|
|
170
|
-
// )
|
|
171
|
-
// .query({ type: 'Light' })
|
|
172
|
-
// .reply(204);
|
|
173
|
-
|
|
174
|
-
// iotAgentLib.activate(iotAgentConfig, done);
|
|
175
|
-
// });
|
|
176
|
-
|
|
177
|
-
// it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
178
|
-
// iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
179
|
-
// should.not.exist(error);
|
|
180
|
-
// contextBrokerMock.done();
|
|
181
|
-
// done();
|
|
182
|
-
// });
|
|
183
|
-
// });
|
|
184
|
-
// });
|
|
185
|
-
|
|
186
|
-
// describe(
|
|
187
|
-
// 'When the IoT Agent receives new geo-information from a device.' +
|
|
188
|
-
// 'Location with LineString type and Array value',
|
|
189
|
-
// function () {
|
|
190
|
-
// const values = [
|
|
191
|
-
// {
|
|
192
|
-
// name: 'location',
|
|
193
|
-
// type: 'LineString',
|
|
194
|
-
// value: [
|
|
195
|
-
// [23, 12.5],
|
|
196
|
-
// [22, 12.5]
|
|
197
|
-
// ]
|
|
198
|
-
// }
|
|
199
|
-
// ];
|
|
200
|
-
|
|
201
|
-
// beforeEach(function (done) {
|
|
202
|
-
// nock.cleanAll();
|
|
203
|
-
|
|
204
|
-
// contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
205
|
-
// .matchHeader('fiware-service', 'smartgondor')
|
|
206
|
-
// .post(
|
|
207
|
-
// '/v2/entities/light1/attrs',
|
|
208
|
-
// utils.readExampleFile(
|
|
209
|
-
// './test/unit/ngsiv2/examples/contextRequests/updateContextGeoproperties2.json'
|
|
210
|
-
// )
|
|
211
|
-
// )
|
|
212
|
-
// .query({ type: 'Light' })
|
|
213
|
-
// .reply(204);
|
|
214
|
-
|
|
215
|
-
// iotAgentLib.activate(iotAgentConfig, done);
|
|
216
|
-
// });
|
|
217
|
-
|
|
218
|
-
// it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
219
|
-
// iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
220
|
-
// should.not.exist(error);
|
|
221
|
-
// contextBrokerMock.done();
|
|
222
|
-
// done();
|
|
223
|
-
// });
|
|
224
|
-
// });
|
|
225
|
-
// }
|
|
226
|
-
// );
|
|
227
|
-
|
|
228
|
-
// describe(
|
|
229
|
-
// 'When the IoT Agent receives new geo-information from a device.' +
|
|
230
|
-
// 'Location with LineString type and Array of Strings',
|
|
231
|
-
// function () {
|
|
232
|
-
// const values = [
|
|
233
|
-
// {
|
|
234
|
-
// name: 'location',
|
|
235
|
-
// type: 'LineString',
|
|
236
|
-
// value: ['23,12.5', '22,12.5']
|
|
237
|
-
// }
|
|
238
|
-
// ];
|
|
239
|
-
|
|
240
|
-
// beforeEach(function (done) {
|
|
241
|
-
// nock.cleanAll();
|
|
242
|
-
|
|
243
|
-
// contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
244
|
-
// .matchHeader('fiware-service', 'smartgondor')
|
|
245
|
-
// .post(
|
|
246
|
-
// '/v2/entities/light1/attrs',
|
|
247
|
-
// utils.readExampleFile(
|
|
248
|
-
// './test/unit/ngsiv2/examples/contextRequests/updateContextGeoproperties2.json'
|
|
249
|
-
// )
|
|
250
|
-
// )
|
|
251
|
-
// .query({ type: 'Light' })
|
|
252
|
-
// .reply(204);
|
|
253
|
-
|
|
254
|
-
// iotAgentLib.activate(iotAgentConfig, done);
|
|
255
|
-
// });
|
|
256
|
-
|
|
257
|
-
// it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
258
|
-
// iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
259
|
-
// should.not.exist(error);
|
|
260
|
-
// contextBrokerMock.done();
|
|
261
|
-
// done();
|
|
262
|
-
// });
|
|
263
|
-
// });
|
|
264
|
-
// }
|
|
265
|
-
// );
|
|
266
|
-
|
|
267
|
-
// describe('When the IoT Agent receives new geo-information from a device. Location with None type', function () {
|
|
268
|
-
// const values = [
|
|
269
|
-
// {
|
|
270
|
-
// name: 'location',
|
|
271
|
-
// type: 'None',
|
|
272
|
-
// value: 'null'
|
|
273
|
-
// }
|
|
274
|
-
// ];
|
|
275
|
-
|
|
276
|
-
// beforeEach(function (done) {
|
|
277
|
-
// nock.cleanAll();
|
|
278
|
-
|
|
279
|
-
// contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
280
|
-
// .matchHeader('fiware-service', 'smartgondor')
|
|
281
|
-
// .post(
|
|
282
|
-
// '/v2/entities/light1/attrs',
|
|
283
|
-
// utils.readExampleFile(
|
|
284
|
-
// './test/unit/ngsiv2/examples/contextRequests/updateContextGeoproperties3.json'
|
|
285
|
-
// )
|
|
286
|
-
// )
|
|
287
|
-
// .query({ type: 'Light' })
|
|
288
|
-
// .reply(204);
|
|
289
|
-
|
|
290
|
-
// iotAgentLib.activate(iotAgentConfig, done);
|
|
291
|
-
// });
|
|
292
|
-
|
|
293
|
-
// it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
294
|
-
// iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
295
|
-
// should.not.exist(error);
|
|
296
|
-
// contextBrokerMock.done();
|
|
297
|
-
// done();
|
|
298
|
-
// });
|
|
299
|
-
// });
|
|
300
|
-
// });
|
|
301
|
-
|
|
302
|
-
// describe(
|
|
303
|
-
// 'When the IoT Agent receives new geo-information from a device.' +
|
|
304
|
-
// 'Location with Polygon type - Array of coordinates',
|
|
305
|
-
// function () {
|
|
306
|
-
// const values = [
|
|
307
|
-
// {
|
|
308
|
-
// name: 'location',
|
|
309
|
-
// type: 'Polygon',
|
|
310
|
-
// value: [
|
|
311
|
-
// [23, 12.5],
|
|
312
|
-
// [22, 13.5],
|
|
313
|
-
// [22, 13.5]
|
|
314
|
-
// ]
|
|
315
|
-
// }
|
|
316
|
-
// ];
|
|
317
|
-
|
|
318
|
-
// beforeEach(function (done) {
|
|
319
|
-
// nock.cleanAll();
|
|
320
|
-
|
|
321
|
-
// contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
322
|
-
// .matchHeader('fiware-service', 'smartgondor')
|
|
323
|
-
// .post(
|
|
324
|
-
// '/v2/entities/light1/attrs',
|
|
325
|
-
// utils.readExampleFile(
|
|
326
|
-
// './test/unit/ngsiv2/examples/contextRequests/updateContextGeoproperties4.json'
|
|
327
|
-
// )
|
|
328
|
-
// )
|
|
329
|
-
// .query({ type: 'Light' })
|
|
330
|
-
// .reply(204);
|
|
331
|
-
|
|
332
|
-
// iotAgentLib.activate(iotAgentConfig, done);
|
|
333
|
-
// });
|
|
334
|
-
|
|
335
|
-
// it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
336
|
-
// iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
337
|
-
// should.not.exist(error);
|
|
338
|
-
// contextBrokerMock.done();
|
|
339
|
-
// done();
|
|
340
|
-
// });
|
|
341
|
-
// });
|
|
342
|
-
// }
|
|
343
|
-
// );
|
|
344
|
-
|
|
345
|
-
// describe(
|
|
346
|
-
// 'When the IoT Agent receives new geo-information from a device.' +
|
|
347
|
-
// 'Location with Polygon type - list of coordinates',
|
|
348
|
-
// function () {
|
|
349
|
-
// const values = [
|
|
350
|
-
// {
|
|
351
|
-
// name: 'location',
|
|
352
|
-
// type: 'Polygon',
|
|
353
|
-
// value: '23,12.5,22,13.5,22,13.5'
|
|
354
|
-
// }
|
|
355
|
-
// ];
|
|
356
|
-
|
|
357
|
-
// beforeEach(function (done) {
|
|
358
|
-
// nock.cleanAll();
|
|
359
|
-
|
|
360
|
-
// contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
361
|
-
// .matchHeader('fiware-service', 'smartgondor')
|
|
362
|
-
// .post(
|
|
363
|
-
// '/v2/entities/light1/attrs',
|
|
364
|
-
// utils.readExampleFile(
|
|
365
|
-
// './test/unit/ngsiv2/examples/contextRequests/updateContextGeoproperties4.json'
|
|
366
|
-
// )
|
|
367
|
-
// )
|
|
368
|
-
// .query({ type: 'Light' })
|
|
369
|
-
// .reply(204);
|
|
370
|
-
|
|
371
|
-
// iotAgentLib.activate(iotAgentConfig, done);
|
|
372
|
-
// });
|
|
373
|
-
|
|
374
|
-
// it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
375
|
-
// iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
376
|
-
// should.not.exist(error);
|
|
377
|
-
// contextBrokerMock.done();
|
|
378
|
-
// done();
|
|
379
|
-
// });
|
|
380
|
-
// });
|
|
381
|
-
// }
|
|
382
|
-
// );
|
|
383
|
-
|
|
384
|
-
// describe('When the IoT Agent receives new geo-information from a device. Location with a missing latitude', function () {
|
|
385
|
-
// const values = [
|
|
386
|
-
// {
|
|
387
|
-
// name: 'location',
|
|
388
|
-
// type: 'Point',
|
|
389
|
-
// value: '23,12.5,22,13.5,22'
|
|
390
|
-
// }
|
|
391
|
-
// ];
|
|
392
|
-
|
|
393
|
-
// beforeEach(function (done) {
|
|
394
|
-
// nock.cleanAll();
|
|
395
|
-
// iotAgentLib.activate(iotAgentConfig, done);
|
|
396
|
-
// });
|
|
397
|
-
|
|
398
|
-
// it('should throw a BadGeocoordinates Error', function (done) {
|
|
399
|
-
// iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
400
|
-
// should.exist(error);
|
|
401
|
-
// done();
|
|
402
|
-
// });
|
|
403
|
-
// });
|
|
404
|
-
// });
|
|
405
|
-
|
|
406
|
-
// describe('When the IoT Agent receives new geo-information from a device. Location invalid coordinates', function () {
|
|
407
|
-
// const values = [
|
|
408
|
-
// {
|
|
409
|
-
// name: 'location',
|
|
410
|
-
// type: 'Point',
|
|
411
|
-
// value: '2016-04-30Z'
|
|
412
|
-
// }
|
|
413
|
-
// ];
|
|
414
|
-
|
|
415
|
-
// beforeEach(function (done) {
|
|
416
|
-
// nock.cleanAll();
|
|
417
|
-
// iotAgentLib.activate(iotAgentConfig, done);
|
|
418
|
-
// });
|
|
419
|
-
|
|
420
|
-
// it('should throw a BadGeocoordinates Error', function (done) {
|
|
421
|
-
// iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
422
|
-
// should.exist(error);
|
|
423
|
-
// done();
|
|
424
|
-
// });
|
|
425
|
-
// });
|
|
426
|
-
// });
|
|
427
|
-
});
|
|
@@ -1,217 +0,0 @@
|
|
|
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 utils = require('../../../tools/utils');
|
|
28
|
-
const should = require('should');
|
|
29
|
-
const logger = require('logops');
|
|
30
|
-
const nock = require('nock');
|
|
31
|
-
let contextBrokerMock;
|
|
32
|
-
const iotAgentConfig = {
|
|
33
|
-
contextBroker: {
|
|
34
|
-
host: '192.168.1.1',
|
|
35
|
-
port: '1026',
|
|
36
|
-
ngsiVersion: 'v2'
|
|
37
|
-
},
|
|
38
|
-
server: {
|
|
39
|
-
port: 4041,
|
|
40
|
-
host: 'localhost'
|
|
41
|
-
},
|
|
42
|
-
types: {
|
|
43
|
-
Light: {
|
|
44
|
-
commands: [],
|
|
45
|
-
type: 'Light',
|
|
46
|
-
lazy: [
|
|
47
|
-
{
|
|
48
|
-
name: 'temperature',
|
|
49
|
-
type: 'centigrades'
|
|
50
|
-
}
|
|
51
|
-
],
|
|
52
|
-
active: [
|
|
53
|
-
{
|
|
54
|
-
name: 'pressure',
|
|
55
|
-
type: 'Hgmm'
|
|
56
|
-
}
|
|
57
|
-
]
|
|
58
|
-
},
|
|
59
|
-
BrokenLight: {
|
|
60
|
-
commands: [],
|
|
61
|
-
lazy: [
|
|
62
|
-
{
|
|
63
|
-
name: 'temperature',
|
|
64
|
-
type: 'centigrades'
|
|
65
|
-
}
|
|
66
|
-
],
|
|
67
|
-
active: [
|
|
68
|
-
{
|
|
69
|
-
name: 'pressure',
|
|
70
|
-
type: 'Hgmm'
|
|
71
|
-
}
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
Termometer: {
|
|
75
|
-
type: 'Termometer',
|
|
76
|
-
commands: [],
|
|
77
|
-
lazy: [
|
|
78
|
-
{
|
|
79
|
-
name: 'temp',
|
|
80
|
-
type: 'kelvin'
|
|
81
|
-
}
|
|
82
|
-
],
|
|
83
|
-
active: []
|
|
84
|
-
},
|
|
85
|
-
Humidity: {
|
|
86
|
-
type: 'Humidity',
|
|
87
|
-
cbHost: 'http://192.168.1.1:3024',
|
|
88
|
-
commands: [],
|
|
89
|
-
lazy: [],
|
|
90
|
-
active: [
|
|
91
|
-
{
|
|
92
|
-
name: 'humidity',
|
|
93
|
-
type: 'percentage'
|
|
94
|
-
}
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
|
-
Motion: {
|
|
98
|
-
type: 'Motion',
|
|
99
|
-
commands: [],
|
|
100
|
-
lazy: [],
|
|
101
|
-
staticAttributes: [
|
|
102
|
-
{
|
|
103
|
-
name: 'location',
|
|
104
|
-
type: 'Vector',
|
|
105
|
-
value: '(123,523)'
|
|
106
|
-
}
|
|
107
|
-
],
|
|
108
|
-
active: [
|
|
109
|
-
{
|
|
110
|
-
name: 'humidity',
|
|
111
|
-
type: 'percentage'
|
|
112
|
-
}
|
|
113
|
-
]
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
service: 'smartgondor',
|
|
117
|
-
subservice: 'gardens',
|
|
118
|
-
providerUrl: 'http://smartgondor.com'
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
describe('NGSI-v2 - Timestamp compression plugin', function () {
|
|
122
|
-
beforeEach(function (done) {
|
|
123
|
-
logger.setLevel('FATAL');
|
|
124
|
-
iotAgentLib.activate(iotAgentConfig, function () {
|
|
125
|
-
iotAgentLib.clearAll(function () {
|
|
126
|
-
done();
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
afterEach(function (done) {
|
|
132
|
-
iotAgentLib.clearAll(function () {
|
|
133
|
-
iotAgentLib.deactivate(done);
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
describe('When an update comes with a timestamp through the plugin', function () {
|
|
137
|
-
const values = [
|
|
138
|
-
{
|
|
139
|
-
name: 'state',
|
|
140
|
-
type: 'Boolean',
|
|
141
|
-
value: 'true'
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
name: 'TheTargetValue',
|
|
145
|
-
type: 'DateTime',
|
|
146
|
-
value: '20071103T131805'
|
|
147
|
-
}
|
|
148
|
-
];
|
|
149
|
-
|
|
150
|
-
beforeEach(function () {
|
|
151
|
-
nock.cleanAll();
|
|
152
|
-
|
|
153
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
154
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
155
|
-
.matchHeader('fiware-servicepath', 'gardens')
|
|
156
|
-
.post(
|
|
157
|
-
'/v2/entities?options=upsert',
|
|
158
|
-
utils.readExampleFile(
|
|
159
|
-
'./test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp1.json'
|
|
160
|
-
)
|
|
161
|
-
)
|
|
162
|
-
.reply(204);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('should return an entity with all its timestamps expanded to have separators', function (done) {
|
|
166
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
167
|
-
should.not.exist(error);
|
|
168
|
-
contextBrokerMock.done();
|
|
169
|
-
done();
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
describe('When an update comes with a timestamp through the plugin with metadata.', function () {
|
|
175
|
-
const values = [
|
|
176
|
-
{
|
|
177
|
-
name: 'state',
|
|
178
|
-
type: 'Boolean',
|
|
179
|
-
value: true,
|
|
180
|
-
metadata: {
|
|
181
|
-
TimeInstant: {
|
|
182
|
-
type: 'DateTime',
|
|
183
|
-
value: '20071103T131805'
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
name: 'TheTargetValue',
|
|
189
|
-
type: 'DateTime',
|
|
190
|
-
value: '20071103T131805'
|
|
191
|
-
}
|
|
192
|
-
];
|
|
193
|
-
|
|
194
|
-
beforeEach(function () {
|
|
195
|
-
nock.cleanAll();
|
|
196
|
-
|
|
197
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
198
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
199
|
-
.matchHeader('fiware-servicepath', 'gardens')
|
|
200
|
-
.post(
|
|
201
|
-
'/v2/entities?options=upsert',
|
|
202
|
-
utils.readExampleFile(
|
|
203
|
-
'./test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp2.json'
|
|
204
|
-
)
|
|
205
|
-
)
|
|
206
|
-
.reply(204);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('should return an entity with all its timestamps expanded to have separators', function (done) {
|
|
210
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
211
|
-
should.not.exist(error);
|
|
212
|
-
contextBrokerMock.done();
|
|
213
|
-
done();
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
});
|