iotagent-node-lib 4.7.0 → 4.9.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 +6 -3
- package/.nyc_output/e4b1fe20-197e-4221-9f8d-6db65ff234b2.json +1 -0
- package/.nyc_output/processinfo/e4b1fe20-197e-4221-9f8d-6db65ff234b2.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/CHANGES_NEXT_RELEASE +1 -0
- package/Changelog +793 -0
- package/doc/README.md +1 -0
- package/doc/admin.md +8 -4
- package/doc/api.md +8 -4
- package/doc/devel/northboundinteractions.md +122 -15
- package/doc/models/models.md +260 -0
- package/doc/requirements.txt +1 -1
- package/docker/Mosquitto/Dockerfile +1 -1
- package/lib/commonConfig.js +11 -2
- package/lib/fiware-iotagent-lib.js +15 -11
- package/lib/jexlTranformsMap.js +182 -35
- package/lib/model/Command.js +9 -0
- package/lib/model/Device.js +1 -0
- package/lib/services/commands/commandRegistryMongoDB.js +15 -1
- package/lib/services/commands/commandService.js +3 -3
- package/lib/services/common/domain.js +4 -3
- package/lib/services/devices/deviceRegistryMongoDB.js +1 -1
- package/lib/services/devices/deviceService.js +11 -2
- package/lib/services/devices/devices-NGSI-LD.js +1 -2
- package/lib/services/devices/devices-NGSI-v2.js +1 -2
- package/lib/services/ngsi/entities-NGSI-LD.js +69 -13
- package/lib/services/ngsi/ngsiService.js +3 -1
- package/lib/services/northBound/contextServer-NGSI-LD.js +5 -3
- package/lib/services/northBound/contextServer-NGSI-v2.js +12 -3
- package/lib/services/northBound/contextServer.js +2 -1
- package/lib/services/northBound/northboundServer.js +2 -1
- package/lib/services/northBound/restUtils.js +6 -2
- package/lib/templates/createDevice.json +4 -0
- package/lib/templates/updateDevice.json +4 -0
- package/package.json +1 -1
- package/test/functional/config-test.js +1 -1
- package/test/functional/testUtils.js +13 -2
- package/test/unit/expressions/jexlExpression-test.js +165 -1
- package/test/unit/ngsi-ld/examples/contextRequests/createDatetimeProvisionedDevice.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDevice.json +3 -12
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceMultientity.json +3 -12
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json +6 -24
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContext1.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContext3WithStatic.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContext4.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContext5.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin7.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin8.json +4 -2
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin9.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextCommandError.json +3 -9
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextCommandExpired.json +13 -19
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextCommandFinish.json +13 -19
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextCommandStatus1.json +4 -9
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextCompressTimestamp1.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextCompressTimestamp2.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin1a.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin2.json +2 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin29.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4.json +2 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4a.json +3 -12
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin6.json +3 -5
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin7.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin8a.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextJsonProperty.json +13 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextListProperty.json +14 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextListRelationship.json +14 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin1.json +2 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin2.json +2 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin3.json +3 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin4.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin5.json +2 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin8.json +2 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +2 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextRelationship.json +11 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextValueType1.json +51 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextValueType2.json +65 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextVocabProperty.json +11 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionCommands1.json +2 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionDeviceStatic.json +1 -4
- package/test/unit/ngsi-ld/general/startup-test.js +3 -0
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +1 -1
- package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +71 -1
- package/test/unit/ngsi-ld/ngsiService/attributeTypes-test.js +293 -0
- package/test/unit/ngsi-ld/ngsiService/unsupported-endpoints-test.js +0 -10
- package/test/unit/ngsi-ld/ngsiService/value-types-test.js +221 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast1.json +0 -11
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast10.json +0 -14
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast2.json +0 -11
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast3.json +0 -11
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast4.json +0 -11
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast5.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast6.json +0 -17
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast7.json +0 -19
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast8.json +0 -14
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast9.json +0 -14
- package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +0 -109
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast1.json +0 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast2.json +0 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast3.json +0 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast4.json +0 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast5.json +0 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast6.json +0 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast7.json +0 -8
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +0 -326
- /package/test/unit/ngsi-ld/examples/contextRequests/{updateContextLanguageProperties1.json → updateContextLanguageProperty.json} +0 -0
|
@@ -30,7 +30,7 @@ const context = {
|
|
|
30
30
|
op: 'IoTAgentNGSI.ContextServer'
|
|
31
31
|
};
|
|
32
32
|
const contextServerUtils = require('./contextServerUtils');
|
|
33
|
-
|
|
33
|
+
const executeUpdateSideEffects = contextServerUtils.executeUpdateSideEffects;
|
|
34
34
|
let contextServerHandler;
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -157,4 +157,5 @@ exports.setCommandHandler = intoTrans(context, setCommandHandler);
|
|
|
157
157
|
exports.setNotificationHandler = intoTrans(context, setNotificationHandler);
|
|
158
158
|
exports.addNotificationMiddleware = intoTrans(context, addNotificationMiddleware);
|
|
159
159
|
exports.setQueryHandler = intoTrans(context, setQueryHandler);
|
|
160
|
+
exports.executeUpdateSideEffects = intoTrans(context, executeUpdateSideEffects);
|
|
160
161
|
exports.init = init;
|
|
@@ -59,7 +59,7 @@ function start(config, callback) {
|
|
|
59
59
|
northboundServer.app.use(domainUtils.requestDomain);
|
|
60
60
|
northboundServer.app.use(bodyParser.json({ limit: config.expressLimit }));
|
|
61
61
|
northboundServer.app.use(bodyParser.json({ type: 'application/*+json', limit: config.expressLimit }));
|
|
62
|
-
|
|
62
|
+
northboundServer.app.set('trust proxy', true); // populate req.ip
|
|
63
63
|
if (config.logLevel && config.logLevel === 'DEBUG') {
|
|
64
64
|
northboundServer.app.use(middlewares.traceRequest);
|
|
65
65
|
}
|
|
@@ -125,6 +125,7 @@ exports.setRemoveDeviceHandler = intoTrans(context, deviceProvisioning.setRemove
|
|
|
125
125
|
exports.addDeviceProvisionMiddleware = deviceProvisioning.addDeviceProvisionMiddleware;
|
|
126
126
|
exports.addConfigurationProvisionMiddleware = groupProvisioning.addConfigurationProvisionMiddleware;
|
|
127
127
|
exports.addNotificationMiddleware = contextServer.addNotificationMiddleware;
|
|
128
|
+
exports.executeUpdateSideEffects = contextServer.executeUpdateSideEffects;
|
|
128
129
|
exports.clear = clear;
|
|
129
130
|
exports.start = intoTrans(context, start);
|
|
130
131
|
exports.stop = intoTrans(context, stop);
|
|
@@ -30,7 +30,6 @@ const errors = require('../../errors');
|
|
|
30
30
|
const constants = require('../../constants');
|
|
31
31
|
const intoTrans = require('../common/domain').intoTrans;
|
|
32
32
|
const revalidator = require('revalidator');
|
|
33
|
-
const moment = require('moment');
|
|
34
33
|
const context = {
|
|
35
34
|
op: 'IoTAgentNGSI.RestUtils'
|
|
36
35
|
};
|
|
@@ -121,6 +120,11 @@ function checkBody(template) {
|
|
|
121
120
|
};
|
|
122
121
|
}
|
|
123
122
|
|
|
123
|
+
function isISOString(val) {
|
|
124
|
+
const d = new Date(val);
|
|
125
|
+
return !Number.isNaN(d.valueOf()) && d.toISOString() === val;
|
|
126
|
+
}
|
|
127
|
+
|
|
124
128
|
/**
|
|
125
129
|
* Checks if the timestamp properties of NGSIv2 entities are valid ISO8601 dates.
|
|
126
130
|
*
|
|
@@ -131,7 +135,7 @@ function IsValidTimestampedNgsi2(payload) {
|
|
|
131
135
|
function isValidTimestampedNgsi2Entity(entity) {
|
|
132
136
|
for (const i in entity) {
|
|
133
137
|
if (entity.hasOwnProperty(i)) {
|
|
134
|
-
if (i === constants.TIMESTAMP_ATTRIBUTE && !
|
|
138
|
+
if (i === constants.TIMESTAMP_ATTRIBUTE && !isISOString(entity[i].value)) {
|
|
135
139
|
return false;
|
|
136
140
|
}
|
|
137
141
|
}
|
|
@@ -145,6 +145,10 @@
|
|
|
145
145
|
"description": "Optional expression for command transformation",
|
|
146
146
|
"type": "string"
|
|
147
147
|
},
|
|
148
|
+
"headers": {
|
|
149
|
+
"description": "Optional headers to include with command",
|
|
150
|
+
"type": "object"
|
|
151
|
+
},
|
|
148
152
|
"payloadType": {
|
|
149
153
|
"description": "Payload type",
|
|
150
154
|
"type": "string"
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "iotagent-node-lib",
|
|
3
3
|
"license": "AGPL-3.0-only",
|
|
4
4
|
"description": "IoT Agent library to interface with NGSI Context Broker",
|
|
5
|
-
"version": "4.
|
|
5
|
+
"version": "4.9.0",
|
|
6
6
|
"homepage": "https://github.com/telefonicaid/iotagent-node-lib",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"fiware",
|
|
@@ -74,16 +74,27 @@ function sendMeasureIotaLib(measure, provision) {
|
|
|
74
74
|
* This is not a problem for the tests using other transports than Lib, in that case, the type will be retrieved
|
|
75
75
|
* from the real provision.
|
|
76
76
|
*/
|
|
77
|
+
let typeInformation = {
|
|
78
|
+
service: provision.headers['fiware-service'],
|
|
79
|
+
subservice: provision.headers['fiware-servicepath']
|
|
80
|
+
};
|
|
77
81
|
let type;
|
|
82
|
+
let staticAttrs;
|
|
78
83
|
if (Array.isArray(provision.json.services) && provision.json.services.length > 0) {
|
|
79
84
|
type = provision.json.services[0].entity_type;
|
|
85
|
+
staticAttrs = provision.json.services[0].static_attributes;
|
|
80
86
|
} else {
|
|
81
87
|
type = DEF_TYPE;
|
|
82
88
|
}
|
|
89
|
+
typeInformation.type = type;
|
|
90
|
+
if (staticAttrs) {
|
|
91
|
+
typeInformation.staticAttributes = staticAttrs;
|
|
92
|
+
}
|
|
93
|
+
typeInformation.id = measure.qs.i;
|
|
83
94
|
iotAgentLib.update(
|
|
84
95
|
type + ':' + measure.qs.i,
|
|
85
96
|
type,
|
|
86
|
-
|
|
97
|
+
typeInformation,
|
|
87
98
|
jsonToIotaMeasures(measure.json),
|
|
88
99
|
function (error, result, body) {
|
|
89
100
|
error ? reject(error) : resolve(result);
|
|
@@ -230,7 +241,7 @@ async function testCase(measure, expectation, provision, env, config, type, tran
|
|
|
230
241
|
if (transport === 'MQTT') {
|
|
231
242
|
try {
|
|
232
243
|
let client = await MQTT.connectAsync('mqtt://' + config.mqtt.host);
|
|
233
|
-
await client.publish('/' + measure.qs.k + '/' + measure.qs.i + '/attrs', JSON.stringify(measure.json));
|
|
244
|
+
await client.publish('/json/' + measure.qs.k + '/' + measure.qs.i + '/attrs', JSON.stringify(measure.json));
|
|
234
245
|
await client.end();
|
|
235
246
|
} catch (error) {
|
|
236
247
|
expect.fail(ERR_MQTT + error);
|
|
@@ -40,7 +40,12 @@ describe('Jexl expression interpreter', function () {
|
|
|
40
40
|
object: {
|
|
41
41
|
name: 'John',
|
|
42
42
|
surname: 'Doe'
|
|
43
|
-
}
|
|
43
|
+
},
|
|
44
|
+
invalidJson: '{"name": "John", surname": "Doe"}', // Invalid JSON for jsonparse
|
|
45
|
+
invalidDate: 'invalid-date', // Invalid date for toisodate and other date functions
|
|
46
|
+
emptyArray: [], // Empty array for addreduce
|
|
47
|
+
invalidHex: 'zz', // Invalid hex string for hextostring
|
|
48
|
+
nonNumeric: 'not-a-number' // Non-numeric input for parseint, parsefloat
|
|
44
49
|
};
|
|
45
50
|
|
|
46
51
|
describe('When a expression with a single value is parsed', function () {
|
|
@@ -392,4 +397,163 @@ describe('Jexl expression interpreter', function () {
|
|
|
392
397
|
});
|
|
393
398
|
});
|
|
394
399
|
});
|
|
400
|
+
|
|
401
|
+
// Check errors
|
|
402
|
+
describe('When invalid inputs are used', function () {
|
|
403
|
+
describe('When an invalid JSON string is parsed', function () {
|
|
404
|
+
it('should return null for jsonparse', function (done) {
|
|
405
|
+
expressionParser.parse('invalidJson|jsonparse', scope, function (error, result) {
|
|
406
|
+
should.not.exist(error);
|
|
407
|
+
should(result).be.Null();
|
|
408
|
+
done();
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
describe('When an invalid date string is parsed', function () {
|
|
414
|
+
it('should return null for toisodate', function (done) {
|
|
415
|
+
expressionParser.parse('invalidDate|toisodate', scope, function (error, result) {
|
|
416
|
+
should.not.exist(error);
|
|
417
|
+
should(result).be.Null();
|
|
418
|
+
done();
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
it('should return null for timeoffset', function (done) {
|
|
423
|
+
expressionParser.parse('invalidDate|timeoffset', scope, function (error, result) {
|
|
424
|
+
should.not.exist(error);
|
|
425
|
+
should(result).be.Null();
|
|
426
|
+
done();
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
describe('When an empty array is processed with addreduce', function () {
|
|
432
|
+
it('should return null for addreduce', function (done) {
|
|
433
|
+
expressionParser.parse('emptyArray|addreduce', scope, function (error, result) {
|
|
434
|
+
should.not.exist(error);
|
|
435
|
+
should(result).be.Null();
|
|
436
|
+
done();
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
describe('When a non-numeric string is parsed by parseint and parsefloat', function () {
|
|
442
|
+
it('should return null for parseint', function (done) {
|
|
443
|
+
expressionParser.parse('nonNumeric|parseint', scope, function (error, result) {
|
|
444
|
+
should.not.exist(error);
|
|
445
|
+
should(result).be.Null();
|
|
446
|
+
done();
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
it('should return null for parsefloat', function (done) {
|
|
451
|
+
expressionParser.parse('nonNumeric|parsefloat', scope, function (error, result) {
|
|
452
|
+
should.not.exist(error);
|
|
453
|
+
should(result).be.Null();
|
|
454
|
+
done();
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
describe('When an invalid hex string is processed by hextostring', function () {
|
|
460
|
+
it('should return null for hextostring', function (done) {
|
|
461
|
+
expressionParser.parse('invalidHex|hextostring', scope, function (error, result) {
|
|
462
|
+
should.not.exist(error);
|
|
463
|
+
should(result).be.Null();
|
|
464
|
+
done();
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
describe('When invalid regular expressions are used in replace functions', function () {
|
|
470
|
+
it('should return null for replaceregexp with invalid regex', function (done) {
|
|
471
|
+
expressionParser.parse(
|
|
472
|
+
'theString|replaceregexp("[a-z", "replacement")',
|
|
473
|
+
scope,
|
|
474
|
+
function (error, result) {
|
|
475
|
+
should.not.exist(error);
|
|
476
|
+
should(result).be.Null();
|
|
477
|
+
done();
|
|
478
|
+
}
|
|
479
|
+
);
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
it('should return null for replaceallregexp with invalid regex', function (done) {
|
|
483
|
+
expressionParser.parse(
|
|
484
|
+
'theString|replaceallregexp("[a-z", "replacement")',
|
|
485
|
+
scope,
|
|
486
|
+
function (error, result) {
|
|
487
|
+
should.not.exist(error);
|
|
488
|
+
should(result).be.Null();
|
|
489
|
+
done();
|
|
490
|
+
}
|
|
491
|
+
);
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
describe('When tostring is used with null or undefined', function () {
|
|
496
|
+
it('should return null for tostring(null)', function (done) {
|
|
497
|
+
expressionParser.parse('null|tostring', scope, function (error, result) {
|
|
498
|
+
should.not.exist(error);
|
|
499
|
+
should(result).be.Null();
|
|
500
|
+
done();
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
it('should return null for tostring(undefined)', function (done) {
|
|
505
|
+
expressionParser.parse('undefined|tostring', scope, function (error, result) {
|
|
506
|
+
should.not.exist(error);
|
|
507
|
+
should(result).be.Null();
|
|
508
|
+
done();
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
describe('When urldecode is used with an invalid URI', function () {
|
|
514
|
+
it('should return null for urldecode with malformed URI', function (done) {
|
|
515
|
+
expressionParser.parse('"%%%invalidURI"|urldecode', scope, function (error, result) {
|
|
516
|
+
should.not.exist(error);
|
|
517
|
+
should(result).be.Null();
|
|
518
|
+
done();
|
|
519
|
+
});
|
|
520
|
+
});
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
describe('When tofixed is used with invalid inputs', function () {
|
|
524
|
+
it('should return null for tofixed with non-numeric value', function (done) {
|
|
525
|
+
expressionParser.parse('"notANumber"|tofixed(2)', scope, function (error, result) {
|
|
526
|
+
should.not.exist(error);
|
|
527
|
+
should(result).be.Null();
|
|
528
|
+
done();
|
|
529
|
+
});
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
it('should return null for tofixed with invalid decimal value', function (done) {
|
|
533
|
+
expressionParser.parse('"123.456"|tofixed("invalid")', scope, function (error, result) {
|
|
534
|
+
should.not.exist(error);
|
|
535
|
+
should(result).be.Null();
|
|
536
|
+
done();
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
describe('When gettime is used with invalid date', function () {
|
|
542
|
+
it('should return null for gettime with invalid date string', function (done) {
|
|
543
|
+
expressionParser.parse('"invalidDate"|gettime', scope, function (error, result) {
|
|
544
|
+
should.not.exist(error);
|
|
545
|
+
should(result).be.Null();
|
|
546
|
+
done();
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
it('should return null for gettime with null', function (done) {
|
|
551
|
+
expressionParser.parse('null|gettime', scope, function (error, result) {
|
|
552
|
+
should.not.exist(error);
|
|
553
|
+
should(result).be.Null();
|
|
554
|
+
done();
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
});
|
|
395
559
|
});
|
|
@@ -3,24 +3,15 @@
|
|
|
3
3
|
"@context": "http://context.json-ld",
|
|
4
4
|
"commandAttr_info": {
|
|
5
5
|
"type": "Property",
|
|
6
|
-
"value":
|
|
7
|
-
"@type": "commandResult",
|
|
8
|
-
"@value": " "
|
|
9
|
-
}
|
|
6
|
+
"value": " "
|
|
10
7
|
},
|
|
11
8
|
"commandAttr_status": {
|
|
12
9
|
"type": "Property",
|
|
13
|
-
"value":
|
|
14
|
-
"@type": "commandStatus",
|
|
15
|
-
"@value": "UNKNOWN"
|
|
16
|
-
}
|
|
10
|
+
"value": "UNKNOWN"
|
|
17
11
|
},
|
|
18
12
|
"hardcodedAttr": {
|
|
19
13
|
"type": "Property",
|
|
20
|
-
"value":
|
|
21
|
-
"@type": "hardcodedType",
|
|
22
|
-
"@value": "hardcodedValue"
|
|
23
|
-
}
|
|
14
|
+
"value": "hardcodedValue"
|
|
24
15
|
},
|
|
25
16
|
"id": "urn:ngsi-ld:TheLightType:TheFirstLight",
|
|
26
17
|
"type": "TheLightType"
|
|
@@ -3,24 +3,15 @@
|
|
|
3
3
|
"@context": "http://context.json-ld",
|
|
4
4
|
"commandAttr_info": {
|
|
5
5
|
"type": "Property",
|
|
6
|
-
"value":
|
|
7
|
-
"@type": "commandResult",
|
|
8
|
-
"@value": " "
|
|
9
|
-
}
|
|
6
|
+
"value": " "
|
|
10
7
|
},
|
|
11
8
|
"commandAttr_status": {
|
|
12
9
|
"type": "Property",
|
|
13
|
-
"value":
|
|
14
|
-
"@type": "commandStatus",
|
|
15
|
-
"@value": "UNKNOWN"
|
|
16
|
-
}
|
|
10
|
+
"value": "UNKNOWN"
|
|
17
11
|
},
|
|
18
12
|
"hardcodedAttr": {
|
|
19
13
|
"type": "Property",
|
|
20
|
-
"value":
|
|
21
|
-
"@type": "hardcodedType",
|
|
22
|
-
"@value": "hardcodedValue"
|
|
23
|
-
}
|
|
14
|
+
"value": "hardcodedType"
|
|
24
15
|
},
|
|
25
16
|
"id": "urn:ngsi-ld:TheLightType:TheFirstLight",
|
|
26
17
|
"type": "TheLightType"
|
package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json
CHANGED
|
@@ -5,45 +5,27 @@
|
|
|
5
5
|
"type": "TheLightType",
|
|
6
6
|
"hardcodedAttr": {
|
|
7
7
|
"type": "Property",
|
|
8
|
-
"value":
|
|
9
|
-
"@type": "hardcodedType",
|
|
10
|
-
"@value": "hardcodedValue"
|
|
11
|
-
}
|
|
8
|
+
"value": "hardcodedType"
|
|
12
9
|
},
|
|
13
10
|
"bootstrapServer": {
|
|
14
11
|
"type": "Property",
|
|
15
|
-
"value":
|
|
16
|
-
"@type": "Address",
|
|
17
|
-
"@value": "127.0.0.1"
|
|
18
|
-
}
|
|
12
|
+
"value": "127.0.0.1"
|
|
19
13
|
},
|
|
20
14
|
"commandAttr_status": {
|
|
21
15
|
"type": "Property",
|
|
22
|
-
"value":
|
|
23
|
-
"@type": "commandStatus",
|
|
24
|
-
"@value": "UNKNOWN"
|
|
25
|
-
}
|
|
16
|
+
"value": "UNKNOWN"
|
|
26
17
|
},
|
|
27
18
|
"commandAttr_info": {
|
|
28
19
|
"type": "Property",
|
|
29
|
-
"value":
|
|
30
|
-
"@type": "commandResult",
|
|
31
|
-
"@value": " "
|
|
32
|
-
}
|
|
20
|
+
"value": "commandResult",
|
|
33
21
|
},
|
|
34
22
|
"wheel1_status": {
|
|
35
23
|
"type": "Property",
|
|
36
|
-
"value":
|
|
37
|
-
"@type": "commandStatus",
|
|
38
|
-
"@value": "UNKNOWN"
|
|
39
|
-
}
|
|
24
|
+
"value": "commandStatus"
|
|
40
25
|
},
|
|
41
26
|
"wheel1_info": {
|
|
42
27
|
"type": "Property",
|
|
43
|
-
"value":
|
|
44
|
-
"@type": "commandResult",
|
|
45
|
-
"@value": " "
|
|
46
|
-
}
|
|
28
|
+
"value": "commandResult"
|
|
47
29
|
}
|
|
48
30
|
}
|
|
49
31
|
]
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
"configuration": {
|
|
5
5
|
"type": "Property",
|
|
6
6
|
"value": {
|
|
7
|
-
"
|
|
8
|
-
|
|
7
|
+
"firmware": {
|
|
8
|
+
"version": "1.1.0",
|
|
9
|
+
"hash": "cf23df2207d99a74fbe169e3eba035e633b65d94"
|
|
10
|
+
}
|
|
9
11
|
}
|
|
10
12
|
},
|
|
11
13
|
"id": "urn:ngsi-ld:Light:light1",
|
|
@@ -3,19 +3,13 @@
|
|
|
3
3
|
"@context": "http://context.json-ld",
|
|
4
4
|
"position_status": {
|
|
5
5
|
"type": "Property",
|
|
6
|
-
"value":
|
|
7
|
-
"@type": "commandStatus",
|
|
8
|
-
"@value": "ERROR"
|
|
9
|
-
}
|
|
6
|
+
"value": "ERROR"
|
|
10
7
|
},
|
|
11
8
|
"position_info": {
|
|
12
9
|
"type": "Property",
|
|
13
|
-
"value":
|
|
14
|
-
"@type": "commandResult",
|
|
15
|
-
"@value": "Stalled"
|
|
16
|
-
}
|
|
10
|
+
"value": "Stalled"
|
|
17
11
|
},
|
|
18
12
|
"id": "urn:ngsi-ld:Robot:r2d2",
|
|
19
13
|
"type": "Robot"
|
|
20
14
|
}
|
|
21
|
-
]
|
|
15
|
+
]
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"@value":"EXPIRED"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"id":"urn:ngsi-ld:Robot:r2d2",
|
|
19
|
-
"type":"Robot"
|
|
20
|
-
}
|
|
2
|
+
{
|
|
3
|
+
"@context":"http://context.json-ld",
|
|
4
|
+
"position_status": {
|
|
5
|
+
"type":"Property",
|
|
6
|
+
"value": "ERROR"
|
|
7
|
+
},
|
|
8
|
+
"position_info": {
|
|
9
|
+
"type":"Property",
|
|
10
|
+
"value": "EXPIRED"
|
|
11
|
+
},
|
|
12
|
+
"id":"urn:ngsi-ld:Robot:r2d2",
|
|
13
|
+
"type":"Robot"
|
|
14
|
+
}
|
|
21
15
|
]
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"@value":"[72, 368, 1]"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"id":"urn:ngsi-ld:Robot:r2d2",
|
|
19
|
-
"type":"Robot"
|
|
20
|
-
}
|
|
2
|
+
{
|
|
3
|
+
"@context":"http://context.json-ld",
|
|
4
|
+
"position_status": {
|
|
5
|
+
"type": "Property",
|
|
6
|
+
"value": "FINISHED"
|
|
7
|
+
},
|
|
8
|
+
"position_info": {
|
|
9
|
+
"type":"Property",
|
|
10
|
+
"value": [72, 368, 1]
|
|
11
|
+
},
|
|
12
|
+
"id":"urn:ngsi-ld:Robot:r2d2",
|
|
13
|
+
"type":"Robot"
|
|
14
|
+
}
|
|
21
15
|
]
|