Skip to content

Commit

Permalink
Merge pull request #847 from telefonicaid/task/add_test_about_ngsiv2_…
Browse files Browse the repository at this point in the history
…measure_with_timeInstant

add test about ngsiv2 measure with TimeInstant
  • Loading branch information
fgalan authored Nov 29, 2024
2 parents e50e105 + b00d69d commit adceb1b
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 0 deletions.
93 changes: 93 additions & 0 deletions test/unit/ngsiv2/HTTP_receive_ngsiv2_measures-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,99 @@ describe('HTTP: NGSIv2 Measure reception ', function () {
});
});

describe('When a POST single NGSIv2 entity measure format with a TimeInstant arrives for the HTTP binding and NGSIV2 is the expected payload type', function () {
const optionsMeasure = {
url: 'http://localhost:' + config.http.port + '/iot/json/',
method: 'POST',
json: {
id: 'urn:ngsiv2:Streetlight:Streetlight-Mylightpoint-2',
type: 'Streetlight',
TimeInstant: {
type: 'DateTime',
value: '2023-11-15T15:52:32Z'
},
name: {
type: 'Text',
value: 'MyLightPoint-test1'
},
description: {
type: 'Text',
value: 'testdescription'
},
status: {
type: 'Text',
value: 'connected',
metadata: {
TimeInstant: {
type: 'DateTime',
value: '2023-11-17T11:59:22.661Z'
}
}
},
dateServiceStarted: {
type: 'DateTime',
value: '2020-06-04T09: 55: 02'
},
locationComment: {
type: 'Text',
value: 'Test1'
},
location: {
type: 'geo:json',
value: {
coordinates: [-87.88429, 41.99499],
type: 'Point'
}
},
address: {
type: 'Text',
value: {
streetAddress: 'MyStreet'
}
},
isRemotelyManaged: {
type: 'Integer',
value: 1
},
installationDate: {
type: 'DateTime',
value: '2022-04-17T02: 30: 04'
}
},
headers: {
'fiware-service': 'smartgondor',
'fiware-servicepath': '/gardens'
},
qs: {
i: 'MQTT_2',
k: '1234'
}
};
beforeEach(function () {
contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post(
'/v2/entities?options=upsert',
utils.readExampleFile('./test/unit/ngsiv2/contextRequests/ngsiv2PayloadMeasureTimeInstant.json')
)
.reply(204);
});
it('should return a 200 OK with no error', function (done) {
request(optionsMeasure, function (error, result, body) {
should.not.exist(error);
result.statusCode.should.equal(200);
done();
});
});
it('should send its value to the Context Broker', function (done) {
request(optionsMeasure, function (error, result, body) {
contextBrokerMock.done();
done();
});
});
});

describe('When a POST multiple NGSIv2 entity measure format arrives for the HTTP binding and NGSIV2 is the expected payload type', function () {
const optionsMeasure = {
url: 'http://localhost:' + config.http.port + '/iot/json/',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"id":"Second MQTT Device",
"type":"AnMQTTDevice",
"TimeInstant": {
"type": "DateTime",
"value": "2023-11-15T15:52:32Z"
},
"measure_id": {
"type": "Text",
"value": "urn:ngsiv2:Streetlight:Streetlight-Mylightpoint-2"
},
"measure_type": {
"type": "Text",
"value": "Streetlight"
},
"name": {
"type": "Text",
"value": "MyLightPoint-test1"
},
"description": {
"type": "Text",
"value": "testdescription"
},
"status": {
"type": "Text",
"value": "connected",
"metadata": {
"TimeInstant": {
"type": "DateTime",
"value": "2023-11-17T11:59:22.661Z"
}
}
},
"dateServiceStarted": {
"type": "DateTime",
"value": "2020-06-04T09: 55: 02"
},
"locationComment": {
"type": "Text",
"value": "Test1"
},
"location": {
"type": "geo:json",
"value": {
"coordinates": [
-87.88429,
41.99499
],
"type": "Point"
}
},
"address": {
"type": "Text",
"value": {
"streetAddress": "MyStreet"
}
},
"isRemotelyManaged": {
"type": "Integer",
"value": 1
},
"installationDate": {
"type": "DateTime",
"value": "2022-04-17T02: 30: 04"
}
}

0 comments on commit adceb1b

Please sign in to comment.