iotagent-node-lib 3.1.0 → 3.3.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 (163) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.yml +134 -0
  2. package/.github/ISSUE_TEMPLATE/config.yml +16 -0
  3. package/.github/ISSUE_TEMPLATE/feature_request.yml +55 -0
  4. package/.github/advanced-issue-labeler.yml +30 -0
  5. package/.github/workflows/issue-labeler.yml +43 -0
  6. package/CHANGES_NEXT_RELEASE +0 -2
  7. package/config.js +5 -5
  8. package/doc/api.md +1483 -298
  9. package/doc/deprecated.md +7 -1
  10. package/doc/development.md +120 -0
  11. package/doc/howto.md +58 -62
  12. package/doc/installationguide.md +3 -11
  13. package/doc/requirements.txt +1 -1
  14. package/docker/Mosquitto/Dockerfile +1 -1
  15. package/lib/commonConfig.js +7 -10
  16. package/lib/fiware-iotagent-lib.js +0 -10
  17. package/lib/jexlTranformsMap.js +2 -1
  18. package/lib/model/Device.js +0 -1
  19. package/lib/model/Group.js +0 -1
  20. package/lib/model/dbConn.js +1 -7
  21. package/lib/plugins/bidirectionalData.js +8 -26
  22. package/lib/plugins/expressionPlugin.js +8 -40
  23. package/lib/plugins/jexlParser.js +28 -0
  24. package/lib/services/commands/commandService.js +1 -1
  25. package/lib/services/common/iotManagerService.js +0 -1
  26. package/lib/services/devices/deviceRegistryMongoDB.js +10 -10
  27. package/lib/services/devices/deviceService.js +16 -20
  28. package/lib/services/devices/devices-NGSI-v2.js +2 -5
  29. package/lib/services/ngsi/entities-NGSI-LD.js +16 -60
  30. package/lib/services/ngsi/entities-NGSI-v2.js +179 -119
  31. package/lib/services/northBound/deviceProvisioningServer.js +17 -17
  32. package/lib/templates/createDevice.json +5 -6
  33. package/lib/templates/createDeviceLax.json +6 -8
  34. package/lib/templates/deviceGroup.json +1 -5
  35. package/lib/templates/updateDevice.json +9 -2
  36. package/lib/templates/updateDeviceLax.json +14 -5
  37. package/package.json +1 -1
  38. package/scripts/legacy_expression_tool/README.md +262 -0
  39. package/scripts/legacy_expression_tool/legacy_expression_tool.py +423 -0
  40. package/scripts/legacy_expression_tool/requirements.txt +3 -0
  41. package/test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json +5 -5
  42. package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +4 -4
  43. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +3 -13
  44. package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +0 -2
  45. package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +31 -30
  46. package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +8 -8
  47. package/test/unit/ngsi-ld/plugins/custom-plugin_test.js +152 -0
  48. package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +1 -1
  49. package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +33 -37
  50. package/test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice4.json +5 -1
  51. package/test/unit/ngsiv2/examples/contextRequests/updateContext.json +2 -0
  52. package/test/unit/ngsiv2/examples/contextRequests/updateContext1.json +3 -1
  53. package/test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json +2 -0
  54. package/test/unit/ngsiv2/examples/contextRequests/updateContext4.json +4 -1
  55. package/test/unit/ngsiv2/examples/contextRequests/updateContext5.json +12 -0
  56. package/test/unit/ngsiv2/examples/contextRequests/updateContext6.json +10 -0
  57. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json +2 -0
  58. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin2.json +3 -1
  59. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json +3 -1
  60. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin4.json +3 -1
  61. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin5.json +3 -1
  62. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin6.json +3 -1
  63. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin7.json +3 -1
  64. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +3 -1
  65. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin9.json +3 -1
  66. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast1.json +2 -0
  67. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast2.json +2 -0
  68. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast3.json +3 -1
  69. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast4.json +3 -1
  70. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast5.json +3 -1
  71. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast6.json +3 -1
  72. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast7.json +3 -1
  73. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandError.json +3 -1
  74. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandExpired.json +3 -1
  75. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandFinish.json +3 -1
  76. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json +2 -0
  77. package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus2.json +2 -0
  78. package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp1.json +3 -1
  79. package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp2.json +3 -1
  80. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +2 -0
  81. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +2 -0
  82. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +2 -0
  83. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json +3 -1
  84. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +2 -0
  85. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +2 -0
  86. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +2 -0
  87. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +2 -0
  88. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +2 -8
  89. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +2 -0
  90. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +2 -0
  91. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +2 -0
  92. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +22 -0
  93. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json +1 -0
  94. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json +2 -0
  95. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json +42 -0
  96. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +33 -0
  97. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +2 -0
  98. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +2 -0
  99. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +2 -0
  100. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +2 -0
  101. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +2 -0
  102. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionSkip.json +12 -0
  103. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityJexlExpressionPlugin1.json +1 -1
  104. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json +1 -1
  105. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json +1 -1
  106. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +1 -1
  107. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json +1 -1
  108. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json +1 -1
  109. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json +1 -1
  110. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +1 -1
  111. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +1 -1
  112. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin17.json +1 -1
  113. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json +1 -1
  114. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +37 -0
  115. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json +1 -1
  116. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +1 -1
  117. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +1 -1
  118. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +1 -1
  119. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -1
  120. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +1 -1
  121. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin9.json +1 -1
  122. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +1 -1
  123. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +1 -1
  124. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
  125. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -0
  126. package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +2 -0
  127. package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributes.json +2 -0
  128. package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +3 -1
  129. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestamp.json +3 -1
  130. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalse.json +12 -0
  131. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalseTimeInstant.json +12 -0
  132. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +2 -0
  133. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +2 -0
  134. package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampTimezone.json +3 -1
  135. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +355 -75
  136. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +18 -51
  137. package/test/unit/ngsiv2/general/https-support-test.js +1 -5
  138. package/test/unit/ngsiv2/lazyAndCommands/command-test.js +4 -10
  139. package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +9 -26
  140. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +143 -57
  141. package/test/unit/ngsiv2/ngsiService/autocast-test.js +14 -21
  142. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +3 -5
  143. package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +1 -10
  144. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +20 -30
  145. package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +6 -69
  146. package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +4 -6
  147. package/test/unit/ngsiv2/plugins/custom-plugin_test.js +150 -0
  148. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +87 -16
  149. package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -3
  150. package/test/unit/ngsiv2/provisioning/device-group-api-test.js +2 -3
  151. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +15 -55
  152. package/test/unit/ngsiv2/provisioning/device-registration_test.js +1 -7
  153. package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +2 -9
  154. package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -11
  155. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +0 -7
  156. package/test/unit/plugins/capture-provision-inPlugins_test.js +0 -6
  157. package/doc/advanced-topics.md +0 -626
  158. package/doc/expressionLanguage.md +0 -762
  159. package/lib/plugins/expressionParser.js +0 -205
  160. package/test/unit/expressions/expression-test.js +0 -197
  161. package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +0 -882
  162. package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +0 -951
  163. package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +0 -296
@@ -240,11 +240,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
240
240
  let longitudeFound = false;
241
241
 
242
242
  for (let i = 0; i < values.length; i++) {
243
- if (values[i].name === 'latitude' && values[i].type === 'string' && values[i].value === '-9.6') {
243
+ if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
244
244
  latitudeFound = true;
245
245
  }
246
246
 
247
- if (values[i].name === 'longitude' && values[i].type === 'string' && values[i].value === '12.4') {
247
+ if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
248
248
  longitudeFound = true;
249
249
  }
250
250
  }
@@ -348,11 +348,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
348
348
  let longitudeFound = false;
349
349
 
350
350
  for (let i = 0; i < values.length; i++) {
351
- if (values[i].name === 'latitude' && values[i].type === 'string' && values[i].value === '-9.6') {
351
+ if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
352
352
  latitudeFound = true;
353
353
  }
354
354
 
355
- if (values[i].name === 'longitude' && values[i].type === 'string' && values[i].value === '12.4') {
355
+ if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
356
356
  longitudeFound = true;
357
357
  }
358
358
  }
@@ -461,11 +461,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
461
461
  let longitudeFound = false;
462
462
 
463
463
  for (let i = 0; i < values.length; i++) {
464
- if (values[i].name === 'latitude' && values[i].type === 'string' && values[i].value === '-9.6') {
464
+ if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
465
465
  latitudeFound = true;
466
466
  }
467
467
 
468
- if (values[i].name === 'longitude' && values[i].type === 'string' && values[i].value === '12.4') {
468
+ if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
469
469
  longitudeFound = true;
470
470
  }
471
471
  }
@@ -603,11 +603,11 @@ describe('NGSI-LD - Bidirectional data plugin', function () {
603
603
  let longitudeFound = false;
604
604
 
605
605
  for (let i = 0; i < values.length; i++) {
606
- if (values[i].name === 'latitude' && values[i].type === 'string' && values[i].value === '-9.6') {
606
+ if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
607
607
  latitudeFound = true;
608
608
  }
609
609
 
610
- if (values[i].name === 'longitude' && values[i].type === 'string' && values[i].value === '12.4') {
610
+ if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
611
611
  longitudeFound = true;
612
612
  }
613
613
  }
@@ -0,0 +1,152 @@
1
+ /*
2
+ * Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U
3
+ *
4
+ * This file is part of fiware-iotagent-lib
5
+ *
6
+ * fiware-iotagent-lib is free software: you can redistribute it and/or
7
+ * modify it under the terms of the GNU Affero General Public License as
8
+ * published by the Free Software Foundation, either version 3 of the License,
9
+ * or (at your option) any later version.
10
+ *
11
+ * fiware-iotagent-lib is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
+ * See the GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public
17
+ * License along with fiware-iotagent-lib.
18
+ * If not, see http://www.gnu.org/licenses/.
19
+ *
20
+ * For those usages not covered by the GNU Affero General Public License
21
+ * please contact with::daniel.moranjimenez@telefonica.com
22
+ *
23
+ * Modified by: Daniel Calvo - ATOS Research & Innovation
24
+ */
25
+
26
+ const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
27
+ const should = require('should');
28
+ const logger = require('logops');
29
+ const nock = require('nock');
30
+ let contextBrokerMock;
31
+ const iotAgentConfig = {
32
+ contextBroker: {
33
+ host: '192.168.1.1',
34
+ port: '1026',
35
+ ngsiVersion: 'ld',
36
+ jsonLdContext: 'http://context.json-ld'
37
+ },
38
+ server: {
39
+ port: 4041
40
+ },
41
+ types: {
42
+ Light: {
43
+ commands: [],
44
+ type: 'Light',
45
+ lazy: [
46
+ {
47
+ name: 'temperature',
48
+ type: 'centigrades'
49
+ }
50
+ ],
51
+ active: [
52
+ {
53
+ name: 'pressure',
54
+ type: 'Hgmm'
55
+ }
56
+ ]
57
+ }
58
+ },
59
+ service: 'smartgondor',
60
+ subservice: 'gardens',
61
+ providerUrl: 'http://smartgondor.com'
62
+ };
63
+
64
+ describe('NGSI-LD - Custom plugin', function () {
65
+ let updateInvoked = false;
66
+ let queryInvoked = false;
67
+
68
+ function updatePlugin(entity, typeInformation, callback) {
69
+ updateInvoked = true;
70
+ return callback(null, entity, typeInformation);
71
+ }
72
+ function queryPlugin(entity, typeInformation, callback) {
73
+ queryInvoked = true;
74
+ return callback(null, entity, typeInformation);
75
+ }
76
+ beforeEach(function (done) {
77
+ logger.setLevel('FATAL');
78
+
79
+ iotAgentLib.activate(iotAgentConfig, function () {
80
+ iotAgentLib.clearAll(function () {
81
+ iotAgentLib.addUpdateMiddleware(updatePlugin);
82
+ iotAgentLib.addQueryMiddleware(queryPlugin);
83
+ done();
84
+ });
85
+ });
86
+ });
87
+
88
+ afterEach(function (done) {
89
+ iotAgentLib.clearAll(function () {
90
+ iotAgentLib.deactivate(done);
91
+ updateInvoked = false;
92
+ queryInvoked = false;
93
+ });
94
+ });
95
+ describe('When an update occurs', function () {
96
+ const values = [
97
+ {
98
+ name: 'state',
99
+ type: 'Boolean',
100
+ value: 'true'
101
+ },
102
+ {
103
+ name: 'dimming',
104
+ type: 'Number',
105
+ value: 23
106
+ }
107
+ ];
108
+
109
+ beforeEach(function () {
110
+ nock.cleanAll();
111
+
112
+ contextBrokerMock = nock('http://192.168.1.1:1026')
113
+ .matchHeader('fiware-service', 'smartgondor')
114
+ .matchHeader('fiware-servicepath', 'gardens')
115
+ .post('/ngsi-ld/v1/entityOperations/upsert/')
116
+ .query({ options: 'update' })
117
+ .reply(204);
118
+ });
119
+
120
+ it('should invoke the plugin', function (done) {
121
+ iotAgentLib.update('light1', 'Light', '', values, function (error) {
122
+ should.not.exist(error);
123
+ contextBrokerMock.done();
124
+ updateInvoked.should.equal(true);
125
+ done();
126
+ });
127
+ });
128
+ });
129
+ describe('When an query occurs', function () {
130
+ beforeEach(function () {
131
+ nock.cleanAll();
132
+
133
+ contextBrokerMock = nock('http://192.168.1.1:1026')
134
+ .matchHeader('fiware-service', 'smartgondor')
135
+ .matchHeader('fiware-servicepath', 'gardens')
136
+ .get('/ngsi-ld/v1/entities/urn:ngsi-ld:Light:light1')
137
+ .query({ attrs: 'state,dimming' })
138
+ .reply(200, { state: 'good', dimming: '23' });
139
+ });
140
+
141
+ it('should invoke the plugin', function (done) {
142
+ const attributes = ['state', 'dimming'];
143
+ iotAgentLib.query('light1', 'Light', '', attributes, function (error) {
144
+ should.not.exist(error);
145
+ contextBrokerMock.done();
146
+ should.not.exist(error);
147
+ queryInvoked.should.equal(true);
148
+ done();
149
+ });
150
+ });
151
+ });
152
+ });
@@ -96,7 +96,7 @@ const iotAgentConfig = {
96
96
  object_id: 'h',
97
97
  name: 'humidity',
98
98
  type: 'Percentage',
99
- entity_name: 'Station Number ${@sn * 10}'
99
+ entity_name: '"Station Number "+sn*10'
100
100
  }
101
101
  ]
102
102
  },
@@ -189,8 +189,7 @@ describe('Mixed Mode: ngsiVersion test', function () {
189
189
  nock.cleanAll();
190
190
  contextBrokerMock = nock('http://192.168.1.1:1026')
191
191
  .matchHeader('fiware-service', 'smartgondor')
192
- .patch('/v2/entities/light1/attrs')
193
- .query({ type: 'Device' })
192
+ .post('/v2/entities?options=upsert')
194
193
  .reply(204);
195
194
 
196
195
  request(optionsCreationDefault, function (error, response, body) {
@@ -211,8 +210,7 @@ describe('Mixed Mode: ngsiVersion test', function () {
211
210
  nock.cleanAll();
212
211
  contextBrokerMock = nock('http://192.168.1.1:1026')
213
212
  .matchHeader('fiware-service', 'smartgondor')
214
- .patch('/v2/entities/light1/attrs')
215
- .query({ type: 'Device' })
213
+ .post('/v2/entities?options=upsert')
216
214
  .reply(204);
217
215
 
218
216
  request(optionsCreationV2, function (error, response, body) {
@@ -248,39 +246,37 @@ describe('Mixed Mode: ngsiVersion test', function () {
248
246
  });
249
247
  });
250
248
 
251
- describe('When a new NGSI-LD device group is provisioned and overridden', function () {
252
- beforeEach(function (done) {
253
- nock.cleanAll();
249
+ // FIXME: ngisld may use also upsert when update entities in appendMode true (default behaviour)
250
+ // describe('When a new NGSI-LD device group is provisioned and overridden', function () {
251
+ // beforeEach(function (done) {
252
+ // nock.cleanAll();
254
253
 
255
- contextBrokerMock = nock('http://192.168.1.1:1026')
256
- .matchHeader('fiware-service', 'smartgondor')
257
- .matchHeader('fiware-servicepath', 'gardens')
258
- .post('/v2/entities?options=upsert')
259
- .reply(204);
254
+ // contextBrokerMock = nock('http://192.168.1.1:1026')
255
+ // .matchHeader('fiware-service', 'smartgondor')
256
+ // .matchHeader('fiware-servicepath', 'gardens')
257
+ // .post('/v2/entities?options=upsert')
258
+ // .reply(204);
260
259
 
261
- contextBrokerMock = nock('http://192.168.1.1:1026')
262
- .patch('/v2/entities/light2/attrs')
263
- .query({ type: 'Device' })
264
- .reply(204);
265
- request(optionsCreationLD, function (error, response, body) {
266
- request(deviceCreationV2, function (error, response, body) {
267
- done();
268
- });
269
- });
270
- });
271
- it('should operate using NGSI-v2', function (done) {
272
- iotAgentLib.update(
273
- 'light2',
274
- 'Device',
275
- 'v2-test',
276
- values,
277
- { ngsiVersion: 'v2', type: 'Device' },
278
- function (error) {
279
- should.not.exist(error);
280
- contextBrokerMock.done();
281
- done();
282
- }
283
- );
284
- });
285
- });
260
+ // contextBrokerMock = nock('http://192.168.1.1:1026').post('/v2/entities?options=upsert').reply(204);
261
+ // request(optionsCreationLD, function (error, response, body) {
262
+ // request(deviceCreationV2, function (error, response, body) {
263
+ // done();
264
+ // });
265
+ // });
266
+ // });
267
+ // it('should operate using NGSI-v2', function (done) {
268
+ // iotAgentLib.update(
269
+ // 'light2',
270
+ // 'Device',
271
+ // 'v2-test',
272
+ // values,
273
+ // { ngsiVersion: 'v2', type: 'Device' },
274
+ // function (error) {
275
+ // should.not.exist(error);
276
+ // contextBrokerMock.done();
277
+ // done();
278
+ // }
279
+ // );
280
+ // });
281
+ // });
286
282
  });
@@ -1,8 +1,12 @@
1
1
  {
2
- "id": "EntityNameByExp",
2
+ "id": "MicroLight1__SUFFIX",
3
3
  "type": "MicroLights",
4
4
  "attr_name": {
5
5
  "type": "string",
6
6
  "value": null
7
+ },
8
+ "suffix_st": {
9
+ "type": "Text",
10
+ "value": "SUFFIX"
7
11
  }
8
12
  }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id": "light1",
3
+ "type": "Light",
2
4
  "state":{
3
5
  "value": true,
4
6
  "type": "boolean"
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "state": {
3
5
  "type": "Boolean",
4
6
  "value": "true"
@@ -8,4 +10,4 @@
8
10
  "type": "Percentage",
9
11
  "value": "87"
10
12
  }
11
- }
13
+ }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"machine1",
3
+ "type":"SensorMachine",
2
4
  "status": {
3
5
  "value": "STARTING",
4
6
  "type": "String"
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"Light1",
3
+ "type":"SensorMachine",
2
4
  "status": {
3
5
  "type": "String",
4
6
  "value": "STARTING"
@@ -7,4 +9,5 @@
7
9
  "type": "Address",
8
10
  "value": "127.0.0.1"
9
11
  }
10
- }
12
+ }
13
+
@@ -0,0 +1,12 @@
1
+ {
2
+ "id":"humSensor",
3
+ "type":"Humidity",
4
+ "state":{
5
+ "value": true,
6
+ "type": "boolean"
7
+ },
8
+ "dimming":{
9
+ "value": 87,
10
+ "type": "number"
11
+ }
12
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "state":{
3
+ "value": true,
4
+ "type": "boolean"
5
+ },
6
+ "dimming":{
7
+ "value": 87,
8
+ "type": "number"
9
+ }
10
+ }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "temperature": {
3
5
  "type":"Number",
4
6
  "value":52,
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "luminance": {
3
5
  "type": "Number",
4
6
  "value": 9,
@@ -7,4 +9,4 @@
7
9
  "value":"CAL"
8
10
  }
9
11
  }
10
- }
12
+ }
@@ -1,6 +1,8 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "unix_timestamp": {
3
5
  "type": "Number",
4
6
  "value": 99823423
5
7
  }
6
- }
8
+ }
@@ -1,6 +1,8 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "active_power": {
3
5
  "type": "Number",
4
6
  "value": 0.45
5
7
  }
6
- }
8
+ }
@@ -1,6 +1,8 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "status": {
3
5
  "type": "Boolean",
4
6
  "value": false
5
7
  }
6
- }
8
+ }
@@ -1,6 +1,8 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "keep_alive": {
3
5
  "type": "None",
4
6
  "value": null
5
7
  }
6
- }
8
+ }
@@ -1,6 +1,8 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "tags": {
3
5
  "type": "Array",
4
6
  "value": ["iot","device"]
5
7
  }
6
- }
8
+ }
@@ -1,6 +1,8 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "configuration": {
3
5
  "type": "Object",
4
6
  "value": {"firmware": {"version": "1.1.0","hash": "cf23df2207d99a74fbe169e3eba035e633b65d94"}}
5
7
  }
6
- }
8
+ }
@@ -1,6 +1,8 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "configuration": {
3
5
  "type": "Object",
4
6
  "value": "string_value"
5
7
  }
6
- }
8
+ }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "pressure":{
3
5
  "value": 23,
4
6
  "type": "Number"
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "temperature":{
3
5
  "value": 14.4,
4
6
  "type": "Number"
@@ -1,6 +1,8 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "status": {
3
5
  "type": "Boolean",
4
6
  "value": true
5
7
  }
6
- }
8
+ }
@@ -1,6 +1,8 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "status": {
3
5
  "type": "Boolean",
4
6
  "value": false
5
7
  }
6
- }
8
+ }
@@ -1,6 +1,8 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "keep_alive": {
3
5
  "type": "None",
4
6
  "value": null
5
7
  }
6
- }
8
+ }
@@ -1,6 +1,8 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "tags": {
3
5
  "type": "Array",
4
6
  "value": ["iot","device"]
5
7
  }
6
- }
8
+ }
@@ -1,6 +1,8 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "configuration": {
3
5
  "type": "Object",
4
6
  "value": {"firmware": {"version": "1.1.0","hash": "cf23df2207d99a74fbe169e3eba035e633b65d94"}}
5
7
  }
6
- }
8
+ }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"r2d2",
3
+ "type":"Robot",
2
4
  "position_status": {
3
5
  "value": "ERROR",
4
6
  "type": "commandStatus"
@@ -7,4 +9,4 @@
7
9
  "value": "Stalled",
8
10
  "type": "commandResult"
9
11
  }
10
- }
12
+ }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"Robot:r2d2",
3
+ "type":"Robot",
2
4
  "position_status": {
3
5
  "value": "ERROR",
4
6
  "type": "commandStatus"
@@ -7,4 +9,4 @@
7
9
  "value": "EXPIRED",
8
10
  "type": "commandResult"
9
11
  }
10
- }
12
+ }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"r2d2",
3
+ "type":"Robot",
2
4
  "position_status": {
3
5
  "value": "FINISHED",
4
6
  "type": "commandStatus"
@@ -7,4 +9,4 @@
7
9
  "value": "[72, 368, 1]",
8
10
  "type": "commandResult"
9
11
  }
10
- }
12
+ }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"Robot:r2d2",
3
+ "type":"Robot",
2
4
  "position_status": {
3
5
  "type": "commandStatus",
4
6
  "value": "PENDING"
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"RobotExp:r2d4",
3
+ "type":"RobotExp",
2
4
  "positionExp_status": {
3
5
  "type": "commandStatus",
4
6
  "value": "PENDING"
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "state": {
3
5
  "type": "Boolean",
4
6
  "value": "true"
@@ -7,4 +9,4 @@
7
9
  "type": "DateTime",
8
10
  "value": "+002007-11-03T13:18:05"
9
11
  }
10
- }
12
+ }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"light1",
3
+ "type":"Light",
2
4
  "state": {
3
5
  "type": "Boolean",
4
6
  "value": true,
@@ -13,4 +15,4 @@
13
15
  "type": "DateTime",
14
16
  "value": "+002007-11-03T13:18:05"
15
17
  }
16
- }
18
+ }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "id":"ws1",
3
+ "type":"WeatherStation",
2
4
  "pressure": {
3
5
  "value": 1040,
4
6
  "type": "Number"