iotagent-node-lib 3.0.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.
Files changed (89) hide show
  1. package/.github/workflows/ci.yml +1 -0
  2. package/CHANGES_NEXT_RELEASE +2 -0
  3. package/docker-compose-dev.yml +1 -1
  4. package/lib/services/ngsi/entities-NGSI-LD.js +2 -16
  5. package/lib/services/ngsi/entities-NGSI-v2.js +4 -16
  6. package/package.json +2 -2
  7. package/test/unit/general/config-multi-core-test.js +2 -1
  8. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +2 -1
  9. package/test/unit/general/deviceService-test.js +2 -1
  10. package/test/unit/general/loglevel-api_test.js +2 -1
  11. package/test/unit/general/startup-test.js +2 -1
  12. package/test/unit/general/statistics-persistence_test.js +1 -0
  13. package/test/unit/general/statistics-service_test.js +1 -0
  14. package/test/unit/lazyAndCommands/commandRegistry_test.js +1 -0
  15. package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +1 -0
  16. package/test/unit/mongodb/mongodb-connectionoptions-test.js +1 -0
  17. package/test/unit/mongodb/mongodb-group-registry-test.js +1 -0
  18. package/test/unit/mongodb/mongodb-registry-test.js +2 -1
  19. package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +2 -1
  20. package/test/unit/ngsi-ld/general/config-jsonld-contexts-test.js +2 -1
  21. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +2 -1
  22. package/test/unit/ngsi-ld/general/deviceService-test.js +2 -1
  23. package/test/unit/ngsi-ld/general/https-support-test.js +2 -1
  24. package/test/unit/ngsi-ld/general/iotam-autoregistration-test.js +2 -1
  25. package/test/unit/ngsi-ld/general/startup-test.js +3 -2
  26. package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +2 -1
  27. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +5 -7
  28. package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +8 -6
  29. package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +18 -22
  30. package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +2 -1
  31. package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +2 -1
  32. package/test/unit/ngsi-ld/ngsiService/autocast-test.js +2 -1
  33. package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +2 -1
  34. package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +32 -34
  35. package/test/unit/ngsi-ld/ngsiService/staticAttributes-test.js +2 -1
  36. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +2 -1
  37. package/test/unit/ngsi-ld/ngsiService/unsupported-endpoints-test.js +11 -15
  38. package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +2 -1
  39. package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +2 -1
  40. package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +2 -1
  41. package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +2 -1
  42. package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +2 -1
  43. package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +1 -0
  44. package/test/unit/ngsi-ld/provisioning/device-registration_test.js +2 -1
  45. package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +15 -12
  46. package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +1 -0
  47. package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +1 -0
  48. package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +1 -0
  49. package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +1 -0
  50. package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +1 -0
  51. package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +13 -7
  52. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +6 -0
  53. package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +7 -1
  54. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +7 -1
  55. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +7 -1
  56. package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +2 -1
  57. package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +4 -2
  58. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +4 -2
  59. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +2 -1
  60. package/test/unit/ngsiv2/general/deviceService-test.js +2 -1
  61. package/test/unit/ngsiv2/general/https-support-test.js +2 -1
  62. package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +2 -1
  63. package/test/unit/ngsiv2/general/startup-test.js +2 -1
  64. package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +2 -1
  65. package/test/unit/ngsiv2/lazyAndCommands/command-test.js +2 -1
  66. package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +8 -6
  67. package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +2 -1
  68. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +3 -2
  69. package/test/unit/ngsiv2/ngsiService/autocast-test.js +2 -1
  70. package/test/unit/ngsiv2/ngsiService/queryDeviceInformationInCb-test.js +2 -1
  71. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +2 -1
  72. package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +2 -1
  73. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +2 -1
  74. package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +2 -1
  75. package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +2 -1
  76. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +2 -1
  77. package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -1
  78. package/test/unit/ngsiv2/provisioning/device-group-api-test.js +1 -0
  79. package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -0
  80. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +1 -0
  81. package/test/unit/ngsiv2/provisioning/device-registration_test.js +2 -1
  82. package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +15 -12
  83. package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +1 -0
  84. package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +1 -0
  85. package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +1 -0
  86. package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +1 -0
  87. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +1 -0
  88. package/test/unit/plugins/capture-configuration-inPlugins_test.js +2 -1
  89. package/test/unit/plugins/capture-provision-inPlugins_test.js +2 -1
@@ -53,6 +53,7 @@ jobs:
53
53
  node-version:
54
54
  - 14.x
55
55
  - 16.x
56
+ - 18.x
56
57
  steps:
57
58
  - name: Git checkout
58
59
  uses: actions/checkout@v2
@@ -0,0 +1,2 @@
1
+
2
+
@@ -3,6 +3,6 @@ version: '3'
3
3
  services:
4
4
 
5
5
  mongo:
6
- image: mongo:4.2
6
+ image: mongo:4.4
7
7
  ports:
8
8
  - "27017:27017"
@@ -973,23 +973,9 @@ function sendUpdateValueNgsiLD(entityName, attributes, typeInformation, token, c
973
973
  ) {
974
974
  if (timestampValue) {
975
975
  // timeInstant is provided as measure
976
- if (Object.keys(payload[0]).length > 3) {
976
+ if (Object.keys(payload[0]).length > 1) {
977
977
  // include metadata with TimeInstant in attrs when TimeInstant is provided as measure in all entities
978
- payload[0] = NGSIv2.addTimestamp(
979
- payload[0],
980
- typeInformation.timezone,
981
- timestampValue,
982
- false // skipMetadataAtt
983
- );
984
- } else {
985
- // Do not include metadata with TimeInstant in attrs when TimeInstant is provided as measure
986
- // and no more entities
987
- payload[0] = NGSIv2.addTimestamp(
988
- payload[0],
989
- typeInformation.timezone,
990
- timestampValue,
991
- true // skipMetadataAtt
992
- );
978
+ payload[0] = NGSIv2.addTimestamp(payload[0], typeInformation.timezone, timestampValue);
993
979
  }
994
980
  } else {
995
981
  // jshint maxdepth:5
@@ -103,7 +103,7 @@ function formatGeoAttrs(attr) {
103
103
  * @param Boolean skipMetadataAtt An optional flag to indicate if timestamp should be added to each metadata attribute. Default is false
104
104
  * @return {Object} NGSIv2 payload entities with timestamp
105
105
  */
106
- function addTimestampNgsi2(payload, timezone, timestampValue, skipMetadataAtt) {
106
+ function addTimestampNgsi2(payload, timezone, timestampValue) {
107
107
  function addTimestampEntity(entity, timezone, timestampValue) {
108
108
  const timestamp = {
109
109
  type: constants.TIMESTAMP_TYPE_NGSI2
@@ -148,9 +148,7 @@ function addTimestampNgsi2(payload, timezone, timestampValue, skipMetadataAtt) {
148
148
  for (const key in entity) {
149
149
  /* eslint-disable-next-line no-prototype-builtins */
150
150
  if (entity.hasOwnProperty(key) && key !== 'id' && key !== 'type') {
151
- if (!skipMetadataAtt) {
152
- addMetadata(entity[key]);
153
- }
151
+ addMetadata(entity[key]);
154
152
  keyCount += 1;
155
153
  }
156
154
  }
@@ -885,25 +883,15 @@ function sendUpdateValueNgsi2(entityName, attributes, typeInformation, token, ca
885
883
  ) {
886
884
  if (timestampValue) {
887
885
  // timeInstant is provided as measure
888
- if (payload.entities.length > 1) {
886
+ if (payload.entities.length > 0) {
889
887
  for (let n = 0; n < payload.entities.length; n++) {
890
888
  // include metadata with TimeInstant in attrs when TimeInstant is provided as measure in all entities
891
889
  payload.entities[n] = addTimestampNgsi2(
892
890
  payload.entities[n],
893
891
  typeInformation.timezone,
894
- timestampValue,
895
- false // skipMetadataAtt
892
+ timestampValue
896
893
  );
897
894
  }
898
- } else {
899
- // Do not include metadata with TimeInstant in attrs when TimeInstant is provided as measure
900
- // and no more entities
901
- payload.entities[0] = addTimestampNgsi2(
902
- payload.entities[0],
903
- typeInformation.timezone,
904
- timestampValue,
905
- true // skipMetadataAtt
906
- );
907
895
  }
908
896
  } else {
909
897
  // jshint maxdepth:5
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.1.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",
@@ -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,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: {
@@ -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
  });
@@ -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: {
@@ -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
  service: 'smartgondor',