diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_05.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_05.robot index 36cf8532e123326b2f8030f9257af0ec1e8325d5..4cb62831ecce0722206f189b15a4350cc40bb10f 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_05.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_05.robot @@ -15,6 +15,8 @@ ${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: ${parking_id_prefix}= urn:ngsi-ld:OffStreetParking: ${vehicle_filename}= vehicle-simple-attributes.jsonld ${parking_filename}= parking-simple-attributes.jsonld +${expectation_filename_alt2}= vehicle-parking-019-02-05.alternative2.geojson +${expectation_filename_alt1}= vehicle-parking-019-02-05.alternative.geojson ${expectation_filename}= vehicle-parking-019-02-05.geojson ${vehicle_entity_type}= https://ngsi-ld-test-suite/context#Vehicle ${parking_entity_type}= https://ngsi-ld-test-suite/context#OffStreetParking @@ -32,9 +34,10 @@ ${parking_entity_type}= https://ngsi-ld-test-suite/context#OffStreetParking ... accept=${CONTENT_TYPE_GEOJSON} ... context=${ngsild_test_suite_context} Check Response Status Code 200 ${response.status_code} - Check Response Body Content - ... expectation_filename=${expectation_filename} + ${alternatives}= Create List ${expectation_filename} ${expectation_filename_alt1} ${expectation_filename_alt2} + Check Body With Alternatives ... response_body=${response.json()} + ... alternatives=${alternatives} *** Keywords *** diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot index 4c7be3f129a33f95c48131917511114be99a7278..80a94e3dc3870297a567ca96097d2d34240324fa 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot @@ -14,6 +14,8 @@ Suite Teardown Delete Entities ${building_id_prefix}= urn:ngsi-ld:Building: ${filename}= building-location-attribute.jsonld ${expectation_filename}= two-buildings-location-attribute-normalized-019-05.geojson +${expectation_filename_alt1}= two-buildings-location-attribute-normalized-019-05.alternative.geojson +${expectation_filename_alt2}= two-buildings-location-attribute-normalized-019-05.alternative2.geojson ${entity_type}= https://ngsi-ld-test-suite/context#Building @@ -30,11 +32,12 @@ ${entity_type}= https://ngsi-ld-test-suite/context#Building ... accept=${CONTENT_TYPE_GEOJSON} ... context=${ngsild_test_suite_context} + Check Response Status Code 200 ${response.status_code} - Check Response Body Content - ... expectation_filename=${expectation_filename} + ${alternatives}= Create List ${expectation_filename} ${expectation_filename_alt1} ${expectation_filename_alt2} + Check Body With Alternatives ... response_body=${response.json()} - + ... alternatives=${alternatives} *** Keywords *** Create Initial Entities diff --git a/data/entities/expectations/building-two-geometry-attribute-normalized.geojson b/data/entities/expectations/building-two-geometry-attribute-normalized.geojson index ff4d2e19bf6482dfe6a33848c528878a77c02f1b..e052e7613e08ec32f4b5268c4a087ff4aebf4bed 100644 --- a/data/entities/expectations/building-two-geometry-attribute-normalized.geojson +++ b/data/entities/expectations/building-two-geometry-attribute-normalized.geojson @@ -28,9 +28,9 @@ "type": "Point", "coordinates": [11.1111, 11.1111] } - }, - "@context": [ - "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" - ] - } + } + }, + "@context": [ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] } diff --git a/data/entities/expectations/building-two-geometry-attribute-simplified.geojson b/data/entities/expectations/building-two-geometry-attribute-simplified.geojson index 5b46b4bc2caadb4de7269ea1837244af896afa4a..95a968fa717e11096c86a405f413f5f956f858a6 100644 --- a/data/entities/expectations/building-two-geometry-attribute-simplified.geojson +++ b/data/entities/expectations/building-two-geometry-attribute-simplified.geojson @@ -16,9 +16,9 @@ "observationSpace": { "type": "Point", "coordinates": [11.1111, 11.1111] - }, - "@context": [ - "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" - ] - } + } + }, + "@context": [ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] } diff --git a/data/entities/expectations/building-two-geometry-property-on-nonexistent-operation-space.geojson b/data/entities/expectations/building-two-geometry-property-on-nonexistent-operation-space.geojson index 022a320cab24f5852e87c4d99dfdf63ec9b18a11..8465bfedfc9ef4abc00dea84d75e88fb2748fa25 100644 --- a/data/entities/expectations/building-two-geometry-property-on-nonexistent-operation-space.geojson +++ b/data/entities/expectations/building-two-geometry-property-on-nonexistent-operation-space.geojson @@ -31,7 +31,7 @@ "subCategory": { "type": "Property", "value": "tourism" - }, - "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" - } + } + }, + "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" } \ No newline at end of file diff --git a/data/entities/expectations/building-two-geometry-property-on-observation-space.geojson b/data/entities/expectations/building-two-geometry-property-on-observation-space.geojson index 17ae675c0b32e8833e403eed4edd2a49c54dcafb..5d60fb44eaf80edd0844967a4ffe1dd0c9b27bff 100644 --- a/data/entities/expectations/building-two-geometry-property-on-observation-space.geojson +++ b/data/entities/expectations/building-two-geometry-property-on-observation-space.geojson @@ -37,9 +37,9 @@ "subCategory": { "type": "Property", "value": "tourism" - }, + } + }, "@context": [ "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" - ] - } + ] } \ No newline at end of file diff --git a/data/entities/expectations/two-buildings-location-attribute-normalized-019-05.alternative.geojson b/data/entities/expectations/two-buildings-location-attribute-normalized-019-05.alternative.geojson new file mode 100644 index 0000000000000000000000000000000000000000..a2bc30a56d369a06aa2917ed4ac87c0eb72d2e2c --- /dev/null +++ b/data/entities/expectations/two-buildings-location-attribute-normalized-019-05.alternative.geojson @@ -0,0 +1,56 @@ +{ + "type": "FeatureCollection", + "features": [{ + "id": "urn:ngsi-ld:Building:019-05-01", + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + }, + "properties": { + "type": "Building", + "name": { + "type": "Property", + "value": "Eiffel Tower" + }, + "subCategory": { + "type": "Property", + "value": "tourism" + }, + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + } + } + }, + "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + }, { + "id": "urn:ngsi-ld:Building:019-05-02", + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + }, + "properties": { + "type": "Building", + "name": { + "type": "Property", + "value": "Eiffel Tower" + }, + "subCategory": { + "type": "Property", + "value": "tourism" + }, + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + } + } + }, + "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + }] +} diff --git a/data/entities/expectations/two-buildings-location-attribute-normalized-019-05.alternative2.geojson b/data/entities/expectations/two-buildings-location-attribute-normalized-019-05.alternative2.geojson new file mode 100644 index 0000000000000000000000000000000000000000..200de667689e19686b06c82f3258b5bffbfac412 --- /dev/null +++ b/data/entities/expectations/two-buildings-location-attribute-normalized-019-05.alternative2.geojson @@ -0,0 +1,57 @@ +{ + "type": "FeatureCollection", + "features": [{ + "id": "urn:ngsi-ld:Building:019-05-01", + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + }, + "properties": { + "type": "Building", + "name": { + "type": "Property", + "value": "Eiffel Tower" + }, + "subCategory": { + "type": "Property", + "value": "tourism" + }, + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + } + } + }, + "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + }, { + "id": "urn:ngsi-ld:Building:019-05-02", + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + }, + "properties": { + "type": "Building", + "name": { + "type": "Property", + "value": "Eiffel Tower" + }, + "subCategory": { + "type": "Property", + "value": "tourism" + }, + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + } + } + }, + "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + }], + "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" +} diff --git a/data/entities/expectations/two-buildings-location-attribute-normalized-019-05.geojson b/data/entities/expectations/two-buildings-location-attribute-normalized-019-05.geojson index 7b34511ff78095a171b4c3952a53cb825dee2e17..41d5b7aa76cf1cfbe7a47d9f34dc5dadb0f45d66 100644 --- a/data/entities/expectations/two-buildings-location-attribute-normalized-019-05.geojson +++ b/data/entities/expectations/two-buildings-location-attribute-normalized-019-05.geojson @@ -23,8 +23,7 @@ "type": "Point", "coordinates": [13.3986, 52.5547] } - }, - "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + } } }, { "id": "urn:ngsi-ld:Building:019-05-02", @@ -49,8 +48,8 @@ "type": "Point", "coordinates": [13.3986, 52.5547] } - }, - "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + } } - }] + }], + "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" } diff --git a/data/entities/expectations/vehicle-parking-019-02-05.alternative.geojson b/data/entities/expectations/vehicle-parking-019-02-05.alternative.geojson new file mode 100644 index 0000000000000000000000000000000000000000..d40f7dd99302876e148a826ebc14a0da28932ffa --- /dev/null +++ b/data/entities/expectations/vehicle-parking-019-02-05.alternative.geojson @@ -0,0 +1,73 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "id": "urn:ngsi-ld:Vehicle:019-02-05", + "type": "Feature", + "geometry": null, + "properties": { + "type": "Vehicle", + "brandName": { + "type": "Property", + "value": "Mercedes" + }, + "isParked": { + "type": "Relationship", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:Bob" + }, + "object": "urn:ngsi-ld:OffStreetParking:Downtown1", + "observedAt": "2017-07-29T12:00:04Z" + } + }, + "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + }, + { + "id": "urn:ngsi-ld:OffStreetParking:019-02-05", + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -8.5, + 41.2 + ] + }, + "properties": { + "type": "OffStreetParking", + "name": { + "type": "Property", + "value": "Downtown One" + }, + "availableSpotNumber": { + "type": "Property", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Camera:C1" + }, + "reliability": { + "type": "Property", + "value": 0.7 + }, + "value": 121, + "observedAt": "2017-07-29T12:05:02Z" + }, + "totalSpotNumber": { + "type": "Property", + "value": 200 + }, + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ + -8.5, + 41.2 + ] + } + } + }, + "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + } + ] +} diff --git a/data/entities/expectations/vehicle-parking-019-02-05.alternative2.geojson b/data/entities/expectations/vehicle-parking-019-02-05.alternative2.geojson new file mode 100644 index 0000000000000000000000000000000000000000..9a6b59e61f1bf311b8c8f691e0087fa3581091a7 --- /dev/null +++ b/data/entities/expectations/vehicle-parking-019-02-05.alternative2.geojson @@ -0,0 +1,74 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "id": "urn:ngsi-ld:Vehicle:019-02-05", + "type": "Feature", + "geometry": null, + "properties": { + "type": "Vehicle", + "brandName": { + "type": "Property", + "value": "Mercedes" + }, + "isParked": { + "type": "Relationship", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:Bob" + }, + "object": "urn:ngsi-ld:OffStreetParking:Downtown1", + "observedAt": "2017-07-29T12:00:04Z" + } + }, + "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + }, + { + "id": "urn:ngsi-ld:OffStreetParking:019-02-05", + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -8.5, + 41.2 + ] + }, + "properties": { + "type": "OffStreetParking", + "name": { + "type": "Property", + "value": "Downtown One" + }, + "availableSpotNumber": { + "type": "Property", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Camera:C1" + }, + "reliability": { + "type": "Property", + "value": 0.7 + }, + "value": 121, + "observedAt": "2017-07-29T12:05:02Z" + }, + "totalSpotNumber": { + "type": "Property", + "value": 200 + }, + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ + -8.5, + 41.2 + ] + } + } + }, + "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + } + ], + "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" +} diff --git a/data/entities/expectations/vehicle-parking-019-02-05.geojson b/data/entities/expectations/vehicle-parking-019-02-05.geojson index 3aa10bff30d5f20fa93bc90bba9c7d546ad411c0..5f8dc3149345292f155770b3e91958ec3251bacf 100644 --- a/data/entities/expectations/vehicle-parking-019-02-05.geojson +++ b/data/entities/expectations/vehicle-parking-019-02-05.geojson @@ -19,8 +19,7 @@ }, "object": "urn:ngsi-ld:OffStreetParking:Downtown1", "observedAt": "2017-07-29T12:00:04Z" - }, - "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + } } }, { @@ -65,9 +64,9 @@ 41.2 ] } - }, - "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + } } } - ] + ], + "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" } diff --git a/doc/analysis/checks.py b/doc/analysis/checks.py index 61c260e355dcc04fc562a75a6d014e6da3300d7c..e91aa77e86cfcc75a488b2c179832ca7c8b6bba1 100644 --- a/doc/analysis/checks.py +++ b/doc/analysis/checks.py @@ -150,6 +150,8 @@ class Checks: Checks.check_data_is_empty, 'Check Notification Containing Entity Element': Checks.check_notification_containing_entity_element, + 'Check Body With Alternatives': + Checks.check_body_with_alternatives } self.args = { @@ -435,6 +437,10 @@ class Checks: 'Check Notification Containing Entity Element': { 'params': ['filename', 'notification'], 'position': [0, 1] + }, + 'Check Body With Alternatives': { + 'params': ['response_body', 'alternatives'], + 'position': [0, 1] } } @@ -1190,6 +1196,14 @@ class Checks: else: raise Exception(f"ERROR, Expected empty data but received: '{kwargs}'") + @staticmethod + def check_body_with_alternatives(kwargs: list) -> str: + if 'response_body' in kwargs and 'alternatives' in kwargs : + response_body = kwargs['response_body'] + alternatives = kwargs['alternatives'] + return f'response body : {response_body} found in alternatives : {alternatives}' + else: + raise Exception(f"ERROR, Expected 'response_body' to be present in 'alternatives' but received: '{kwargs}'") def get_checks(self, **kwargs) -> str: @@ -1303,6 +1317,8 @@ if __name__ == "__main__": print() print(data.get_checks(checks='Check Notification Containing Entity Element')) + print() + print(data.get_checks(checks='Check Body With Alternatives')) # Check exceptions try: diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 1cb78c3fc109789d8a3d0e5852f948693feac065..9a8c6dea29e5b73ebb45686428737f0e8b1e15d5 100755 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -802,3 +802,14 @@ Check Message Contain Key Check Message Field Equal [Arguments] ${expected_field} ${field} Should Be Equal As Strings ${expected_field} ${field} + +Check Body With Alternatives + [Arguments] ${response_body} ${alternatives} + ${result}= False + FOR ${alternative} IN @{alternatives} + ${result}= Run Keyword And Return Status Check Response Body Content expectation_filename=${alternative} response_body=${response_body} + IF ${result} + BREAK + END + END + Should Be True ${result} \ No newline at end of file