diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_11.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_11.robot new file mode 100644 index 0000000000000000000000000000000000000000..b1fdaa47a9de91c716772fffde39993b515c07a3 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_11.robot @@ -0,0 +1,52 @@ +*** Settings *** +Documentation Check that you can query the temporal evolution of entities with a limit to the number of entities to be retrieved +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Suite Teardown Delete Initial Entities +Test Template Query the temporal evolution of entities with a limit to the number of entities to be retrieved + +*** Variable *** +${vehicule_id_prefix}= urn:ngsi-ld:Vehicle: +${bus_id_prefix}= urn:ngsi-ld:Bus: +${first_vehicle_payload_file}= 2020-08-vehicule-temporal-representation-sample.jsonld +${second_vehicle_payload_file}= 2020-09-vehicule-temporal-representation-sample.jsonld +${bus_payload_file}= 2020-08-bus-temporal-representation-sample.jsonld + +${expectation_file}= vehicles-temporal-representation-021-11-expectation.jsonld + +*** Test Cases *** LIMIT EXPECTATION_FILE TEMPORAL_ENTITIES_REPRESENTATION_IDS +Query Some entities ${2} vehicles-temporal-representation-021-11-01-expectation.jsonld ${first_temporal_entity_representation_id} ${second_temporal_entity_representation_id} +Query All entities ${20} vehicles-temporal-representation-021-11-02-expectation.jsonld ${first_temporal_entity_representation_id} ${second_temporal_entity_representation_id} ${third_temporal_entity_representation_id} + +*** Keywords *** +Query the temporal evolution of entities with a limit to the number of entities to be retrieved + [Arguments] ${limit} ${expectation_file} @{temporal_entities_representation_ids} + [Documentation] Check that you can query the temporal evolution of entities with a limit to the number of entities to be retrieved + [Tags] mandatory + + @{entity_types_to_be_retrieved}= Create List Vehicle Bus + + Query Temporal Representation Of Entities entity_types=${entity_types_to_be_retrieved} limit=${limit} timerel=after timeAt=2020-07-01T12:05:00Z context=${ngsild_test_suite_context} + + Check Response Status Code Set To 200 + Check Response Body Containing List Containing EntityTemporal elements ${expectation_file} ${temporal_entities_representation_ids} + +Setup Initial Entities + ${first_temporal_entity_representation_id}= Generate Random Entity Id ${vehicule_id_prefix} + ${second_temporal_entity_representation_id}= Generate Random Entity Id ${vehicule_id_prefix} + ${third_temporal_entity_representation_id}= Generate Random Entity Id ${bus_id_prefix} + + Create Temporal Representation Of Entity ${first_vehicle_payload_file} ${first_temporal_entity_representation_id} + Create Temporal Representation Of Entity ${second_vehicle_payload_file} ${second_temporal_entity_representation_id} + Create Temporal Representation Of Entity ${bus_payload_file} ${third_temporal_entity_representation_id} + Set Suite Variable ${first_temporal_entity_representation_id} + Set Suite Variable ${second_temporal_entity_representation_id} + Set Suite Variable ${third_temporal_entity_representation_id} + +Delete Initial Entities + Delete Temporal Representation Of Entity ${first_temporal_entity_representation_id} + Delete Temporal Representation Of Entity ${second_temporal_entity_representation_id} + Delete Temporal Representation Of Entity ${third_temporal_entity_representation_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_12.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_12.robot new file mode 100644 index 0000000000000000000000000000000000000000..6bfb3e01b77ab5a560e42fab3d855ce04b3571fa --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_12.robot @@ -0,0 +1,32 @@ +*** Settings *** +Documentation Check that you cannot query the temporal evolution of entities with an invalid request or invalid request content +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Suite Teardown Delete Initial Entities + +*** Variable *** +${vehicule_id_prefix}= urn:ngsi-ld:Vehicle: +${vehicle_payload_file}= 2020-08-vehicule-temporal-representation-sample.jsonld + +*** Test Case *** +Query the temporal evolution of entities with an invalid request + [Documentation] Check that you cannot query the temporal evolution of entities with an invalid request + [Tags] mandatory + + Query Temporal Representation Of Entities timerel=after timeAt=2020-07-01T12:05:00Z context=${ngsild_test_suite_context} + + Check Response Status Code Set To 400 + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_BAD_REQUEST_DATA} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} + +*** Keywords *** +Setup Initial Entities + ${temporal_entity_representation_id}= Generate Random Entity Id ${vehicule_id_prefix} + Create Temporal Representation Of Entity ${vehicle_payload_file} ${temporal_entity_representation_id} + Set Suite Variable ${temporal_entity_representation_id} + +Delete Initial Entities + Delete Temporal Representation Of Entity ${temporal_entity_representation_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_13.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_13.robot new file mode 100644 index 0000000000000000000000000000000000000000..fddc62ad516e35394fafa46698dbc86abafd1c74 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_13.robot @@ -0,0 +1,43 @@ +*** Settings *** +Documentation Check that you can query the temporal evolution of entities using the entityOperations method +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Suite Teardown Delete Initial Entities +Test Template Query the temporal evolution of entities using the entityOperations method + +*** Variable *** +${vehicule_id_prefix}= urn:ngsi-ld:Vehicle: +${first_vehicle_payload_file}= 2020-08-vehicule-temporal-representation-sample.jsonld +${second_vehicle_payload_file}= 2020-09-vehicule-temporal-representation-sample.jsonld + +*** Test Cases *** PAYLOAD_FILE EXPECTATION_FILE +After entity-operations-after-query.jsonld vehicles-temporal-representation-021-13-01-expectation.jsonld +Before entity-operations-before-query.jsonld vehicles-temporal-representation-021-13-02-expectation.jsonld + +*** Keywords *** +Query the temporal evolution of entities using the entityOperations method + [Arguments] ${payload_file} ${expectation_file} + [Documentation] Check that you can query the temporal evolution of entities using the entityOperations method + [Tags] mandatory + + Query Temporal Representation Of Entities Via Post ${payload_file} + + @{temporal_entities_representation_ids}= Create List ${first_temporal_entity_representation_id} ${second_temporal_entity_representation_id} + + Check Response Status Code Set To 200 + Check Response Body Containing List Containing EntityTemporal elements ${expectation_file} ${temporal_entities_representation_ids} + +Setup Initial Entities + ${first_temporal_entity_representation_id}= Generate Random Entity Id ${vehicule_id_prefix} + ${second_temporal_entity_representation_id}= Generate Random Entity Id ${vehicule_id_prefix} + Create Temporal Representation Of Entity ${first_vehicle_payload_file} ${first_temporal_entity_representation_id} + Create Temporal Representation Of Entity ${second_vehicle_payload_file} ${second_temporal_entity_representation_id} + Set Suite Variable ${first_temporal_entity_representation_id} + Set Suite Variable ${second_temporal_entity_representation_id} + +Delete Initial Entities + Delete Temporal Representation Of Entity ${first_temporal_entity_representation_id} + Delete Temporal Representation Of Entity ${second_temporal_entity_representation_id} diff --git a/data/temporalEntities/entity-operations-after-query.jsonld b/data/temporalEntities/entity-operations-after-query.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..494f7062f43509e37553f39bb24c9b9bc7775c83 --- /dev/null +++ b/data/temporalEntities/entity-operations-after-query.jsonld @@ -0,0 +1,9 @@ +{ + "type":"Vehicle", + "timerel":"after", + "timeAt":"2020-08-02T12:05:00Z", + "@context":[ + "https://raw.githubusercontent.com/easy-global-market/ngsild-api-data-models/feature/add-json-ld-context-for-ngsi-ld-test-suite/ngsi-ld-test-suite/ngsi-ld-test-suite-context.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/temporalEntities/entity-operations-before-query.jsonld b/data/temporalEntities/entity-operations-before-query.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..9a5ab48fa2d42d72fc4f568d2ecbaca9bdb33cb4 --- /dev/null +++ b/data/temporalEntities/entity-operations-before-query.jsonld @@ -0,0 +1,9 @@ +{ + "type":"Vehicle", + "timerel":"before", + "timeAt":"2020-08-02T12:05:00Z", + "@context":[ + "https://raw.githubusercontent.com/easy-global-market/ngsild-api-data-models/feature/add-json-ld-context-for-ngsi-ld-test-suite/ngsi-ld-test-suite/ngsi-ld-test-suite-context.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/temporalEntities/expectations/vehicles-temporal-representation-021-11-01-expectation.jsonld b/data/temporalEntities/expectations/vehicles-temporal-representation-021-11-01-expectation.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..fdbbaea536c2f5fce7f6bf3cef002bfc145a1ef9 --- /dev/null +++ b/data/temporalEntities/expectations/vehicles-temporal-representation-021-11-01-expectation.jsonld @@ -0,0 +1,86 @@ +[ + { + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "brandName":{ + "type":"Property", + "value":"Volvo" + }, + "fuelLevel":[ + { + "type":"Property", + "value":67, + "observedAt":"2020-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":53, + "observedAt":"2020-08-01T13:05:00Z" + }, + { + "type":"Property", + "value":40, + "observedAt":"2020-08-01T14:07:00Z" + } + ], + "speed":[ + { + "type":"Property", + "value":120, + "observedAt":"2020-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":80, + "observedAt":"2020-08-01T12:05:00Z" + }, + { + "type":"Property", + "value":100, + "observedAt":"2020-08-01T12:07:00Z" + } + ] + }, + { + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "brandName":{ + "type":"Property", + "value":"BMW" + }, + "fuelLevel":[ + { + "type":"Property", + "value":53, + "observedAt":"2020-09-01T13:05:00Z" + }, + { + "type":"Property", + "value":67, + "observedAt":"2020-09-01T12:03:00Z" + }, + { + "type":"Property", + "value":40, + "observedAt":"2020-09-01T14:07:00Z" + } + ], + "speed":[ + { + "type":"Property", + "value":120, + "observedAt":"2020-09-01T12:03:00Z" + }, + { + "type":"Property", + "value":80, + "observedAt":"2020-09-01T12:05:00Z" + }, + { + "type":"Property", + "value":100, + "observedAt":"2020-09-01T12:07:00Z" + } + ] + } +] \ No newline at end of file diff --git a/data/temporalEntities/expectations/vehicles-temporal-representation-021-11-02-expectation.jsonld b/data/temporalEntities/expectations/vehicles-temporal-representation-021-11-02-expectation.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..5396ce0db956d0b06ef9452d639445e4dd6979d4 --- /dev/null +++ b/data/temporalEntities/expectations/vehicles-temporal-representation-021-11-02-expectation.jsonld @@ -0,0 +1,128 @@ +[ + { + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "brandName":{ + "type":"Property", + "value":"Volvo" + }, + "fuelLevel":[ + { + "type":"Property", + "value":67, + "observedAt":"2020-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":53, + "observedAt":"2020-08-01T13:05:00Z" + }, + { + "type":"Property", + "value":40, + "observedAt":"2020-08-01T14:07:00Z" + } + ], + "speed":[ + { + "type":"Property", + "value":120, + "observedAt":"2020-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":80, + "observedAt":"2020-08-01T12:05:00Z" + }, + { + "type":"Property", + "value":100, + "observedAt":"2020-08-01T12:07:00Z" + } + ] + }, + { + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "brandName":{ + "type":"Property", + "value":"BMW" + }, + "fuelLevel":[ + { + "type":"Property", + "value":53, + "observedAt":"2020-09-01T13:05:00Z" + }, + { + "type":"Property", + "value":67, + "observedAt":"2020-09-01T12:03:00Z" + }, + { + "type":"Property", + "value":40, + "observedAt":"2020-09-01T14:07:00Z" + } + ], + "speed":[ + { + "type":"Property", + "value":120, + "observedAt":"2020-09-01T12:03:00Z" + }, + { + "type":"Property", + "value":80, + "observedAt":"2020-09-01T12:05:00Z" + }, + { + "type":"Property", + "value":100, + "observedAt":"2020-09-01T12:07:00Z" + } + ] + }, + { + "id":"urn:ngsi-ld:Bus:randomUUID", + "type":"Bus", + "brandName":{ + "type":"Property", + "value":"Mercedes" + }, + "fuelLevel":[ + { + "type":"Property", + "value":210, + "observedAt":"2020-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":145, + "observedAt":"2020-08-01T13:05:00Z" + }, + { + "type":"Property", + "value":124, + "observedAt":"2020-08-01T14:07:00Z" + } + ], + "speed":[ + { + "type":"Property", + "value":45, + "observedAt":"2020-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":25, + "observedAt":"2020-08-01T12:05:00Z" + }, + { + "type":"Property", + "value":67, + "observedAt":"2020-08-01T12:07:00Z" + } + ] + } +] \ No newline at end of file diff --git a/data/temporalEntities/expectations/vehicles-temporal-representation-021-13-01-expectation.jsonld b/data/temporalEntities/expectations/vehicles-temporal-representation-021-13-01-expectation.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..4adef51e0ab41f1dafb76356dae47d84757f8ce1 --- /dev/null +++ b/data/temporalEntities/expectations/vehicles-temporal-representation-021-13-01-expectation.jsonld @@ -0,0 +1,52 @@ +[ + { + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "brandName":{ + "type":"Property", + "value":"Volvo" + } + }, + { + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "brandName":{ + "type":"Property", + "value":"BMW" + }, + "fuelLevel":[ + { + "type":"Property", + "value":53, + "observedAt":"2020-09-01T13:05:00Z" + }, + { + "type":"Property", + "value":67, + "observedAt":"2020-09-01T12:03:00Z" + }, + { + "type":"Property", + "value":40, + "observedAt":"2020-09-01T14:07:00Z" + } + ], + "speed":[ + { + "type":"Property", + "value":120, + "observedAt":"2020-09-01T12:03:00Z" + }, + { + "type":"Property", + "value":80, + "observedAt":"2020-09-01T12:05:00Z" + }, + { + "type":"Property", + "value":100, + "observedAt":"2020-09-01T12:07:00Z" + } + ] + } +] \ No newline at end of file diff --git a/data/temporalEntities/expectations/vehicles-temporal-representation-021-13-02-expectation.jsonld b/data/temporalEntities/expectations/vehicles-temporal-representation-021-13-02-expectation.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..7fbe7c4300a861de787d17b0c5ff9a5520c97cff --- /dev/null +++ b/data/temporalEntities/expectations/vehicles-temporal-representation-021-13-02-expectation.jsonld @@ -0,0 +1,52 @@ +[ + { + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "brandName":{ + "type":"Property", + "value":"Volvo" + }, + "fuelLevel":[ + { + "type":"Property", + "value":67, + "observedAt":"2020-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":53, + "observedAt":"2020-08-01T13:05:00Z" + }, + { + "type":"Property", + "value":40, + "observedAt":"2020-08-01T14:07:00Z" + } + ], + "speed":[ + { + "type":"Property", + "value":120, + "observedAt":"2020-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":80, + "observedAt":"2020-08-01T12:05:00Z" + }, + { + "type":"Property", + "value":100, + "observedAt":"2020-08-01T12:07:00Z" + } + ] + }, + { + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "brandName":{ + "type":"Property", + "value":"BMW" + } + } +] \ No newline at end of file diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 28d925192000fa658b4a719de3f9b4e2d3617dc9..50407fe7ff822f4865c9eb058b08265b8feee8f6 100644 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -14,6 +14,7 @@ ${BATCH_DELETE_ENDPOINT_PATH} entityOperations/delete &{BATCH_OPERATION_ENDPOINT_MAPPING} create=${BATCH_CREATE_ENDPOINT_PATH} upsert=${BATCH_UPSERT_ENDPOINT_PATH} update=${BATCH_UPDATE_ENDPOINT_PATH} delete=${BATCH_DELETE_ENDPOINT_PATH} ${ENTITIES_ENDPOINT_PATH} entities ${TEMPORAL_ENTITIES_ENDPOINT_PATH} temporal/entities +${TEMPORAL_ENTITY_OPERATIONS_ENDPOINT_PATH} temporal/entityOperations ${CONTENT_TYPE_JSON} application/json ${CONTENT_TYPE_LD_JSON} application/ld+json @@ -149,7 +150,7 @@ Retrieve Temporal Representation Of Entity Set Test Variable ${response} Query Temporal Representation Of Entities - [Arguments] ${context}=${EMPTY} ${entity_types}=${EMPTY} ${entity_ids}=${EMPTY} ${entity_id_pattern}=${EMPTY} ${ngsild_query}=${EMPTY} ${georel}=${EMPTY} ${geometry}=${EMPTY} ${coordinates}=${EMPTY} ${geoproperty}=${EMPTY} ${timerel}=${EMPTY} ${timeAt}=${EMPTY} ${attrs}=${EMPTY} ${lastN}=${EMPTY} + [Arguments] ${context}=${EMPTY} ${entity_types}=${EMPTY} ${entity_ids}=${EMPTY} ${entity_id_pattern}=${EMPTY} ${ngsild_query}=${EMPTY} ${georel}=${EMPTY} ${geometry}=${EMPTY} ${coordinates}=${EMPTY} ${geoproperty}=${EMPTY} ${timerel}=${EMPTY} ${timeAt}=${EMPTY} ${attrs}=${EMPTY} ${limit}=${EMPTY} ${lastN}=${EMPTY} ${entity_types_length} = Get Length ${entity_types} ${entity_ids_length} = Get Length ${entity_ids} ${attrs_length} = Get Length ${attrs} @@ -168,12 +169,23 @@ Query Temporal Representation Of Entities Run Keyword If '${geometry}'!='' Set To Dictionary ${params} geometry=${geometry} Run Keyword If '${coordinates}'!='' Set To Dictionary ${params} coordinates=${coordinates} Run Keyword If '${geoproperty}'!='' Set To Dictionary ${params} geoproperty=${geoproperty} + Run Keyword If '${limit}'!='' Set To Dictionary ${params} limit=${limit} ${response}= GET ${TEMPORAL_ENTITIES_ENDPOINT_PATH} headers=${headers} query=${params} Output request Output response Set Test Variable ${response} +Query Temporal Representation Of Entities Via Post + [Arguments] ${query_file_name} + ${headers}= Create Dictionary + Set To Dictionary ${headers} Content-Type ${CONTENT_TYPE_LD_JSON} + ${query_payload}= Load Json From File ${EXECDIR}/data/temporalEntities/${query_file_name} + ${response}= POST ${TEMPORAL_ENTITY_OPERATIONS_ENDPOINT_PATH}/query body=${query_payload} headers=${headers} + Output request + Output response + Set Test Variable ${response} + Delete Temporal Representation Of Entity [Arguments] ${temporal_entity_representation_id}