iotagent-node-lib 3.0.0 → 3.2.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/config.js +5 -5
- package/doc/api.md +1540 -298
- package/doc/deprecated.md +3 -1
- package/doc/development.md +120 -0
- package/doc/installationguide.md +3 -6
- package/docker-compose-dev.yml +1 -1
- package/lib/commonConfig.js +7 -10
- package/lib/fiware-iotagent-lib.js +0 -10
- package/lib/jexlTranformsMap.js +2 -1
- 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/devices/deviceService.js +2 -1
- package/lib/services/ngsi/entities-NGSI-LD.js +15 -73
- package/lib/services/ngsi/entities-NGSI-v2.js +149 -124
- package/lib/services/northBound/deviceProvisioningServer.js +17 -14
- package/lib/templates/createDevice.json +5 -2
- package/lib/templates/createDeviceLax.json +7 -5
- package/lib/templates/updateDevice.json +5 -2
- package/lib/templates/updateDeviceLax.json +3 -5
- package/package.json +2 -2
- package/test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json +5 -5
- package/test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice4.json +1 -0
- package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +4 -4
- 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 -1
- 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/expressions/jexlBasedTransformations-test.js +0 -2
- 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 +2 -1
- 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 -1
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +10 -9
- package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +2 -1
- package/test/unit/ngsi-ld/plugins/custom-plugin_test.js +152 -0
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +3 -2
- package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +2 -1
- 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/createMinimumProvisionedDevice4.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +0 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +20 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json +42 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +32 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +37 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +7 -1
- 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/jexlBasedTransformations-test.js +232 -8
- 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 +3 -3
- 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 -1
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +8 -7
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +2 -1
- package/test/unit/ngsiv2/plugins/custom-plugin_test.js +151 -0
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +87 -13
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -1
- 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 +12 -3
- 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/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 -881
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +0 -950
- package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +0 -294
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"expressionLanguage": {
|
|
40
40
|
"description": "Expression language used to apply expressions for this device",
|
|
41
|
-
"type": "
|
|
41
|
+
"type": "string"
|
|
42
42
|
},
|
|
43
43
|
"explicitAttrs": {
|
|
44
44
|
"description": "Flag about only provisioned attributes will be processed to Context Broker"
|
|
@@ -98,13 +98,15 @@
|
|
|
98
98
|
},
|
|
99
99
|
"expression": {
|
|
100
100
|
"description": "Optional expression for measurement transformation",
|
|
101
|
-
"type": "string"
|
|
102
|
-
|
|
101
|
+
"type": "string"
|
|
102
|
+
},
|
|
103
|
+
"skipValue": {
|
|
104
|
+
"description": "Attribute is skipped when result of apply expression is this value",
|
|
105
|
+
"type": "any"
|
|
103
106
|
},
|
|
104
107
|
"entity_name": {
|
|
105
108
|
"description": "Optional entity name for multientity updates",
|
|
106
|
-
"type": "string"
|
|
107
|
-
"pattern": "^([^<>;'=\"]+)+$"
|
|
109
|
+
"type": "string"
|
|
108
110
|
},
|
|
109
111
|
"entity_type": {
|
|
110
112
|
"description": "Optional entity type for multientity updatess",
|
|
@@ -88,10 +88,13 @@
|
|
|
88
88
|
"description": "Optional expression for measurement transformation",
|
|
89
89
|
"type": "string"
|
|
90
90
|
},
|
|
91
|
+
"skipValue": {
|
|
92
|
+
"description": "Attribute is skipped when result of apply expression is this value",
|
|
93
|
+
"type": "any"
|
|
94
|
+
},
|
|
91
95
|
"entity_name": {
|
|
92
96
|
"description": "Optional entity name for multientity updates",
|
|
93
|
-
"type": "string"
|
|
94
|
-
"pattern": "^([^<>;'=\"]+)+$"
|
|
97
|
+
"type": "string"
|
|
95
98
|
},
|
|
96
99
|
"entity_type": {
|
|
97
100
|
"description": "Optional entity type for multientity updatess",
|
|
@@ -79,13 +79,11 @@
|
|
|
79
79
|
},
|
|
80
80
|
"expression": {
|
|
81
81
|
"description": "Optional expression for measurement transformation",
|
|
82
|
-
"type": "string"
|
|
83
|
-
"pattern": "^([^<>;'=]+)+$"
|
|
82
|
+
"type": "string"
|
|
84
83
|
},
|
|
85
84
|
"entity_name": {
|
|
86
85
|
"description": "Optional entity name for multientity updates",
|
|
87
|
-
"type": "string"
|
|
88
|
-
"pattern": "^([^<>;'=\"]+)+$"
|
|
86
|
+
"type": "string"
|
|
89
87
|
},
|
|
90
88
|
"entity_type": {
|
|
91
89
|
"description": "Optional entity type for multientity updatess",
|
|
@@ -158,4 +156,4 @@
|
|
|
158
156
|
"type": "array"
|
|
159
157
|
}
|
|
160
158
|
}
|
|
161
|
-
}
|
|
159
|
+
}
|
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": "3.
|
|
5
|
+
"version": "3.2.0",
|
|
6
6
|
"homepage": "https://github.com/telefonicaid/iotagent-node-lib",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"fiware",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"main": "lib/fiware-iotagent-lib",
|
|
25
25
|
"engines": {
|
|
26
|
-
"node": ">=
|
|
26
|
+
"node": ">=16"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"clean": "rm -rf package-lock.json && rm -rf node_modules && rm -rf coverage",
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
{
|
|
13
13
|
"name":"location",
|
|
14
14
|
"type":"geo:point",
|
|
15
|
-
"expression": "
|
|
15
|
+
"expression": "latitude,longitude",
|
|
16
16
|
"reverse": [
|
|
17
17
|
{
|
|
18
18
|
"object_id":"latitude",
|
|
19
|
-
"type": "
|
|
20
|
-
"expression": "
|
|
19
|
+
"type": "Number",
|
|
20
|
+
"expression": "location | split(', ')[1] | parsefloat()"
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
"object_id":"longitude",
|
|
24
|
-
"type": "
|
|
25
|
-
"expression": "
|
|
24
|
+
"type": "Number",
|
|
25
|
+
"expression": "location | split(', ')[0] | parsefloat()"
|
|
26
26
|
}
|
|
27
27
|
]
|
|
28
28
|
}
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"reverse": [
|
|
15
15
|
{
|
|
16
16
|
"object_id":"latitude",
|
|
17
|
-
"type": "
|
|
18
|
-
"expression": "
|
|
17
|
+
"type": "Number",
|
|
18
|
+
"expression": "location | split(', ')[1] | parsefloat()"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"object_id":"longitude",
|
|
22
|
-
"type": "
|
|
23
|
-
"expression": "
|
|
22
|
+
"type": "Number",
|
|
23
|
+
"expression": "location | split(', ')[0] | parsefloat()"
|
|
24
24
|
}
|
|
25
25
|
]
|
|
26
26
|
}
|
|
@@ -40,7 +40,6 @@ const iotAgentConfig = {
|
|
|
40
40
|
ngsiVersion: 'ld',
|
|
41
41
|
jsonLdContext: 'http://context.json-ld'
|
|
42
42
|
},
|
|
43
|
-
defaultExpressionLanguage: 'jexl',
|
|
44
43
|
server: {
|
|
45
44
|
port: 4041
|
|
46
45
|
},
|
|
@@ -266,7 +265,6 @@ const iotAgentConfigTS = {
|
|
|
266
265
|
ngsiVersion: 'ld',
|
|
267
266
|
jsonLdContext: 'http://context.json-ld'
|
|
268
267
|
},
|
|
269
|
-
defaultExpressionLanguage: 'jexl',
|
|
270
268
|
server: {
|
|
271
269
|
port: 4041
|
|
272
270
|
},
|
|
@@ -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: {
|
|
@@ -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
|
});
|