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.
Files changed (122) hide show
  1. package/.github/workflows/ci.yml +1 -0
  2. package/config.js +5 -5
  3. package/doc/api.md +1540 -298
  4. package/doc/deprecated.md +3 -1
  5. package/doc/development.md +120 -0
  6. package/doc/installationguide.md +3 -6
  7. package/docker-compose-dev.yml +1 -1
  8. package/lib/commonConfig.js +7 -10
  9. package/lib/fiware-iotagent-lib.js +0 -10
  10. package/lib/jexlTranformsMap.js +2 -1
  11. package/lib/plugins/bidirectionalData.js +8 -26
  12. package/lib/plugins/expressionPlugin.js +8 -40
  13. package/lib/plugins/jexlParser.js +28 -0
  14. package/lib/services/commands/commandService.js +1 -1
  15. package/lib/services/devices/deviceService.js +2 -1
  16. package/lib/services/ngsi/entities-NGSI-LD.js +15 -73
  17. package/lib/services/ngsi/entities-NGSI-v2.js +149 -124
  18. package/lib/services/northBound/deviceProvisioningServer.js +17 -14
  19. package/lib/templates/createDevice.json +5 -2
  20. package/lib/templates/createDeviceLax.json +7 -5
  21. package/lib/templates/updateDevice.json +5 -2
  22. package/lib/templates/updateDeviceLax.json +3 -5
  23. package/package.json +2 -2
  24. package/test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json +5 -5
  25. package/test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice4.json +1 -0
  26. package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +4 -4
  27. package/test/unit/general/config-multi-core-test.js +2 -1
  28. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +2 -1
  29. package/test/unit/general/deviceService-test.js +2 -1
  30. package/test/unit/general/loglevel-api_test.js +2 -1
  31. package/test/unit/general/startup-test.js +2 -1
  32. package/test/unit/general/statistics-persistence_test.js +1 -0
  33. package/test/unit/general/statistics-service_test.js +1 -0
  34. package/test/unit/lazyAndCommands/commandRegistry_test.js +1 -0
  35. package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +1 -0
  36. package/test/unit/mongodb/mongodb-connectionoptions-test.js +1 -0
  37. package/test/unit/mongodb/mongodb-group-registry-test.js +1 -0
  38. package/test/unit/mongodb/mongodb-registry-test.js +2 -1
  39. package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +0 -2
  40. package/test/unit/ngsi-ld/general/config-jsonld-contexts-test.js +2 -1
  41. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +2 -1
  42. package/test/unit/ngsi-ld/general/deviceService-test.js +2 -1
  43. package/test/unit/ngsi-ld/general/https-support-test.js +2 -1
  44. package/test/unit/ngsi-ld/general/iotam-autoregistration-test.js +2 -1
  45. package/test/unit/ngsi-ld/general/startup-test.js +3 -2
  46. package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +2 -1
  47. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +5 -7
  48. package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +8 -6
  49. package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +18 -22
  50. package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +2 -1
  51. package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +2 -1
  52. package/test/unit/ngsi-ld/ngsiService/autocast-test.js +2 -1
  53. package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +2 -1
  54. package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +32 -34
  55. package/test/unit/ngsi-ld/ngsiService/staticAttributes-test.js +2 -1
  56. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +2 -1
  57. package/test/unit/ngsi-ld/ngsiService/unsupported-endpoints-test.js +11 -15
  58. package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +2 -1
  59. package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +10 -9
  60. package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +2 -1
  61. package/test/unit/ngsi-ld/plugins/custom-plugin_test.js +152 -0
  62. package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +3 -2
  63. package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +2 -1
  64. package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +1 -0
  65. package/test/unit/ngsi-ld/provisioning/device-registration_test.js +2 -1
  66. package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +15 -12
  67. package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +1 -0
  68. package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +1 -0
  69. package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +1 -0
  70. package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +1 -0
  71. package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +1 -0
  72. package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +13 -7
  73. package/test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice4.json +5 -1
  74. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +0 -8
  75. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +6 -0
  76. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +20 -0
  77. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json +42 -0
  78. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +32 -0
  79. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +37 -0
  80. package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +7 -1
  81. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +7 -1
  82. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +7 -1
  83. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +232 -8
  84. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +2 -1
  85. package/test/unit/ngsiv2/general/deviceService-test.js +2 -1
  86. package/test/unit/ngsiv2/general/https-support-test.js +2 -1
  87. package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +2 -1
  88. package/test/unit/ngsiv2/general/startup-test.js +2 -1
  89. package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +2 -1
  90. package/test/unit/ngsiv2/lazyAndCommands/command-test.js +2 -1
  91. package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +8 -6
  92. package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +3 -3
  93. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +3 -2
  94. package/test/unit/ngsiv2/ngsiService/autocast-test.js +2 -1
  95. package/test/unit/ngsiv2/ngsiService/queryDeviceInformationInCb-test.js +2 -1
  96. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +2 -1
  97. package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +2 -1
  98. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +2 -1
  99. package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +8 -7
  100. package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +2 -1
  101. package/test/unit/ngsiv2/plugins/custom-plugin_test.js +151 -0
  102. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +87 -13
  103. package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -1
  104. package/test/unit/ngsiv2/provisioning/device-group-api-test.js +1 -0
  105. package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -0
  106. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +12 -3
  107. package/test/unit/ngsiv2/provisioning/device-registration_test.js +2 -1
  108. package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +15 -12
  109. package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +1 -0
  110. package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +1 -0
  111. package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +1 -0
  112. package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +1 -0
  113. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +1 -0
  114. package/test/unit/plugins/capture-configuration-inPlugins_test.js +2 -1
  115. package/test/unit/plugins/capture-provision-inPlugins_test.js +2 -1
  116. package/doc/advanced-topics.md +0 -626
  117. package/doc/expressionLanguage.md +0 -762
  118. package/lib/plugins/expressionParser.js +0 -205
  119. package/test/unit/expressions/expression-test.js +0 -197
  120. package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +0 -881
  121. package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +0 -950
  122. 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": "boolean"
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
- "pattern": "^([^<>;'=]+)+$"
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.0.0",
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": ">=14"
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": "${latitude}, ${longitude}",
15
+ "expression": "latitude,longitude",
16
16
  "reverse": [
17
17
  {
18
18
  "object_id":"latitude",
19
- "type": "string",
20
- "expression": "${trim(substr(@location, indexOf(@location, \",\") + 1, length(@location)))}"
19
+ "type": "Number",
20
+ "expression": "location | split(', ')[1] | parsefloat()"
21
21
  },
22
22
  {
23
23
  "object_id":"longitude",
24
- "type": "string",
25
- "expression": "${trim(substr(@location, 0, indexOf(@location, \",\")))}"
24
+ "type": "Number",
25
+ "expression": "location | split(', ')[0] | parsefloat()"
26
26
  }
27
27
  ]
28
28
  }
@@ -3,6 +3,7 @@
3
3
  {
4
4
  "device_id": "MicroLight1",
5
5
  "protocol": "GENERIC_PROTO",
6
+ "expressionLanguage": "jexl",
6
7
  "attributes": [
7
8
  {
8
9
  "name": "attr_name",
@@ -14,13 +14,13 @@
14
14
  "reverse": [
15
15
  {
16
16
  "object_id":"latitude",
17
- "type": "string",
18
- "expression": "${trim(substr(@location, indexOf(@location, \",\") + 1, length(@location)))}"
17
+ "type": "Number",
18
+ "expression": "location | split(', ')[1] | parsefloat()"
19
19
  },
20
20
  {
21
21
  "object_id":"longitude",
22
- "type": "string",
23
- "expression": "${trim(substr(@location, 0, indexOf(@location, \",\")))}"
22
+ "type": "Number",
23
+ "expression": "location | split(', ')[0] | parsefloat()"
24
24
  }
25
25
  ]
26
26
  }
@@ -32,7 +32,8 @@ const iotAgentConfig = {
32
32
  port: '1026'
33
33
  },
34
34
  server: {
35
- port: 4041
35
+ port: 4041,
36
+ host: 'localhost'
36
37
  },
37
38
  types: {
38
39
  Light: {
@@ -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
  authentication: {
43
44
  // Next line is syntactically correct from a configuration point of
@@ -36,7 +36,8 @@ const iotAgentConfig = {
36
36
  port: '1026'
37
37
  },
38
38
  server: {
39
- port: 4041
39
+ port: 4041,
40
+ host: 'localhost'
40
41
  },
41
42
  types: {
42
43
  Light: {
@@ -34,7 +34,8 @@ const iotAgentConfig = {
34
34
  port: '1026'
35
35
  },
36
36
  server: {
37
- port: 4041
37
+ port: 4041,
38
+ host: 'localhost'
38
39
  },
39
40
  types: {
40
41
  Light: {
@@ -38,7 +38,8 @@ const iotAgentConfig = {
38
38
  port: '1026'
39
39
  },
40
40
  server: {
41
- port: 4041
41
+ port: 4041,
42
+ host: 'localhost'
42
43
  },
43
44
  types: {
44
45
  Light: {
@@ -37,6 +37,7 @@ const iotAgentConfig = {
37
37
  },
38
38
  server: {
39
39
  port: 4041,
40
+ host: 'localhost',
40
41
  baseRoot: '/'
41
42
  },
42
43
  stats: {
@@ -32,6 +32,7 @@ const iotAgentConfig = {
32
32
  },
33
33
  server: {
34
34
  port: 4041,
35
+ host: 'localhost',
35
36
  baseRoot: '/'
36
37
  },
37
38
  stats: {
@@ -35,6 +35,7 @@ const iotAgentConfig = {
35
35
  server: {
36
36
  name: 'testAgent',
37
37
  port: 4041,
38
+ host: 'localhost',
38
39
  baseRoot: '/'
39
40
  },
40
41
  types: {},
@@ -38,6 +38,7 @@ const iotAgentConfig = {
38
38
  server: {
39
39
  name: 'testAgent',
40
40
  port: 4041,
41
+ host: 'localhost',
41
42
  baseRoot: '/'
42
43
  },
43
44
  types: {},
@@ -38,6 +38,7 @@ const iotAgentConfig = {
38
38
  },
39
39
  server: {
40
40
  port: 4041,
41
+ host: 'localhost',
41
42
  baseRoot: '/'
42
43
  },
43
44
  stats: {
@@ -40,6 +40,7 @@ const iotAgentConfig = {
40
40
  server: {
41
41
  name: 'testAgent',
42
42
  port: 4041,
43
+ host: 'localhost',
43
44
  baseRoot: '/'
44
45
  },
45
46
  types: {},
@@ -38,7 +38,8 @@ const iotAgentConfig = {
38
38
  port: '1026'
39
39
  },
40
40
  server: {
41
- port: 4041
41
+ port: 4041,
42
+ host: 'localhost'
42
43
  },
43
44
  types: {
44
45
  Light: {
@@ -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
  jsonLdContext: 'http://context.json-ld'
38
38
  },
39
39
  server: {
40
- port: 4041
40
+ port: 4041,
41
+ host: 'localhost'
41
42
  },
42
43
  types: {
43
44
  Light: {
@@ -42,7 +42,8 @@ const iotAgentConfig = {
42
42
  jsonLdContext: 'http://context.json-ld'
43
43
  },
44
44
  server: {
45
- port: 4041
45
+ port: 4041,
46
+ host: 'localhost'
46
47
  },
47
48
  authentication: {
48
49
  type: 'oauth2',
@@ -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: {
@@ -42,7 +42,8 @@ const iotAgentConfig = {
42
42
  jsonLdContext: 'http://context.json-ld'
43
43
  },
44
44
  server: {
45
- port: 4041
45
+ port: 4041,
46
+ host: 'localhost'
46
47
  },
47
48
  types: {
48
49
  Light: {
@@ -39,7 +39,8 @@ const iotAgentConfig = {
39
39
  jsonLdContext: 'http://context.json-ld'
40
40
  },
41
41
  server: {
42
- port: 4041
42
+ port: 4041,
43
+ host: 'localhost'
43
44
  },
44
45
  types: {
45
46
  Light: {
@@ -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( 'openiot');
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);
@@ -43,7 +43,8 @@ const iotAgentConfig = {
43
43
  jsonLdContext: 'http://context.json-ld'
44
44
  },
45
45
  server: {
46
- port: 4041
46
+ port: 4041,
47
+ host: 'localhost'
47
48
  },
48
49
  types: {
49
50
  Light: {
@@ -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
- id: 'urn:ngsi-ld:Robot:r2d2',
1250
- type: 'Robot'
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([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], function (
328
- error
329
- ) {
330
- done();
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
- "position": {
135
- "type": "Property",
136
- "value": {
137
- "moveTo" : [12,34],
138
- "observedAt": "urn:ngsi-ld:null",
139
- "precision": {
140
- "value": 0.95,
141
- "unitCode": "C62"
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
- "orientation" : "urn:ngsi-ld:null"
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
- "type": "Property",
201
- "value": "urn:ngsi-ld:null"
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();
@@ -43,7 +43,8 @@ const iotAgentConfig = {
43
43
  jsonLdContext: 'http://context.json-ld'
44
44
  },
45
45
  server: {
46
- port: 4041
46
+ port: 4041,
47
+ host: 'localhost'
47
48
  },
48
49
  types: {
49
50
  Light: {
@@ -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: {
@@ -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: {
@@ -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: {
@@ -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
- 'When the IoT Agent receives new exonym from a device name with LanguageProperty type and a JSON object',
74
- function () {
75
- const values = [
76
- {
77
- name: 'name',
78
- type: 'LanguageProperty',
79
- value: {
80
- el: "Κωνσταντινούπολις",
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
- beforeEach(function (done) {
88
- nock.cleanAll();
86
+ beforeEach(function (done) {
87
+ nock.cleanAll();
89
88
 
90
- contextBrokerMock = nock('http://192.168.1.1:1026')
91
- .matchHeader('fiware-service', 'smartgondor')
92
- .post(
93
- '/ngsi-ld/v1/entityOperations/upsert/?options=update',
94
- utils.readExampleFile(
95
- './test/unit/ngsi-ld/examples/contextRequests/updateContextLanguageProperties1.json'
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
- .reply(204);
96
+ )
97
+ .reply(204);
99
98
 
100
- iotAgentLib.activate(iotAgentConfig, done);
101
- });
99
+ iotAgentLib.activate(iotAgentConfig, done);
100
+ });
102
101
 
103
- it('should change the value of the corresponding attribute in the context broker', function (done) {
104
- iotAgentLib.update('light1', 'Light', '', values, function (error) {
105
- should.not.exist(error);
106
- contextBrokerMock.done();
107
- done();
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
  });