iotagent-node-lib 3.4.4 → 4.0.1
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/README.md +4 -0
- package/doc/admin.md +1 -13
- package/doc/api.md +116 -18
- package/doc/devel/architecture.md +0 -12
- package/doc/index.md +1 -1
- package/doc/roadmap.md +22 -10
- package/lib/commonConfig.js +0 -11
- package/lib/errors.js +2 -2
- package/lib/model/Device.js +2 -1
- package/lib/model/Group.js +2 -1
- package/lib/model/dbConn.js +22 -11
- package/lib/plugins/expressionPlugin.js +0 -5
- package/lib/plugins/jexlParser.js +15 -31
- package/lib/services/common/genericMiddleware.js +14 -2
- package/lib/services/common/iotManagerService.js +2 -1
- package/lib/services/devices/deviceRegistryMongoDB.js +3 -1
- package/lib/services/devices/deviceService.js +16 -21
- package/lib/services/devices/devices-NGSI-LD.js +5 -98
- package/lib/services/devices/devices-NGSI-mixed.js +0 -14
- package/lib/services/devices/devices-NGSI-v2.js +3 -0
- package/lib/services/groups/groupRegistryMemory.js +0 -25
- package/lib/services/groups/groupRegistryMongoDB.js +20 -19
- package/lib/services/groups/groupService.js +3 -14
- package/lib/services/ngsi/entities-NGSI-LD.js +82 -7
- package/lib/services/ngsi/entities-NGSI-v2.js +297 -696
- package/lib/services/ngsi/ngsiUtils.js +0 -30
- package/lib/services/northBound/deviceProvisioningServer.js +6 -3
- package/lib/templates/createDevice.json +4 -0
- package/lib/templates/createDeviceLax.json +4 -0
- package/lib/templates/deviceGroup.json +4 -0
- package/lib/templates/updateDevice.json +4 -0
- package/lib/templates/updateDeviceLax.json +4 -0
- package/package.json +6 -2
- package/test/functional/README.md +378 -0
- package/test/functional/config-test.js +70 -0
- package/test/functional/functional-tests-runner.js +126 -0
- package/test/functional/functional-tests.js +241 -0
- package/test/functional/testCases.js +2944 -0
- package/test/functional/testUtils.js +251 -0
- package/test/tools/utils.js +25 -0
- package/test/unit/mongodb/mongodb-connectionoptions-test.js +35 -22
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +3 -34
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +8 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin7.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin8.json +1 -6
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +67 -87
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +7 -13
- package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +43 -43
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +19 -29
- package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +0 -1
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +35 -46
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +8 -9
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +96 -221
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +18 -27
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +8 -16
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +0 -13
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +4 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29b.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +0 -6
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34b.json +14 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +1 -11
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36b.json +13 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin37.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +1 -11
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10b.json +37 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +4 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +0 -3
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +10 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -5
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +8 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +0 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +7 -1
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +898 -28
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +0 -4
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +267 -0
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +19 -21
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +21 -24
- package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -21
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +4 -6
- package/CHANGES_NEXT_RELEASE +0 -0
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +0 -438
- package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +0 -381
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +0 -311
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +0 -325
- package/test/unit/ngsiv2/ngsiService/geoproperties-test.js +0 -427
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +0 -217
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +0 -119
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -309
|
@@ -88,7 +88,7 @@ describe('Device Group utils', function () {
|
|
|
88
88
|
});
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
-
describe('When an API Key is requested for a device in a group
|
|
91
|
+
describe('When an API Key is requested for a device in a group', function () {
|
|
92
92
|
beforeEach(function (done) {
|
|
93
93
|
async.series(
|
|
94
94
|
[
|
|
@@ -107,26 +107,6 @@ describe('Device Group utils', function () {
|
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
|
-
describe('When an API Key is requested for a device in a subservice with the SingleConfiguration mode', function () {
|
|
111
|
-
beforeEach(function (done) {
|
|
112
|
-
iotAgentConfig.singleConfigurationMode = true;
|
|
113
|
-
iotAgentLib.activate(iotAgentConfig, function () {
|
|
114
|
-
request(groupCreation, function (error, response, body) {
|
|
115
|
-
done();
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
afterEach(function () {
|
|
120
|
-
iotAgentConfig.singleConfigurationMode = false;
|
|
121
|
-
});
|
|
122
|
-
it('should return the API Key of the related subservice', function (done) {
|
|
123
|
-
iotAgentLib.getEffectiveApiKey('testservice', '/testingPath', null, function (error, apiKey) {
|
|
124
|
-
should.not.exist(error);
|
|
125
|
-
apiKey.should.equal('801230BJKL23Y9090DSFL123HJK09H324HV8732');
|
|
126
|
-
done();
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
110
|
describe('When an API Key is requested without a provisioned group but with a configured type', function () {
|
|
131
111
|
beforeEach(function (done) {
|
|
132
112
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -366,11 +366,10 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
366
366
|
done();
|
|
367
367
|
});
|
|
368
368
|
});
|
|
369
|
-
it('should store the device
|
|
369
|
+
it('should store the device without explicitAttrs', function (done) {
|
|
370
370
|
request(options, function (error, response, body) {
|
|
371
371
|
iotAgentLib.listDevices('smartgondor', '/gardens', function (error, results) {
|
|
372
|
-
should.exist(results.devices[0].explicitAttrs);
|
|
373
|
-
results.devices[0].explicitAttrs.should.equal(false);
|
|
372
|
+
should.not.exist(results.devices[0].explicitAttrs);
|
|
374
373
|
done();
|
|
375
374
|
});
|
|
376
375
|
});
|
|
@@ -430,12 +429,11 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
430
429
|
done();
|
|
431
430
|
});
|
|
432
431
|
|
|
433
|
-
it('should store the device
|
|
432
|
+
it('should store the device without explicitAttrs value', function (done) {
|
|
434
433
|
request(groupCreation, function (error, response, body) {
|
|
435
434
|
request(options, function (error, response, body) {
|
|
436
435
|
iotAgentLib.listDevices('smartgondor', '/gardens', function (error, results) {
|
|
437
|
-
should.exist(results.devices[0].explicitAttrs);
|
|
438
|
-
results.devices[0].explicitAttrs.should.equal(true);
|
|
436
|
+
should.not.exist(results.devices[0].explicitAttrs);
|
|
439
437
|
done();
|
|
440
438
|
});
|
|
441
439
|
});
|
package/CHANGES_NEXT_RELEASE
DELETED
|
File without changes
|
|
@@ -1,438 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 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::[contacto@tid.es]
|
|
22
|
-
*
|
|
23
|
-
* Modified by: Jason Fox - FIWARE Foundation
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/* eslint-disable no-unused-vars */
|
|
27
|
-
|
|
28
|
-
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
29
|
-
const utils = require('../../../tools/utils');
|
|
30
|
-
const request = utils.request;
|
|
31
|
-
const should = require('should');
|
|
32
|
-
const logger = require('logops');
|
|
33
|
-
const nock = require('nock');
|
|
34
|
-
let contextBrokerMock;
|
|
35
|
-
const iotAgentConfig = {
|
|
36
|
-
autocast: true,
|
|
37
|
-
contextBroker: {
|
|
38
|
-
host: '192.168.1.1',
|
|
39
|
-
port: '1026',
|
|
40
|
-
ngsiVersion: 'ld',
|
|
41
|
-
jsonLdContext: 'http://context.json-ld'
|
|
42
|
-
},
|
|
43
|
-
server: {
|
|
44
|
-
port: 4041,
|
|
45
|
-
host: 'localhost'
|
|
46
|
-
},
|
|
47
|
-
types: {
|
|
48
|
-
Light: {
|
|
49
|
-
commands: [],
|
|
50
|
-
type: 'Light',
|
|
51
|
-
active: [
|
|
52
|
-
{
|
|
53
|
-
name: 'pressure',
|
|
54
|
-
type: 'Number'
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'temperature',
|
|
58
|
-
type: 'Number'
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: 'id',
|
|
62
|
-
type: 'String'
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: 'status',
|
|
66
|
-
type: 'Boolean'
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: 'keep_alive',
|
|
70
|
-
type: 'None'
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: 'tags',
|
|
74
|
-
type: 'Array'
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: 'configuration',
|
|
78
|
-
type: 'Object'
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: 'date',
|
|
82
|
-
type: 'Date'
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
name: 'time',
|
|
86
|
-
type: 'Time'
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: 'dateTime',
|
|
90
|
-
type: 'DateTime'
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
service: 'smartgondor',
|
|
96
|
-
subservice: 'gardens',
|
|
97
|
-
providerUrl: 'http://smartgondor.com'
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
describe('NGSI-LD - JSON native types autocast test', function () {
|
|
101
|
-
beforeEach(function () {
|
|
102
|
-
logger.setLevel('FATAL');
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
afterEach(function (done) {
|
|
106
|
-
iotAgentLib.deactivate(done);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
describe('When the IoT Agent receives new information from a device. Observation with Number type and Integer value', function () {
|
|
110
|
-
const values = [
|
|
111
|
-
{
|
|
112
|
-
name: 'pressure',
|
|
113
|
-
type: 'Number',
|
|
114
|
-
value: '23'
|
|
115
|
-
}
|
|
116
|
-
];
|
|
117
|
-
|
|
118
|
-
beforeEach(function (done) {
|
|
119
|
-
nock.cleanAll();
|
|
120
|
-
|
|
121
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
122
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
123
|
-
.post(
|
|
124
|
-
'/ngsi-ld/v1/entityOperations/upsert/?options=update',
|
|
125
|
-
utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast1.json')
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
.reply(204);
|
|
129
|
-
|
|
130
|
-
iotAgentLib.activate(iotAgentConfig, done);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
134
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
135
|
-
should.not.exist(error);
|
|
136
|
-
contextBrokerMock.done();
|
|
137
|
-
done();
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
describe('When the IoT Agent receives new information from a device. Observation with Number type and Float value', function () {
|
|
143
|
-
const values = [
|
|
144
|
-
{
|
|
145
|
-
name: 'temperature',
|
|
146
|
-
type: 'Number',
|
|
147
|
-
value: '14.4'
|
|
148
|
-
}
|
|
149
|
-
];
|
|
150
|
-
|
|
151
|
-
beforeEach(function (done) {
|
|
152
|
-
nock.cleanAll();
|
|
153
|
-
|
|
154
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
155
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
156
|
-
.post(
|
|
157
|
-
'/ngsi-ld/v1/entityOperations/upsert/?options=update',
|
|
158
|
-
utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast2.json')
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
.reply(204);
|
|
162
|
-
|
|
163
|
-
iotAgentLib.activate(iotAgentConfig, done);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
167
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
168
|
-
should.not.exist(error);
|
|
169
|
-
contextBrokerMock.done();
|
|
170
|
-
done();
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
describe('When the IoT Agent receives new information from a device. Observation with Boolean type and True value', function () {
|
|
176
|
-
const values = [
|
|
177
|
-
{
|
|
178
|
-
name: 'status',
|
|
179
|
-
type: 'Boolean',
|
|
180
|
-
value: 'true'
|
|
181
|
-
}
|
|
182
|
-
];
|
|
183
|
-
|
|
184
|
-
beforeEach(function (done) {
|
|
185
|
-
nock.cleanAll();
|
|
186
|
-
|
|
187
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
188
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
189
|
-
.post(
|
|
190
|
-
'/ngsi-ld/v1/entityOperations/upsert/?options=update',
|
|
191
|
-
utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast3.json')
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
.reply(204);
|
|
195
|
-
|
|
196
|
-
iotAgentLib.activate(iotAgentConfig, done);
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
200
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
201
|
-
should.not.exist(error);
|
|
202
|
-
contextBrokerMock.done();
|
|
203
|
-
done();
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
describe('When the IoT Agent receives new information from a device. Observation with Boolean type and False value', function () {
|
|
209
|
-
const values = [
|
|
210
|
-
{
|
|
211
|
-
name: 'status',
|
|
212
|
-
type: 'Boolean',
|
|
213
|
-
value: 'false'
|
|
214
|
-
}
|
|
215
|
-
];
|
|
216
|
-
|
|
217
|
-
beforeEach(function (done) {
|
|
218
|
-
nock.cleanAll();
|
|
219
|
-
|
|
220
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
221
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
222
|
-
.post(
|
|
223
|
-
'/ngsi-ld/v1/entityOperations/upsert/?options=update',
|
|
224
|
-
utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast4.json')
|
|
225
|
-
)
|
|
226
|
-
|
|
227
|
-
.reply(204);
|
|
228
|
-
|
|
229
|
-
iotAgentLib.activate(iotAgentConfig, done);
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
233
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
234
|
-
should.not.exist(error);
|
|
235
|
-
contextBrokerMock.done();
|
|
236
|
-
done();
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
describe('When the IoT Agent receives new information from a device. Observation with None type', function () {
|
|
242
|
-
const values = [
|
|
243
|
-
{
|
|
244
|
-
name: 'keep_alive',
|
|
245
|
-
type: 'None',
|
|
246
|
-
value: 'null'
|
|
247
|
-
}
|
|
248
|
-
];
|
|
249
|
-
|
|
250
|
-
beforeEach(function (done) {
|
|
251
|
-
nock.cleanAll();
|
|
252
|
-
|
|
253
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
254
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
255
|
-
.post(
|
|
256
|
-
'/ngsi-ld/v1/entityOperations/upsert/?options=update',
|
|
257
|
-
utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast5.json')
|
|
258
|
-
)
|
|
259
|
-
|
|
260
|
-
.reply(204);
|
|
261
|
-
|
|
262
|
-
iotAgentLib.activate(iotAgentConfig, done);
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
266
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
267
|
-
should.not.exist(error);
|
|
268
|
-
contextBrokerMock.done();
|
|
269
|
-
done();
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
describe('When the IoT Agent receives new information from a device. Observation with Array type', function () {
|
|
275
|
-
const values = [
|
|
276
|
-
{
|
|
277
|
-
name: 'tags',
|
|
278
|
-
type: 'Array',
|
|
279
|
-
value: '["iot","device"]'
|
|
280
|
-
}
|
|
281
|
-
];
|
|
282
|
-
|
|
283
|
-
beforeEach(function (done) {
|
|
284
|
-
nock.cleanAll();
|
|
285
|
-
|
|
286
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
287
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
288
|
-
.post(
|
|
289
|
-
'/ngsi-ld/v1/entityOperations/upsert/?options=update',
|
|
290
|
-
utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast6.json')
|
|
291
|
-
)
|
|
292
|
-
|
|
293
|
-
.reply(204);
|
|
294
|
-
|
|
295
|
-
iotAgentLib.activate(iotAgentConfig, done);
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
299
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
300
|
-
should.not.exist(error);
|
|
301
|
-
contextBrokerMock.done();
|
|
302
|
-
done();
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
describe('When the IoT Agent receives new information from a device. Observation with Object type', function () {
|
|
308
|
-
const values = [
|
|
309
|
-
{
|
|
310
|
-
name: 'configuration',
|
|
311
|
-
type: 'Object',
|
|
312
|
-
value: '{"firmware": {"version": "1.1.0","hash": "cf23df2207d99a74fbe169e3eba035e633b65d94"}}'
|
|
313
|
-
}
|
|
314
|
-
];
|
|
315
|
-
|
|
316
|
-
beforeEach(function (done) {
|
|
317
|
-
nock.cleanAll();
|
|
318
|
-
|
|
319
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
320
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
321
|
-
.post(
|
|
322
|
-
'/ngsi-ld/v1/entityOperations/upsert/?options=update',
|
|
323
|
-
utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast7.json')
|
|
324
|
-
)
|
|
325
|
-
|
|
326
|
-
.reply(204);
|
|
327
|
-
|
|
328
|
-
iotAgentLib.activate(iotAgentConfig, done);
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
332
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
333
|
-
should.not.exist(error);
|
|
334
|
-
contextBrokerMock.done();
|
|
335
|
-
done();
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
describe('When the IoT Agent receives new information from a device. Observation with Time type', function () {
|
|
341
|
-
const values = [
|
|
342
|
-
{
|
|
343
|
-
name: 'time',
|
|
344
|
-
type: 'Time',
|
|
345
|
-
value: '2016-04-30T14:59:46.000Z'
|
|
346
|
-
}
|
|
347
|
-
];
|
|
348
|
-
|
|
349
|
-
beforeEach(function (done) {
|
|
350
|
-
nock.cleanAll();
|
|
351
|
-
|
|
352
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
353
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
354
|
-
.post(
|
|
355
|
-
'/ngsi-ld/v1/entityOperations/upsert/?options=update',
|
|
356
|
-
utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast8.json')
|
|
357
|
-
)
|
|
358
|
-
|
|
359
|
-
.reply(204);
|
|
360
|
-
|
|
361
|
-
iotAgentLib.activate(iotAgentConfig, done);
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
365
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
366
|
-
should.not.exist(error);
|
|
367
|
-
contextBrokerMock.done();
|
|
368
|
-
done();
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
describe('When the IoT Agent receives new information from a device. Observation with DateTime type', function () {
|
|
374
|
-
const values = [
|
|
375
|
-
{
|
|
376
|
-
name: 'dateTime',
|
|
377
|
-
type: 'DateTime',
|
|
378
|
-
value: '2016-04-30Z'
|
|
379
|
-
}
|
|
380
|
-
];
|
|
381
|
-
|
|
382
|
-
beforeEach(function (done) {
|
|
383
|
-
nock.cleanAll();
|
|
384
|
-
|
|
385
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
386
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
387
|
-
.post(
|
|
388
|
-
'/ngsi-ld/v1/entityOperations/upsert/?options=update',
|
|
389
|
-
utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast9.json')
|
|
390
|
-
)
|
|
391
|
-
|
|
392
|
-
.reply(204);
|
|
393
|
-
|
|
394
|
-
iotAgentLib.activate(iotAgentConfig, done);
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
398
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
399
|
-
should.not.exist(error);
|
|
400
|
-
contextBrokerMock.done();
|
|
401
|
-
done();
|
|
402
|
-
});
|
|
403
|
-
});
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
describe('When the IoT Agent receives new information from a device. Observation with Date type', function () {
|
|
407
|
-
const values = [
|
|
408
|
-
{
|
|
409
|
-
name: 'date',
|
|
410
|
-
type: 'Date',
|
|
411
|
-
value: '2016-04-30T14:59:46.000Z'
|
|
412
|
-
}
|
|
413
|
-
];
|
|
414
|
-
|
|
415
|
-
beforeEach(function (done) {
|
|
416
|
-
nock.cleanAll();
|
|
417
|
-
|
|
418
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
419
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
420
|
-
.post(
|
|
421
|
-
'/ngsi-ld/v1/entityOperations/upsert/?options=update',
|
|
422
|
-
utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast10.json')
|
|
423
|
-
)
|
|
424
|
-
|
|
425
|
-
.reply(204);
|
|
426
|
-
|
|
427
|
-
iotAgentLib.activate(iotAgentConfig, done);
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
it('should change the value of the corresponding attribute in the context broker', function (done) {
|
|
431
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
432
|
-
should.not.exist(error);
|
|
433
|
-
contextBrokerMock.done();
|
|
434
|
-
done();
|
|
435
|
-
});
|
|
436
|
-
});
|
|
437
|
-
});
|
|
438
|
-
});
|