iotagent-node-lib 2.26.0 → 3.1.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 +1 -0
- package/CHANGES_NEXT_RELEASE +2 -0
- package/docker-compose-dev.yml +1 -1
- package/lib/fiware-iotagent-lib.js +0 -5
- package/lib/plugins/compressTimestamp.js +2 -7
- package/lib/plugins/expressionParser.js +0 -47
- package/lib/plugins/expressionPlugin.js +6 -78
- package/lib/plugins/jexlParser.js +0 -36
- package/lib/plugins/pluginUtils.js +0 -119
- package/lib/services/ngsi/entities-NGSI-LD.js +586 -199
- package/lib/services/ngsi/entities-NGSI-v2.js +607 -297
- package/lib/services/ngsi/ngsiUtils.js +15 -22
- package/package.json +2 -2
- package/test/unit/general/config-multi-core-test.js +2 -1
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +2 -1
- package/test/unit/general/deviceService-test.js +2 -1
- package/test/unit/general/loglevel-api_test.js +2 -3
- package/test/unit/general/startup-test.js +2 -1
- package/test/unit/general/statistics-persistence_test.js +1 -0
- package/test/unit/general/statistics-service_test.js +1 -0
- package/test/unit/lazyAndCommands/commandRegistry_test.js +1 -0
- package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +1 -0
- package/test/unit/mongodb/mongodb-connectionoptions-test.js +1 -0
- package/test/unit/mongodb/mongodb-group-registry-test.js +1 -0
- package/test/unit/mongodb/mongodb-registry-test.js +2 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin1.json +0 -5
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast10.json +1 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast8.json +1 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast9.json +1 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +16 -15
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4.json +8 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4a.json +34 -34
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin5.json +8 -8
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin6.json +0 -20
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin7.json +0 -5
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin8.json +10 -10
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +8 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +5 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextProcessTimestamp.json +4 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextTimestampOverride.json +4 -3
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +4 -3
- package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +4 -6
- package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +1 -7
- package/test/unit/ngsi-ld/general/config-jsonld-contexts-test.js +2 -1
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +2 -1
- package/test/unit/ngsi-ld/general/deviceService-test.js +2 -1
- package/test/unit/ngsi-ld/general/https-support-test.js +2 -1
- package/test/unit/ngsi-ld/general/iotam-autoregistration-test.js +2 -1
- package/test/unit/ngsi-ld/general/startup-test.js +3 -2
- package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +2 -1
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +5 -7
- package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +8 -6
- package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +18 -22
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +17 -4
- package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +32 -34
- package/test/unit/ngsi-ld/ngsiService/staticAttributes-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/unsupported-endpoints-test.js +11 -15
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +2 -3
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +2 -1
- package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +2 -32
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +20 -19
- package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +21 -7
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +2 -1
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +15 -12
- package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +1 -0
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +13 -7
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json +2 -2
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +4 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +0 -16
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +8 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +42 -42
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +7 -7
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +0 -5
- package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +6 -6
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +7 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +7 -1
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +2 -4
- package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +4 -8
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +5 -9
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +2 -1
- package/test/unit/ngsiv2/general/deviceService-test.js +2 -1
- package/test/unit/ngsiv2/general/https-support-test.js +2 -1
- package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +2 -1
- package/test/unit/ngsiv2/general/startup-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +8 -6
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +2 -1
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +3 -2
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +2 -1
- package/test/unit/ngsiv2/ngsiService/queryDeviceInformationInCb-test.js +2 -1
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +2 -1
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +2 -1
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +2 -3
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +2 -5
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +2 -33
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +7 -16
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +3 -2
- package/test/unit/ngsiv2/provisioning/device-group-api-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +1 -0
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +2 -1
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +15 -12
- package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +1 -0
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +1 -0
- package/test/unit/plugins/capture-configuration-inPlugins_test.js +2 -1
- package/test/unit/plugins/capture-provision-inPlugins_test.js +2 -1
- package/lib/plugins/addEvent.js +0 -32
- package/lib/plugins/attributeAlias.js +0 -107
- package/lib/plugins/multiEntity.js +0 -255
- package/lib/plugins/timestampProcessPlugin.js +0 -95
- package/test/unit/ngsi-ld/plugins/event-plugin_test.js +0 -116
- package/test/unit/ngsiv2/plugins/event-plugin_test.js +0 -118
- package/test/unit/ngsiv2/plugins/translation-inPlugins_test.js +0 -262
|
@@ -40,7 +40,8 @@ const iotAgentConfig = {
|
|
|
40
40
|
jsonLdContext: 'http://context.json-ld'
|
|
41
41
|
},
|
|
42
42
|
server: {
|
|
43
|
-
port: 4041
|
|
43
|
+
port: 4041,
|
|
44
|
+
host: 'localhost'
|
|
44
45
|
},
|
|
45
46
|
types: {
|
|
46
47
|
Light: {
|
|
@@ -198,9 +199,6 @@ describe('NGSI-LD - Expression-based transformations plugin', function () {
|
|
|
198
199
|
|
|
199
200
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
200
201
|
iotAgentLib.clearAll(function () {
|
|
201
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
202
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
203
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
204
202
|
done();
|
|
205
203
|
});
|
|
206
204
|
});
|
|
@@ -746,13 +744,13 @@ describe('NGSI-LD - Expression-based transformations plugin', function () {
|
|
|
746
744
|
});
|
|
747
745
|
});
|
|
748
746
|
|
|
749
|
-
describe('When an update comes for attributes without expressions and
|
|
747
|
+
describe('When an update comes for attributes without expressions and Array type', function () {
|
|
750
748
|
// Case: Update for a JSON array attribute without expression
|
|
751
749
|
|
|
752
750
|
const values = [
|
|
753
751
|
{
|
|
754
752
|
name: 'r',
|
|
755
|
-
type: '
|
|
753
|
+
type: 'Array',
|
|
756
754
|
value: ['v0.1', 'v0.2', 'v0.3']
|
|
757
755
|
}
|
|
758
756
|
];
|
|
@@ -293,13 +293,10 @@ const iotAgentConfigTS = {
|
|
|
293
293
|
|
|
294
294
|
describe('NGSI-LD: JEXL', function () {
|
|
295
295
|
beforeEach(function (done) {
|
|
296
|
-
logger.setLevel('FATAL');
|
|
296
|
+
//logger.setLevel('FATAL');
|
|
297
297
|
|
|
298
298
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
299
299
|
iotAgentLib.clearAll(function () {
|
|
300
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
301
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
302
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
303
300
|
done();
|
|
304
301
|
});
|
|
305
302
|
});
|
|
@@ -964,9 +961,6 @@ describe('NGSI-LD: JEXL - Timestamps', function () {
|
|
|
964
961
|
|
|
965
962
|
iotAgentLib.activate(iotAgentConfigTS, function () {
|
|
966
963
|
iotAgentLib.clearAll(function () {
|
|
967
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
968
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
969
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
970
964
|
done();
|
|
971
965
|
});
|
|
972
966
|
});
|
|
@@ -37,7 +37,8 @@ const iotAgentConfig = {
|
|
|
37
37
|
port: '1026'
|
|
38
38
|
},
|
|
39
39
|
server: {
|
|
40
|
-
port: 4041
|
|
40
|
+
port: 4041,
|
|
41
|
+
host: 'localhost'
|
|
41
42
|
},
|
|
42
43
|
types: {
|
|
43
44
|
Light: {
|
|
@@ -135,7 +136,7 @@ describe('NGSI-LD - Startup tests', function () {
|
|
|
135
136
|
config.getConfig().contextBroker.url.should.equal('http://cbhost:1111');
|
|
136
137
|
config.getConfig().contextBroker.ngsiVersion.should.equal('ld');
|
|
137
138
|
config.getConfig().contextBroker.jsonLdContext.should.equal('http://context.jsonld');
|
|
138
|
-
config.getConfig().contextBroker.fallbackTenant.should.equal(
|
|
139
|
+
config.getConfig().contextBroker.fallbackTenant.should.equal('openiot');
|
|
139
140
|
config.getConfig().contextBroker.fallbackPath.should.equal('smartgondor');
|
|
140
141
|
config.getConfig().server.ldSupport.null.should.equal(false);
|
|
141
142
|
config.getConfig().server.ldSupport.datasetId.should.equal(false);
|
|
@@ -44,7 +44,8 @@ const iotAgentConfig = {
|
|
|
44
44
|
jsonLdContext: 'http://context.json-ld'
|
|
45
45
|
},
|
|
46
46
|
server: {
|
|
47
|
-
port: 4041
|
|
47
|
+
port: 4041,
|
|
48
|
+
host: 'localhost'
|
|
48
49
|
},
|
|
49
50
|
types: {
|
|
50
51
|
Light: {
|
|
@@ -1224,10 +1225,7 @@ describe('NGSI-LD - Command functionalities', function () {
|
|
|
1224
1225
|
|
|
1225
1226
|
describe('When a query arrives to the IoT Agent with registered commands but no lazy attributes', function () {
|
|
1226
1227
|
const options = {
|
|
1227
|
-
url:
|
|
1228
|
-
'http://localhost:' +
|
|
1229
|
-
iotAgentConfig.server.port +
|
|
1230
|
-
'/ngsi-ld/v1/entities/urn:ngsi-ld:Robot:r2d2',
|
|
1228
|
+
url: 'http://localhost:' + iotAgentConfig.server.port + '/ngsi-ld/v1/entities/urn:ngsi-ld:Robot:r2d2',
|
|
1231
1229
|
method: 'GET',
|
|
1232
1230
|
headers: {
|
|
1233
1231
|
'fiware-service': 'smartgondor',
|
|
@@ -1246,8 +1244,8 @@ describe('NGSI-LD - Command functionalities', function () {
|
|
|
1246
1244
|
should.exist(attributes);
|
|
1247
1245
|
attributes.length.should.equal(0);
|
|
1248
1246
|
callback(null, {
|
|
1249
|
-
|
|
1250
|
-
|
|
1247
|
+
id: 'urn:ngsi-ld:Robot:r2d2',
|
|
1248
|
+
type: 'Robot'
|
|
1251
1249
|
});
|
|
1252
1250
|
});
|
|
1253
1251
|
|
|
@@ -45,7 +45,8 @@ const iotAgentConfig = {
|
|
|
45
45
|
jsonLdContext: 'http://context.json-ld'
|
|
46
46
|
},
|
|
47
47
|
server: {
|
|
48
|
-
port: 4041
|
|
48
|
+
port: 4041,
|
|
49
|
+
host: 'localhost'
|
|
49
50
|
},
|
|
50
51
|
types: {
|
|
51
52
|
Light: {
|
|
@@ -324,11 +325,12 @@ describe('NGSI-LD - IoT Agent Lazy Devices', function () {
|
|
|
324
325
|
.post('/ngsi-ld/v1/entityOperations/upsert/')
|
|
325
326
|
.reply(204);
|
|
326
327
|
|
|
327
|
-
async.series(
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
328
|
+
async.series(
|
|
329
|
+
[apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)],
|
|
330
|
+
function (error) {
|
|
331
|
+
done();
|
|
332
|
+
}
|
|
333
|
+
);
|
|
332
334
|
});
|
|
333
335
|
|
|
334
336
|
it('should not give any error', function (done) {
|
|
@@ -45,6 +45,7 @@ const iotAgentConfig = {
|
|
|
45
45
|
},
|
|
46
46
|
server: {
|
|
47
47
|
port: 4041,
|
|
48
|
+
host: 'localhost',
|
|
48
49
|
ldSupport: {
|
|
49
50
|
null: true,
|
|
50
51
|
datasetId: false,
|
|
@@ -53,8 +54,8 @@ const iotAgentConfig = {
|
|
|
53
54
|
},
|
|
54
55
|
types: {
|
|
55
56
|
Robot: {
|
|
56
|
-
internalAttributes:[],
|
|
57
|
-
commands:[
|
|
57
|
+
internalAttributes: [],
|
|
58
|
+
commands: [
|
|
58
59
|
{
|
|
59
60
|
name: 'position',
|
|
60
61
|
object_id: 'pos',
|
|
@@ -125,24 +126,21 @@ describe('NGSI-LD - Merge-Patch functionalities', function () {
|
|
|
125
126
|
|
|
126
127
|
describe('When a merge-patch PATCH arrives to the IoT Agent as Context Provider', function () {
|
|
127
128
|
const options = {
|
|
128
|
-
url:
|
|
129
|
-
'http://localhost:' +
|
|
130
|
-
iotAgentConfig.server.port +
|
|
131
|
-
'/ngsi-ld/v1/entities/urn:ngsi-ld:Robot:r2d2',
|
|
129
|
+
url: 'http://localhost:' + iotAgentConfig.server.port + '/ngsi-ld/v1/entities/urn:ngsi-ld:Robot:r2d2',
|
|
132
130
|
method: 'PATCH',
|
|
133
131
|
json: {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
}
|
|
132
|
+
position: {
|
|
133
|
+
type: 'Property',
|
|
134
|
+
value: {
|
|
135
|
+
moveTo: [12, 34],
|
|
136
|
+
observedAt: 'urn:ngsi-ld:null',
|
|
137
|
+
precision: {
|
|
138
|
+
value: 0.95,
|
|
139
|
+
unitCode: 'C62'
|
|
140
|
+
}
|
|
141
|
+
}
|
|
144
142
|
},
|
|
145
|
-
|
|
143
|
+
orientation: 'urn:ngsi-ld:null'
|
|
146
144
|
},
|
|
147
145
|
headers: {
|
|
148
146
|
'fiware-service': 'smartgondor',
|
|
@@ -188,7 +186,6 @@ describe('NGSI-LD - Merge-Patch functionalities', function () {
|
|
|
188
186
|
});
|
|
189
187
|
});
|
|
190
188
|
|
|
191
|
-
|
|
192
189
|
xdescribe('When a partial update PATCH with an NGSI-LD Null arrives to the IoT Agent as Context Provider', function () {
|
|
193
190
|
const options = {
|
|
194
191
|
url:
|
|
@@ -197,8 +194,8 @@ describe('NGSI-LD - Merge-Patch functionalities', function () {
|
|
|
197
194
|
'/ngsi-ld/v1/entities/urn:ngsi-ld:Robot:r2d2/attrs/position',
|
|
198
195
|
method: 'PATCH',
|
|
199
196
|
json: {
|
|
200
|
-
|
|
201
|
-
|
|
197
|
+
type: 'Property',
|
|
198
|
+
value: 'urn:ngsi-ld:null'
|
|
202
199
|
},
|
|
203
200
|
headers: {
|
|
204
201
|
'fiware-service': 'smartgondor',
|
|
@@ -236,10 +233,9 @@ describe('NGSI-LD - Merge-Patch functionalities', function () {
|
|
|
236
233
|
});
|
|
237
234
|
|
|
238
235
|
request(options, function (error, response, body) {
|
|
239
|
-
console.error(error)
|
|
236
|
+
console.error(error);
|
|
240
237
|
should.not.exist(error);
|
|
241
238
|
|
|
242
|
-
|
|
243
239
|
response.statusCode.should.equal(204);
|
|
244
240
|
handlerCalled.should.equal(1);
|
|
245
241
|
done();
|
|
@@ -41,7 +41,8 @@ const iotAgentConfig = {
|
|
|
41
41
|
jsonLdContext: 'http://context.json-ld'
|
|
42
42
|
},
|
|
43
43
|
server: {
|
|
44
|
-
port: 4041
|
|
44
|
+
port: 4041,
|
|
45
|
+
host: 'localhost'
|
|
45
46
|
},
|
|
46
47
|
types: {
|
|
47
48
|
Light: {
|
|
@@ -75,6 +76,18 @@ const iotAgentConfig = {
|
|
|
75
76
|
{
|
|
76
77
|
name: 'configuration',
|
|
77
78
|
type: 'Object'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'date',
|
|
82
|
+
type: 'Date'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'time',
|
|
86
|
+
type: 'Time'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'dateTime',
|
|
90
|
+
type: 'DateTime'
|
|
78
91
|
}
|
|
79
92
|
]
|
|
80
93
|
}
|
|
@@ -327,7 +340,7 @@ describe('NGSI-LD - JSON native types autocast test', function () {
|
|
|
327
340
|
describe('When the IoT Agent receives new information from a device. Observation with Time type', function () {
|
|
328
341
|
const values = [
|
|
329
342
|
{
|
|
330
|
-
name: '
|
|
343
|
+
name: 'time',
|
|
331
344
|
type: 'Time',
|
|
332
345
|
value: '2016-04-30T14:59:46.000Z'
|
|
333
346
|
}
|
|
@@ -360,7 +373,7 @@ describe('NGSI-LD - JSON native types autocast test', function () {
|
|
|
360
373
|
describe('When the IoT Agent receives new information from a device. Observation with DateTime type', function () {
|
|
361
374
|
const values = [
|
|
362
375
|
{
|
|
363
|
-
name: '
|
|
376
|
+
name: 'dateTime',
|
|
364
377
|
type: 'DateTime',
|
|
365
378
|
value: '2016-04-30Z'
|
|
366
379
|
}
|
|
@@ -393,7 +406,7 @@ describe('NGSI-LD - JSON native types autocast test', function () {
|
|
|
393
406
|
describe('When the IoT Agent receives new information from a device. Observation with Date type', function () {
|
|
394
407
|
const values = [
|
|
395
408
|
{
|
|
396
|
-
name: '
|
|
409
|
+
name: 'date',
|
|
397
410
|
type: 'Date',
|
|
398
411
|
value: '2016-04-30T14:59:46.000Z'
|
|
399
412
|
}
|
|
@@ -41,7 +41,8 @@ const iotAgentConfig = {
|
|
|
41
41
|
jsonLdContext: 'http://context.json-ld'
|
|
42
42
|
},
|
|
43
43
|
server: {
|
|
44
|
-
port: 4041
|
|
44
|
+
port: 4041,
|
|
45
|
+
host: 'localhost'
|
|
45
46
|
},
|
|
46
47
|
types: {
|
|
47
48
|
Light: {
|
|
@@ -69,44 +70,41 @@ describe('NGSI-LD - LanguageProperty test', function () {
|
|
|
69
70
|
iotAgentLib.deactivate(done);
|
|
70
71
|
});
|
|
71
72
|
|
|
72
|
-
describe(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
en: "Constantinople",
|
|
82
|
-
tr: "İstanbul"
|
|
83
|
-
}
|
|
73
|
+
describe('When the IoT Agent receives new exonym from a device name with LanguageProperty type and a JSON object', function () {
|
|
74
|
+
const values = [
|
|
75
|
+
{
|
|
76
|
+
name: 'name',
|
|
77
|
+
type: 'LanguageProperty',
|
|
78
|
+
value: {
|
|
79
|
+
el: 'Κωνσταντινούπολις',
|
|
80
|
+
en: 'Constantinople',
|
|
81
|
+
tr: 'İstanbul'
|
|
84
82
|
}
|
|
85
|
-
|
|
83
|
+
}
|
|
84
|
+
];
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
beforeEach(function (done) {
|
|
87
|
+
nock.cleanAll();
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
89
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
90
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
91
|
+
.post(
|
|
92
|
+
'/ngsi-ld/v1/entityOperations/upsert/?options=update',
|
|
93
|
+
utils.readExampleFile(
|
|
94
|
+
'./test/unit/ngsi-ld/examples/contextRequests/updateContextLanguageProperties1.json'
|
|
97
95
|
)
|
|
98
|
-
|
|
96
|
+
)
|
|
97
|
+
.reply(204);
|
|
99
98
|
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
iotAgentLib.activate(iotAgentConfig, done);
|
|
100
|
+
});
|
|
102
101
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
});
|
|
102
|
+
it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
103
|
+
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
104
|
+
should.not.exist(error);
|
|
105
|
+
contextBrokerMock.done();
|
|
106
|
+
done();
|
|
109
107
|
});
|
|
110
|
-
}
|
|
111
|
-
);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
112
110
|
});
|
|
@@ -40,7 +40,8 @@ const iotAgentConfig = {
|
|
|
40
40
|
jsonLdContext: 'http://context.json-ld'
|
|
41
41
|
},
|
|
42
42
|
server: {
|
|
43
|
-
port: 4041
|
|
43
|
+
port: 4041,
|
|
44
|
+
host: 'localhost'
|
|
44
45
|
},
|
|
45
46
|
types: {},
|
|
46
47
|
service: 'smartgondor',
|
|
@@ -48,7 +49,6 @@ const iotAgentConfig = {
|
|
|
48
49
|
providerUrl: 'http://smartgondor.com'
|
|
49
50
|
};
|
|
50
51
|
|
|
51
|
-
|
|
52
52
|
const iotAgentConfigWithLimitedSupport = {
|
|
53
53
|
contextBroker: {
|
|
54
54
|
host: '192.168.1.1',
|
|
@@ -58,10 +58,11 @@ const iotAgentConfigWithLimitedSupport = {
|
|
|
58
58
|
},
|
|
59
59
|
server: {
|
|
60
60
|
port: 4041,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
host: 'localhost',
|
|
62
|
+
ldSupport: {
|
|
63
|
+
null: false,
|
|
64
|
+
datasetId: false
|
|
65
|
+
}
|
|
65
66
|
},
|
|
66
67
|
types: {
|
|
67
68
|
Robot: {
|
|
@@ -91,7 +92,6 @@ const device = {
|
|
|
91
92
|
service: 'smartgondor'
|
|
92
93
|
};
|
|
93
94
|
|
|
94
|
-
|
|
95
95
|
describe('NGSI-LD - Unsupported Endpoints', function () {
|
|
96
96
|
beforeEach(function (done) {
|
|
97
97
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
@@ -153,7 +153,6 @@ describe('NGSI-LD - Unsupported Endpoints', function () {
|
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
-
|
|
157
156
|
it('PUT /entities/<entity-id> includes an NGSI-LD Null should return a valid NSGI-LD error message', function (done) {
|
|
158
157
|
const options = {
|
|
159
158
|
url:
|
|
@@ -162,7 +161,7 @@ describe('NGSI-LD - Unsupported Endpoints', function () {
|
|
|
162
161
|
'/ngsi-ld/v1/entities/urn:ngsi-ld:entity/attrs/att',
|
|
163
162
|
method: 'PUT',
|
|
164
163
|
json: {
|
|
165
|
-
|
|
164
|
+
value: 'urn:ngsi-ld:null'
|
|
166
165
|
},
|
|
167
166
|
headers: {
|
|
168
167
|
'fiware-service': 'smartgondor',
|
|
@@ -194,7 +193,6 @@ describe('NGSI-LD - Limiting Support', function () {
|
|
|
194
193
|
.post('/ngsi-ld/v1/entityOperations/upsert/')
|
|
195
194
|
.reply(204);
|
|
196
195
|
|
|
197
|
-
|
|
198
196
|
iotAgentLib.activate(iotAgentConfigWithLimitedSupport, function () {
|
|
199
197
|
iotAgentLib.clearAll(function () {
|
|
200
198
|
done();
|
|
@@ -217,7 +215,7 @@ describe('NGSI-LD - Limiting Support', function () {
|
|
|
217
215
|
'/ngsi-ld/v1/entities/urn:ngsi-ld:Robot:r2d2/attrs/position',
|
|
218
216
|
method: 'PATCH',
|
|
219
217
|
json: {
|
|
220
|
-
|
|
218
|
+
value: 'urn:ngsi-ld:null'
|
|
221
219
|
},
|
|
222
220
|
headers: {
|
|
223
221
|
'fiware-service': 'smartgondor',
|
|
@@ -235,9 +233,8 @@ describe('NGSI-LD - Limiting Support', function () {
|
|
|
235
233
|
done();
|
|
236
234
|
});
|
|
237
235
|
});
|
|
238
|
-
|
|
239
236
|
});
|
|
240
|
-
});
|
|
237
|
+
});
|
|
241
238
|
describe('When sending a payload including a datasetId when datasetIds are unsupported ', function () {
|
|
242
239
|
it('should return a valid NSGI-LD error message', function (done) {
|
|
243
240
|
const options = {
|
|
@@ -276,7 +273,6 @@ describe('NGSI-LD - Limiting Support', function () {
|
|
|
276
273
|
done();
|
|
277
274
|
});
|
|
278
275
|
});
|
|
279
|
-
|
|
280
276
|
});
|
|
281
|
-
});
|
|
277
|
+
});
|
|
282
278
|
});
|
|
@@ -41,7 +41,8 @@ const iotAgentConfig = {
|
|
|
41
41
|
jsonLdContext: 'http://context.json-ld'
|
|
42
42
|
},
|
|
43
43
|
server: {
|
|
44
|
-
port: 4041
|
|
44
|
+
port: 4041,
|
|
45
|
+
host: 'localhost'
|
|
45
46
|
},
|
|
46
47
|
types: {
|
|
47
48
|
Light: {
|
|
@@ -117,8 +118,6 @@ describe('NGSI-LD - Attribute alias plugin', function () {
|
|
|
117
118
|
|
|
118
119
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
119
120
|
iotAgentLib.clearAll(function () {
|
|
120
|
-
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
121
|
-
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
122
121
|
done();
|
|
123
122
|
});
|
|
124
123
|
});
|