iotagent-node-lib 4.2.0 → 4.4.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/doc/api.md +178 -69
- package/docker/Mosquitto/Dockerfile +1 -1
- package/lib/commonConfig.js +18 -0
- package/lib/errors.js +48 -20
- package/lib/services/commands/commandRegistryMemory.js +12 -2
- package/lib/services/commands/commandRegistryMongoDB.js +26 -15
- package/lib/services/devices/deviceRegistryMemory.js +1 -1
- package/lib/services/devices/deviceRegistryMongoDB.js +7 -12
- package/lib/services/devices/deviceService.js +4 -3
- package/lib/services/devices/devices-NGSI-LD.js +3 -3
- package/lib/services/devices/devices-NGSI-v2.js +10 -4
- package/lib/services/groups/groupRegistryMemory.js +1 -1
- package/lib/services/groups/groupRegistryMongoDB.js +1 -1
- package/lib/services/groups/groupService.js +9 -3
- package/lib/services/ngsi/entities-NGSI-LD.js +15 -7
- package/lib/services/ngsi/entities-NGSI-v2.js +86 -54
- package/lib/services/ngsi/ngsiService.js +3 -3
- package/lib/services/ngsi/subscription-NGSI-LD.js +2 -0
- package/lib/services/ngsi/subscription-NGSI-v2.js +2 -0
- package/lib/services/northBound/contextServer-NGSI-LD.js +50 -55
- package/lib/services/northBound/contextServer-NGSI-v2.js +1 -1
- package/lib/services/northBound/deviceProvisioningServer.js +100 -26
- package/lib/services/northBound/restUtils.js +1 -1
- package/package.json +2 -2
- package/scripts/legacy_expression_tool/requirements.txt +1 -1
- package/test/functional/testCases.js +797 -66
- package/test/functional/testUtils.js +3 -1
- package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +0 -1
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +8 -5
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +34 -2
- package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +37 -2
|
@@ -112,7 +112,9 @@ function jsonToIotaMeasures(json) {
|
|
|
112
112
|
if (key === 'TimeInstant') {
|
|
113
113
|
measure.type = 'DateTime';
|
|
114
114
|
} else {
|
|
115
|
-
|
|
115
|
+
// Although the type is not meaningfull and we could have picked any string for this,
|
|
116
|
+
// we have aligned with DEFAULT_ATTRIBUTE_TYPE constant in IOTA-JSON and IOTA-UL repositories
|
|
117
|
+
measure.type = 'Text';
|
|
116
118
|
}
|
|
117
119
|
measures.push(measure);
|
|
118
120
|
}
|
|
@@ -600,7 +600,6 @@ describe('NGSI-LD - Active attributes test', function () {
|
|
|
600
600
|
should.exist(error.name);
|
|
601
601
|
error.code.should.equal(207);
|
|
602
602
|
error.details.notUpdated.should.equal('someEntities');
|
|
603
|
-
error.message.should.equal('Error accesing entity data for device: light1 of type: Light');
|
|
604
603
|
error.name.should.equal('ENTITY_GENERIC_ERROR');
|
|
605
604
|
contextBrokerMock.done();
|
|
606
605
|
done();
|
|
@@ -905,17 +905,17 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
905
905
|
const valuesIdType = [
|
|
906
906
|
{
|
|
907
907
|
name: 'id',
|
|
908
|
-
type: '
|
|
908
|
+
type: 'aTypeProvidedByIoTACodeCallingUpdateOnLib1',
|
|
909
909
|
value: 'idIoTA'
|
|
910
910
|
},
|
|
911
911
|
{
|
|
912
912
|
name: 'type',
|
|
913
|
-
type: '
|
|
913
|
+
type: 'aTypeProvidedByIoTACodeCallingUpdateOnLib2',
|
|
914
914
|
value: 'typeIoTA'
|
|
915
915
|
},
|
|
916
916
|
{
|
|
917
917
|
name: 'm',
|
|
918
|
-
type: '
|
|
918
|
+
type: 'aTypeProvidedByIoTACodeCallingUpdateOnLib3',
|
|
919
919
|
value: 'measIoTA'
|
|
920
920
|
}
|
|
921
921
|
];
|
|
@@ -923,6 +923,9 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
923
923
|
beforeEach(function (done) {
|
|
924
924
|
nock.cleanAll();
|
|
925
925
|
|
|
926
|
+
// Note that in the case of measure_id and measure_type the type provided by the IOTA when calling iotAgentLib.update()
|
|
927
|
+
// is used (thus ignoring the one of the StupidDevice group for id or type, which is 'text') but in the case of measIoTA the type provided in the
|
|
928
|
+
// provisioning ('String') is used
|
|
926
929
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
927
930
|
.matchHeader('fiware-service', 'smartgondor')
|
|
928
931
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
@@ -934,11 +937,11 @@ describe('NGSI-v2 - Active attributes test', function () {
|
|
|
934
937
|
type: 'String'
|
|
935
938
|
},
|
|
936
939
|
measure_id: {
|
|
937
|
-
type: '
|
|
940
|
+
type: 'aTypeProvidedByIoTACodeCallingUpdateOnLib1',
|
|
938
941
|
value: 'idIoTA'
|
|
939
942
|
},
|
|
940
943
|
measure_type: {
|
|
941
|
-
type: '
|
|
944
|
+
type: 'aTypeProvidedByIoTACodeCallingUpdateOnLib2',
|
|
942
945
|
value: 'typeIoTA'
|
|
943
946
|
}
|
|
944
947
|
})
|
|
@@ -307,6 +307,38 @@ const iotAgentConfig = {
|
|
|
307
307
|
}
|
|
308
308
|
]
|
|
309
309
|
},
|
|
310
|
+
WeatherStation10: {
|
|
311
|
+
commands: [],
|
|
312
|
+
type: 'WeatherStation',
|
|
313
|
+
lazy: [],
|
|
314
|
+
active: [
|
|
315
|
+
{
|
|
316
|
+
object_id: 'p',
|
|
317
|
+
name: 'pressure',
|
|
318
|
+
type: 'Hgmm'
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
object_id: 'h',
|
|
322
|
+
name: 'humidity',
|
|
323
|
+
type: 'Percentage',
|
|
324
|
+
entity_name: 'Higro2000',
|
|
325
|
+
entity_type: 'Higrometer',
|
|
326
|
+
metadata: {
|
|
327
|
+
unitCode: {
|
|
328
|
+
type: 'Text',
|
|
329
|
+
value: 'Hgmm'
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
object_id: 'TimeInstant',
|
|
335
|
+
name: 'TimeInstant',
|
|
336
|
+
type: 'DateTime',
|
|
337
|
+
entity_name: 'Higro2000',
|
|
338
|
+
entity_type: 'Higrometer'
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
},
|
|
310
342
|
Sensor001: {
|
|
311
343
|
commands: [],
|
|
312
344
|
type: 'Sensor',
|
|
@@ -1488,7 +1520,7 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
|
|
|
1488
1520
|
|
|
1489
1521
|
describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plugin', function () {
|
|
1490
1522
|
beforeEach(function (done) {
|
|
1491
|
-
logger.setLevel('
|
|
1523
|
+
logger.setLevel('DEBUG');
|
|
1492
1524
|
iotAgentConfig.timestamp = true;
|
|
1493
1525
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
1494
1526
|
iotAgentLib.clearAll(function () {
|
|
@@ -1635,7 +1667,7 @@ describe('NGSI-v2 - Multi-entity plugin is executed before timestamp process plu
|
|
|
1635
1667
|
value: '2018-06-13T13:28:34.611Z'
|
|
1636
1668
|
}
|
|
1637
1669
|
];
|
|
1638
|
-
iotAgentLib.update('ws5', '
|
|
1670
|
+
iotAgentLib.update('ws5', 'WeatherStation10', '', tsValue, function (error) {
|
|
1639
1671
|
should.not.exist(error);
|
|
1640
1672
|
contextBrokerMock.done();
|
|
1641
1673
|
done();
|
|
@@ -161,7 +161,7 @@ describe('NGSI-v2 - Device provisioning API: Remove provisioned devices', functi
|
|
|
161
161
|
method: 'DELETE'
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
-
it('should return a
|
|
164
|
+
it('should return a 204 OK and no errors', function (done) {
|
|
165
165
|
request(options, function (error, response, body) {
|
|
166
166
|
should.not.exist(error);
|
|
167
167
|
response.statusCode.should.equal(204);
|
|
@@ -231,7 +231,42 @@ describe('NGSI-v2 - Device provisioning API: Remove provisioned devices', functi
|
|
|
231
231
|
method: 'DELETE'
|
|
232
232
|
};
|
|
233
233
|
|
|
234
|
-
it('should return a
|
|
234
|
+
it('should return a 204 OK and no errors', function (done) {
|
|
235
|
+
request(options, function (error, response, body) {
|
|
236
|
+
should.not.exist(error);
|
|
237
|
+
response.statusCode.should.equal(204);
|
|
238
|
+
done();
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
describe('When a request to remove a provision devices arrives', function () {
|
|
244
|
+
const options = {
|
|
245
|
+
url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/op/delete',
|
|
246
|
+
headers: {
|
|
247
|
+
'fiware-service': 'smartgondor',
|
|
248
|
+
'fiware-servicepath': '/gardens'
|
|
249
|
+
},
|
|
250
|
+
method: 'POST',
|
|
251
|
+
json: {
|
|
252
|
+
devices: [
|
|
253
|
+
{
|
|
254
|
+
deviceId: 'Light1',
|
|
255
|
+
apikey: ''
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
deviceId: 'Light2',
|
|
259
|
+
apikey: ''
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
deviceId: 'Light3',
|
|
263
|
+
apikey: ''
|
|
264
|
+
}
|
|
265
|
+
]
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
it('should return a 204 OK and no errors', function (done) {
|
|
235
270
|
request(options, function (error, response, body) {
|
|
236
271
|
should.not.exist(error);
|
|
237
272
|
response.statusCode.should.equal(204);
|