|
24 | 24 | */ |
25 | 25 |
|
26 | 26 | const iotAgentLib = require('../../../../lib/fiware-iotagent-lib'); |
27 | | - // FIXME: #1012 |
28 | | -//const utils = require('../../../tools/utils'); |
29 | | -//const should = require('should'); |
| 27 | +const utils = require('../../../tools/utils'); |
| 28 | +const should = require('should'); |
30 | 29 | const logger = require('logops'); |
31 | | -//const nock = require('nock'); |
32 | | -//let contextBrokerMock; |
33 | | -//const iotAgentConfig = { |
34 | | -// autocast: true, |
35 | | -// contextBroker: { |
36 | | -// host: '192.168.1.1', |
37 | | -// port: '1026', |
38 | | -// ngsiVersion: 'v2' |
39 | | -// }, |
40 | | -// server: { |
41 | | -// port: 4041 |
42 | | -// }, |
43 | | -// types: { |
44 | | -// Light: { |
45 | | -// commands: [], |
46 | | -// type: 'Light', |
47 | | -// active: [ |
48 | | -// { |
49 | | -// name: 'location', |
50 | | -// type: 'geo:json' |
51 | | -// } |
52 | | -// ] |
53 | | -// } |
54 | | -// }, |
55 | | -// service: 'smartGondor', |
56 | | -// subservice: 'gardens', |
57 | | -// providerUrl: 'http://smartGondor.com' |
58 | | -//}; |
| 30 | +const nock = require('nock'); |
| 31 | +let contextBrokerMock; |
| 32 | +const iotAgentConfig = { |
| 33 | + autocast: true, |
| 34 | + autocastGeoJSON: ['Point', 'Polygon', 'LineString'], |
| 35 | + contextBroker: { |
| 36 | + host: '192.168.1.1', |
| 37 | + port: '1026', |
| 38 | + ngsiVersion: 'v2' |
| 39 | + }, |
| 40 | + server: { |
| 41 | + port: 4041 |
| 42 | + }, |
| 43 | + types: { |
| 44 | + Light: { |
| 45 | + commands: [], |
| 46 | + type: 'Light', |
| 47 | + active: [ |
| 48 | + { |
| 49 | + name: 'location', |
| 50 | + type: 'geo:json' |
| 51 | + } |
| 52 | + ] |
| 53 | + } |
| 54 | + }, |
| 55 | + service: 'smartGondor', |
| 56 | + subservice: 'gardens', |
| 57 | + providerUrl: 'http://smartGondor.com' |
| 58 | +}; |
| 59 | + |
| 60 | +// No autoCast |
| 61 | +const iotAgentConfig2 = { |
| 62 | + autocast: true, |
| 63 | + contextBroker: { |
| 64 | + host: '192.168.1.1', |
| 65 | + port: '1026', |
| 66 | + ngsiVersion: 'v2' |
| 67 | + }, |
| 68 | + server: { |
| 69 | + port: 4041 |
| 70 | + }, |
| 71 | + types: { |
| 72 | + Light: { |
| 73 | + commands: [], |
| 74 | + type: 'Light', |
| 75 | + active: [ |
| 76 | + { |
| 77 | + name: 'location', |
| 78 | + type: 'geo:json' |
| 79 | + } |
| 80 | + ] |
| 81 | + } |
| 82 | + }, |
| 83 | + service: 'smartGondor', |
| 84 | + subservice: 'gardens', |
| 85 | + providerUrl: 'http://smartGondor.com' |
| 86 | +}; |
59 | 87 |
|
60 | 88 | describe('NGSI-v2 - Geo-JSON types autocast test', function () { |
61 | 89 | beforeEach(function () { |
@@ -105,6 +133,46 @@ describe('NGSI-v2 - Geo-JSON types autocast test', function () { |
105 | 133 | } |
106 | 134 | ); |
107 | 135 |
|
| 136 | + |
| 137 | + describe( |
| 138 | + 'When the IoT Agent receives new geo-information from a device.' + |
| 139 | + 'Location with Point type and String value and Point is not autocast', |
| 140 | + function () { |
| 141 | + const values = [ |
| 142 | + { |
| 143 | + name: 'location', |
| 144 | + type: 'Point', |
| 145 | + value: '23,12.5' |
| 146 | + } |
| 147 | + ]; |
| 148 | + |
| 149 | + beforeEach(function (done) { |
| 150 | + nock.cleanAll(); |
| 151 | + |
| 152 | + contextBrokerMock = nock('http://192.168.1.1:1026') |
| 153 | + .matchHeader('fiware-service', 'smartGondor') |
| 154 | + .post( |
| 155 | + '/v2/entities/light1/attrs', |
| 156 | + utils.readExampleFile( |
| 157 | + './test/unit/ngsiv2/examples/contextRequests/updateContextGeopropertiesAsString.json' |
| 158 | + ) |
| 159 | + ) |
| 160 | + .query({ type: 'Light' }) |
| 161 | + .reply(204); |
| 162 | + |
| 163 | + iotAgentLib.activate(iotAgentConfig2, done); |
| 164 | + }); |
| 165 | + |
| 166 | + it('should not 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 | + |
108 | 176 | describe( |
109 | 177 | 'When the IoT Agent receives new geo-information from a device.' + |
110 | 178 | 'Location with geo:json type and GeoJSON object value', |
|
0 commit comments