diff --git a/TP/NGSI-LD/CommonBehaviours/043.robot b/TP/NGSI-LD/CommonBehaviours/043.robot new file mode 100644 index 0000000000000000000000000000000000000000..b372613b69742e39395a73a38908410d6cfdf9e7 --- /dev/null +++ b/TP/NGSI-LD/CommonBehaviours/043.robot @@ -0,0 +1,84 @@ +*** Settings *** +Documentation Verify throwing 503 – LDContextNotAvaliable error if remote JSON-LD @context cannot be retrieved +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Variable *** +${expected_status_code}= 503 + +${building_id_prefix}= urn:ngsi-ld:Building: +${building_filename}= building-minimal-without-context-sample.jsonld + +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${subscription_filename}= csourceSubscriptions/subscription-without-context-sample.jsonld + +${tea_id_prefix}= urn:ngsi-ld:Vehicle: +${tea_filename}= bus-temporal-representation-without-context-sample.jsonld + +${registration_id_prefix}= urn:ngsi-ld:Registration: +${registration_filename}= csourceRegistrations/context-source-registration-without-context-sample.jsonld + +*** Test Cases *** +043_01 Create entity + [Documentation] Verify throwing 503 – LDContextNotAvaliable error if remote JSON-LD @context cannot be retrieved (Create entity) + + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type ${building_filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code ${expected_status_code} ${response['status']} + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_LD_CONTEXT_NOT_AVAILABLE} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} + + [Teardown] Delete Entity by Id ${entity_id} + +043_02 Create subscription + [Documentation] Verify throwing 503 – LDContextNotAvaliable error if remote JSON-LD @context cannot be retrieved (Create subscription) + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${response}= Create Subscription ${subscription_id} ${subscription_filename} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code ${expected_status_code} ${response['status']} + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_LD_CONTEXT_NOT_AVAILABLE} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} + + [Teardown] Delete Subscription ${subscription_id} + + +043_03 Create Temporal Representation of Entities + [Documentation] Verify throwing 503 – LDContextNotAvaliable error if remote JSON-LD @context cannot be retrieved (Create Temporal Representation of Entities) + + ${temporal_entity_representation_id}= Generate Random Entity Id ${tea_id_prefix} + ${response}= Create Or Update Temporal Representation Of Entity Selecting Content Type ${temporal_entity_representation_id} ${tea_filename} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code ${expected_status_code} ${response['status']} + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_LD_CONTEXT_NOT_AVAILABLE} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} + + [Teardown] Delete Temporal Representation Of Entity ${temporal_entity_representation_id} + +043_04 Batch entity create + [Documentation] Verify throwing 503 – LDContextNotAvaliable error if remote JSON-LD @context cannot be retrieved (Batch entity create) + + ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} + ${second_entity_id}= Generate Random Entity Id ${building_id_prefix} + ${first_entity}= Load Entity ${building_filename} ${first_entity_id} + ${second_entity}= Load Entity ${building_filename} ${second_entity_id} + @{entities_to_be_created}= Create List ${first_entity} ${second_entity} + + Batch Create Entities @{entities_to_be_created} content_type=${CONTENT_TYPE_LD_JSON} + Check Response Status Code Set To ${expected_status_code} + Check RL Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_LD_CONTEXT_NOT_AVAILABLE} + Check RL Response Body Containing ProblemDetails Element Containing Title Element ${response} + + [Teardown] Batch Delete Entities @{entities_to_be_created} + +043_05 Create context source registration + [Documentation] Verify throwing 503 – LDContextNotAvaliable error if remote JSON-LD @context cannot be retrieved (Create context source registration) + + ${registration_id_prefix}= Generate Random Entity Id ${registration_id_prefix} + + ${payload}= Load Json From File ${EXECDIR}/data/${registration_filename} + ${updated_payload}= Update Value To Json ${payload} $..id ${registration_id_prefix} + ${request} ${response}= Create Context Source Registration With Return ${updated_payload} + Check Response Status Code ${expected_status_code} ${response['status']} + Check Response Headers Containing URI set to ${request['path']}/ ${registration_id} ${response} + + [Teardown] Delete Context Source Registration ${registration_id_prefix} \ No newline at end of file diff --git a/TP/NGSI-LD/CommonBehaviours/044_01.robot b/TP/NGSI-LD/CommonBehaviours/044_01.robot new file mode 100644 index 0000000000000000000000000000000000000000..76c1db84680a8d00c3affd97cf3d51da89b17e35 --- /dev/null +++ b/TP/NGSI-LD/CommonBehaviours/044_01.robot @@ -0,0 +1,41 @@ +*** Settings *** +Documentation Verify that PATCH HTTP requests can be done with "application/merge-patch+json" as Content-Type +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Variable *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${vehicle_filename}= vehicle-simple-attributes-sample.jsonld +${vehicle_fragment}= vehicle-brandname-fragment.jsonld +${attribute_id}= brandName + +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${subscription_filename}= csourceSubscriptions/subscription-sample.jsonld +${subscription_fragment}= csourceSubscriptions/fragments/subscription-update-sample.jsonld + +*** Test Cases *** +044_01_01_endpoint /entities/{entityId}/attrs/{attrId} + [Documentation] Verify that PATCH HTTP requests can be done with "application/merge-patch+json" as Content-Type + [Tags] mandatory + ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type ${vehicle_filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${response}= Partial Update Entity Attributes ${entity_id} ${attribute_id} ${vehicle_fragment} ${CONTENT_TYPE_MERGE_PATCH_JSON} + Check Response Status Code 204 ${response['status']} + + [Teardown] Delete Entity by Id ${entity_id} + +044_01_02_endpoint /subscriptions/{subscriptionId} + [Documentation] Verify that PATCH HTTP requests can be done with "application/merge-patch+json" as Content-Type + [Tags] mandatory + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${response}= Create Subscription ${subscription_id} ${subscription_filename} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${response}= Update Subscription ${subscription_id} ${subscription_fragment} ${CONTENT_TYPE_MERGE_PATCH_JSON} + Check Response Status Code 204 ${response['status']} + + [Teardown] Delete Subscription ${subscription_id} + diff --git a/TP/NGSI-LD/CommonBehaviours/044_02.robot b/TP/NGSI-LD/CommonBehaviours/044_02.robot new file mode 100644 index 0000000000000000000000000000000000000000..df734374731bb8a787b29d8306ac7bfad9b75099 --- /dev/null +++ b/TP/NGSI-LD/CommonBehaviours/044_02.robot @@ -0,0 +1,84 @@ +*** Settings *** +Documentation Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Variable *** +${building_id_prefix}= urn:ngsi-ld:Building: +${building_filename}= building-simple-attributes-sample.jsonld +${building_expectation}= building-simple-attributes-sample-expectation.json +${entity_type}= https://ngsi-ld-test-suite/context#Building + +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${subscription_filename}= csourceSubscriptions/subscription-sample.jsonld +${subscription_expectation}= subscription-sample-expectation.json + +${registration_id_prefix}= urn:ngsi-ld:Registration: +${registration_filename}= csourceRegistrations/context-source-registration-with-expiration-sample.jsonld +${registration_expectation}= context-source-registration-with-expiration-expectation.json +${registration_type}= Vehicle + +${tea_id_prefix}= urn:ngsi-ld:Vehicle: +${tea_filename}= vehicle-temporal-representation-sample.jsonld +${tea_expectation}= vehicle-temporal-representation-expectation.json +${teatype}= Vehicle + +*** Test Cases *** +044_02_01_endpoint /entities/{entityId} + [Documentation] Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/entities/{entityId}) + ${id}= Generate Random Entity Id ${building_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type ${building_filename} ${id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${request} ${response}= Query Entity ${id} + Check Response Status Code 200 ${response['status']} + Check Response Body Containing Entity element ${building_expectation} ${id} ${response['body']} + Check Request Containing Accept Header Set To ${request} application/json, */* + + [Teardown] Delete Entity by Id Returning Response ${id} + + +044_02_02_endpoint /subscriptions/{subscriptionId} + [Documentation] Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/subscriptions/{subscriptionId}) + + ${id}= Generate Random Entity Id ${subscription_id_prefix} + ${response}= Create Subscription ${id} ${subscription_filename} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${request} ${response}= Retrieve Subscription ${id} + Check Response Status Code 200 ${response['status']} + Check Response Body Containing One Subscription element ${subscription_expectation} ${response['body']} + Check Request Containing Accept Header Set To ${request} application/json, */* + + [Teardown] Delete Subscription ${id} + +044_02_03_endpoint /csourceRegistrations/ + [Documentation] Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/csourceRegistrations/) + + ${registration_id}= Generate Random Entity Id ${registration_id_prefix} + ${payload}= Load Json From File ${EXECDIR}/data/${registration_filename} + ${updated_payload}= Update Value To Json ${payload} $..id ${registration_id} + ${request} ${response}= Create Context Source Registration With Return ${updated_payload} + Check Response Status Code 201 ${response['status']} + + ${request} ${response}= Query Context Source Registrations With Return id=${registration_id} type=${registration_type} + Check Response Status Code 200 ${response['status']} + Check Response Body Containing One Registration element ${registration_expectation} ${response['body']} + Check Request Containing Accept Header Set To ${request} application/json, */* + + [Teardown] Delete Context Source Registration ${registration_id} + +044_02_04_endpoint /temporal/entities + [Documentation] Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/temporal/entities) + + ${temporal_entity_representation_id}= Generate Random Entity Id ${tea_id_prefix} + Create Temporal Representation Of Entity ${tea_filename} ${temporal_entity_representation_id} + + ${request} ${response}= Query Temporal Representation Of Entities With Return entity_types=${teatype} timerel=after timeAt=2020-08-01T12:05:00Z + Check Response Status Code 200 ${response['status']} + Set Test Variable ${response} + Check Response Body Containing EntityTemporal element ${tea_expectation} ${temporal_entity_representation_id} + Check Request Containing Accept Header Set To ${request} application/json, */* + + [Teardown] Delete Temporal Representation Of Entity ${temporal_entity_representation_id} \ No newline at end of file diff --git a/TP/NGSI-LD/CommonBehaviours/044_03.robot b/TP/NGSI-LD/CommonBehaviours/044_03.robot new file mode 100644 index 0000000000000000000000000000000000000000..bf43562bb5c5dcf00f586a3f89e652f3b538bbc4 --- /dev/null +++ b/TP/NGSI-LD/CommonBehaviours/044_03.robot @@ -0,0 +1,90 @@ +*** Settings *** +Documentation Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Variable *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${vehicle_filename}= vehicle-simple-attributes-sample.json +${vehicle_attribute}= speed +${vehicle_fragment}= vehicle-brandname-fragment.jsonld + +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${subscription_filename}= csourceSubscriptions/subscription-sample.jsonld +${subscription_fragment}= csourceSubscriptions/fragments/subscription-update-sample.jsonld + +${tea_id_prefix}= urn:ngsi-ld:Vehicle: +${tea_filename}= vehicle-temporal-representation-sample.jsonld + +${building_id_prefix}= urn:ngsi-ld:Building: +${building_filename}= building-simple-attributes-sample.jsonld + +*** Test Cases *** +044_03_01_endpoint patch /entities/{entityId}/attrs/{attrId} + [Documentation] Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (patch /entities/{entityId}/attrs/{attrId}) + + ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type ${vehicle_filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${response}= Partial Update Entity Attributes ${entity_id} ${vehicle_attribute} ${vehicle_fragment} ${EMPTY} + Check Response Status Code 415 ${response['status']} + + [Teardown] Delete Entity by Id Returning Response ${entity_id} + +044_03_02_endpoint patch /subscriptions/{subscriptionId} + [Documentation] Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (patch /subscriptions/{subscriptionId}) + + ${id}= Generate Random Entity Id ${subscription_id_prefix} + ${response}= Create Subscription ${id} ${subscription_filename} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${response}= Update Subscription ${id} ${subscription_fragment} ${EMPTY} + Check Response Status Code 415 ${response['status']} + + [Teardown] Delete Subscription ${id} + +044_03_03_endpoint post /entities/ + [Documentation] Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (post /entities/) + + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type ${building_filename} ${entity_id} ${EMPTY} + Check Response Status Code 415 ${response['status']} + + [Teardown] Delete Entity by Id ${entity_id} + +044_03_04_endpoint post /subscriptions/ + [Documentation] Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (post /subscriptions/) + + ${subscriptions_id}= Generate Random Entity Id ${subscription_id_prefix} + ${response}= Create Subscription ${subscriptions_id} ${subscription_filename} ${EMPTY} + Check Response Status Code 415 ${response['status']} + + [Teardown] Delete Subscription ${subscriptions_id} + +044_03_05_endpoint post /entityOperations/create + + [Documentation] Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (post /entityOperations/create) + + ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} + ${second_entity_id}= Generate Random Entity Id ${building_id_prefix} + ${first_entity}= Load Entity ${building_filename} ${first_entity_id} + ${second_entity}= Load Entity ${building_filename} ${second_entity_id} + @{entities_to_be_created}= Create List ${first_entity} ${second_entity} + + Batch Create Entities @{entities_to_be_created} content_type=${EMPTY} + + @{expected_entities_ids}= Create List ${first_entity_id} ${second_entity_id} + Check Response Status Code Set To 415 + + [Teardown] Batch Delete Entities @{expected_entities_ids} + +044_03_06_endpoint post /temporal/entities/ + [Documentation] Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (post /temporal/entities/) + + ${temporal_entity_representation_id}= Generate Random Entity Id ${tea_id_prefix} + ${response}= Create Or Update Temporal Representation Of Entity Selecting Content Type ${temporal_entity_representation_id} ${tea_filename} ${EMPTY} + Check Response Status Code 415 ${response['status']} + + [Teardown] Delete Temporal Representation Of Entity ${temporal_entity_representation_id} \ No newline at end of file diff --git a/TP/NGSI-LD/CommonBehaviours/044_04.robot b/TP/NGSI-LD/CommonBehaviours/044_04.robot new file mode 100644 index 0000000000000000000000000000000000000000..29d07ad62cea661715c5b9b228763e407ea525b7 --- /dev/null +++ b/TP/NGSI-LD/CommonBehaviours/044_04.robot @@ -0,0 +1,58 @@ +*** Settings *** +Documentation Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Variable *** +${accept}= application/xml +${status_code}= 406 + +${building_id_prefix}= urn:ngsi-ld:Building: +${building_filename}= building-simple-attributes-sample.jsonld + +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${subscription_filename}= csourceSubscriptions/subscription-sample.jsonld + +*** Test Cases *** +044_04_01_endpoint get /entities/{entityId} + [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /entities/{entityId}) + + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type ${building_filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${request} ${response}= Query Entity ${entity_id} accept=${accept} + Check Response Status Code ${status_code} ${response['status']} + + [Teardown] Delete Entity by Id Returning Response ${entity_id} + +044_04_02_endpoint get /subscriptions/{subscriptionId} + [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /subscriptions/{subscriptionId}) + + ${id}= Generate Random Entity Id ${subscription_id_prefix} + ${response}= Create Subscription ${id} ${subscription_filename} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${request} ${response}= Retrieve Subscription ${id} accept=${accept} + Check Response Status Code ${status_code} ${response['status']} + + [Teardown] Delete Subscription ${id} + +044_04_03_endpoint get /csourceRegistrations/ + [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /csourceRegistrations/) + + Query Context Source Registrations type=Building accept=${accept} + Check Response Status Code Set To ${status_code} + +044_04_04_endpoint get /csourceSubscriptions/ + [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /csourceSubscriptions/) + + Query Context Source Registration Subscriptions accept=${accept} + Check Response Status Code Set To ${status_code} + +044_04_05_endpoint get /temporal/entities + [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /temporal/entities) + ${entity_types_to_be_retrieved}= Catenate SEPARATOR=, Vehicle + Query Temporal Representation Of Entities entity_types=${entity_types_to_be_retrieved} timerel=after timeAt=2020-08-01T12:05:00Z accept=${accept} + Check Response Status Code Set To ${status_code} \ No newline at end of file diff --git a/TP/NGSI-LD/CommonBehaviours/044_05.robot b/TP/NGSI-LD/CommonBehaviours/044_05.robot new file mode 100644 index 0000000000000000000000000000000000000000..ff5b8b74ef9a3c8478585123d1f4034e63394b56 --- /dev/null +++ b/TP/NGSI-LD/CommonBehaviours/044_05.robot @@ -0,0 +1,107 @@ +*** Settings *** +Documentation Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header is "application/geo+json" for operations different than "Retrieve Entity" and "Query Entity" +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Variable *** +${accept}= application/geo+json +${status_code}= 406 + +${building_id_prefix}= urn:ngsi-ld:Building: +${building_filename}= building-simple-attributes-sample.jsonld +${entity_type}= https://ngsi-ld-test-suite/context#Building + +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${subscription_filename}= csourceSubscriptions/subscription-sample.jsonld +${subscription_fragment}= csourceSubscriptions/fragments/subscription-update-sample.json + +${registration_id_prefix}= urn:ngsi-ld:Registration: +${registration_filename}= context-source-registration-with-expiration-sample.jsonld +${registration_fragment}= context-source-registration-with-expiration-expectation.json + +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${vehicle_filename}= vehicle-simple-attributes-sample.jsonld +${vehicle_attribute}= brandName +${vehicle_fragment}= vehicle-brandname-fragment.jsonld + +${tea_id_prefix}= urn:ngsi-ld:Vehicle: +${tea_filename}= vehicle-temporal-representation-sample.jsonld + +*** Test Cases *** +044_05_01_endpoint create /entities/ + [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header is "application/geo+json" for operations different than "Retrieve Entity" and "Query Entity" (create /entities/) + + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type ${building_filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} accept=${accept} + Check Response Status Code ${status_code} ${response['status']} + + [Teardown] Delete Entity by Id ${entity_id} + +044_05_02_endpoint update /entities/{entityId}/attrs/{attrId} + [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header is "application/geo+json" for operations different than "Retrieve Entity" and "Query Entity" (update /entities/{entityId}/attrs/{attrId}) + + ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type ${vehicle_filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + Retrieve Entity by Id ${entity_id} + ${response}= Partial Update Entity Attributes ${entity_id} ${vehicle_attribute} ${vehicle_fragment} ${CONTENT_TYPE_LD_JSON} accept=${accept} + Check Response Status Code ${status_code} ${response['status']} + + [Teardown] Delete Entity by Id Returning Response ${entity_id} + +044_05_03_endpoint create /subscriptions/ + [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header is "application/geo+json" for operations different than "Retrieve Entity" and "Query Entity" (create /subscriptions/) + + ${subscriptions_id}= Generate Random Entity Id ${subscription_id_prefix} + ${response}= Create Subscription ${subscriptions_id} ${subscription_filename} ${CONTENT_TYPE_LD_JSON} accept=${accept} + Check Response Status Code ${status_code} ${response['status']} + + [Teardown] Delete Subscription ${subscriptions_id} + +044_05_04_endpoint update /subscriptions/{subscriptionId} + [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header is "application/geo+json" for operations different than "Retrieve Entity" and "Query Entity" (update /subscriptions/{subscriptionId}) + + ${id}= Generate Random Entity Id ${subscription_id_prefix} + ${response}= Create Subscription ${id} ${subscription_filename} ${CONTENT_TYPE_LD_JSON} + + ${response}= Update Subscription ${id} ${subscription_fragment} ${CONTENT_TYPE_LD_JSON} accept=${accept} + Check Response Status Code ${status_code} ${response['status']} + + [Teardown] Delete Subscription ${id} + +044_05_05_endpoint create /temporal/entities/ + [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header is "application/geo+json" for operations different than "Retrieve Entity" and "Query Entity" (create /temporal/entities/) + + ${temporal_entity_representation_id}= Generate Random Entity Id ${tea_id_prefix} + ${response}= Create Or Update Temporal Representation Of Entity Selecting Content Type ${temporal_entity_representation_id} ${tea_filename} ${CONTENT_TYPE_LD_JSON} accept=${accept} + Check Response Status Code ${status_code} ${response['status']} + + [Teardown] Delete Temporal Representation Of Entity ${temporal_entity_representation_id} + +044_05_06_endpoint create /entityOperations/create + [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header is "application/geo+json" for operations different than "Retrieve Entity" and "Query Entity" (create /entityOperations/create) + + ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} + ${second_entity_id}= Generate Random Entity Id ${building_id_prefix} + ${first_entity}= Load Entity ${building_filename} ${first_entity_id} + ${second_entity}= Load Entity ${building_filename} ${second_entity_id} + @{entities_to_be_created}= Create List ${first_entity} ${second_entity} + + Batch Create Entities @{entities_to_be_created} content_type=${CONTENT_TYPE_LD_JSON} accept=${accept} + + @{expected_entities_ids}= Create List ${first_entity_id} ${second_entity_id} + Check Response Status Code Set To ${status_code} + + [Teardown] Batch Delete Entities @{expected_entities_ids} + +044_05_07_endpoint create /csourceRegistrations/ + [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header is "application/geo+json" for operations different than "Retrieve Entity" and "Query Entity" (create /csourceRegistrations/) + + ${registration_id}= Generate Random Entity Id ${registration_id_prefix} + ${payload}= Load Json From File ${EXECDIR}/data/csourceRegistrations/${registration_filename} + ${updated_payload}= Update Value To Json ${payload} $..id ${registration_id} + ${request} ${response}= Create Context Source Registration With Return ${updated_payload} accept=${accept} + Check Response Status Code ${status_code} ${response['status']} + + [Teardown] Delete Context Source Registration ${registration_id} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_01_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_01_01.robot index c7928e4486e14213ecee879622512f875694282a..30c74bf434080532229080eb40c7b3714d86a551 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_01_01.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_01_01.robot @@ -18,7 +18,7 @@ ${expectation_filename}= building-simple-attributes-expectation.jsonld ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} Check Response Status Code 201 ${response['status']} - ${response}= Query Entity ${entity_id} ${CONTENT_TYPE_LD_JSON} + ${request} ${response}= Query Entity ${entity_id} ${CONTENT_TYPE_LD_JSON} Check Response Status Code 200 ${response['status']} Check Response Body Containing Entity element ${expectation_filename} ${entity_id} ${response['body']} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_01_03.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_01_03.robot index f63cfea57a623a836e91bd81a72a7cf76e95d507..5441bf70f31da6f1d978ecd098c6201aeb1e5d4c 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_01_03.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_01_03.robot @@ -19,7 +19,7 @@ ${geometry_property}= location ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} Check Response Status Code 201 ${response['status']} - ${response}= Query Entity ${entity_id} ${CONTENT_TYPE_LD_JSON} geoproperty=${geometry_property} + ${request} ${response}= Query Entity ${entity_id} ${CONTENT_TYPE_LD_JSON} geoproperty=${geometry_property} Check Response Status Code 200 ${response['status']} Check Response Body Containing Entity element ${expectation_filename} ${entity_id} ${response['body']} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_02.robot index 5f75ed8079e2a20b58fa92d272e02d473db1db2a..b834764bd49f415abd170ee031cc13188b2c586a 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_02.robot @@ -15,7 +15,7 @@ Get Entity With Invalid/Missing Id [Documentation] Check that you cannot get an entity with invalid/missing id [Tags] /entities/{entityId} 5_7_1 - ${response}= Query Entity ${entity_id} ${CONTENT_TYPE_LD_JSON} + ${request} ${response}= Query Entity ${entity_id} ${CONTENT_TYPE_LD_JSON} Check Response Status Code ${expected_status_code} ${response['status']} Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${problem_type} Check Response Body Containing ProblemDetails Element Containing Title Element ${response} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_03_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_03_01.robot index 7d82ec3aff5020c699cea73c8188985a3e4099d2..911bb58ee0a8b5e34d6e0eaaca723b83d7fc7ed4 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_03_01.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_03_01.robot @@ -13,7 +13,7 @@ Get an entity if the Entity Id is not known to the system [Tags] /entities/{entityId} 5_6_6 ${entity_id}= Generate Random Entity Id ${building_id_prefix} - ${response}= Query Entity ${entity_id} ${CONTENT_TYPE_LD_JSON} + ${request} ${response}= Query Entity ${entity_id} ${CONTENT_TYPE_LD_JSON} Check Response Status Code 404 ${response['status']} Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_RESOURCE_NOT_FOUND} Check Response Body Containing ProblemDetails Element Containing Title Element ${response} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_04.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_04.robot index 5ebaa22113c8515f635ea22c3eb03481224f9379..19e29198140a51249dbb6947ec59ba1355fee73f 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_04.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_04.robot @@ -19,7 +19,7 @@ Get an entity in a simplified representation ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} Check Response Status Code 201 ${response['status']} - ${response}= Query Entity ${entity_id} ${CONTENT_TYPE_LD_JSON} options=${options_parameter} + ${request} ${response}= Query Entity ${entity_id} ${CONTENT_TYPE_LD_JSON} options=${options_parameter} Check Response Status Code 200 ${response['status']} Check Response Body Containing Entity element ${expectation_filename} ${entity_id} ${response['body']} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_05.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_05.robot index 4c2392da68bf12f33ccd540b3909a2f43f2199ec..faa882c32122b3b57c629db3fda590fa5c1a6dac 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_05.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_05.robot @@ -20,7 +20,7 @@ Get an entity by id that can be returned in a geoJSON format ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} Check Response Status Code 201 ${response['status']} - ${response}= Query Entity ${entity_id} ${accept_header} options=${options_parameter} + ${request} ${response}= Query Entity ${entity_id} ${accept_header} options=${options_parameter} Check Response Status Code 200 ${response['status']} Check Response Body Containing Entity element ${expectation_filename} ${entity_id} ${response} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_06.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_06.robot index 48e921f249fe8f2ed983454a6c1dacbaf6e169d3..c380f352574cda3124208e5598595159855500ab 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_06.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/018_06.robot @@ -25,7 +25,7 @@ Check Json-LD Resolution When retrieving an entity [Documentation] Check that the JSON-LD @context is obtained from a Link header if present and that the default JSON-LD @context is used if not present [Tags] mandatory - ${response}= Query Entity ${entity_id} ${CONTENT_TYPE_JSON} context=${context} + ${request} ${response}= Query Entity ${entity_id} ${CONTENT_TYPE_JSON} context=${context} Check Response Status Code 200 ${response['status']} Check Response Body Containing Entity element ${expected_payload} ${entity_id} ${response['body']} diff --git a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_01.robot b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_01.robot index 23cd6558177a15eb3aa1814518e079e53689f5dc..76961327c978841b9245fe587b80f2cb75074439 100644 --- a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_01.robot +++ b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_01.robot @@ -26,7 +26,7 @@ Update Context Source ${fragment}= Load Json From File ${EXECDIR}/data/csourceRegistrations/${update_filename} ${fragment_with_id}= Update Value To Json ${fragment} $..id ${registration_id} - ${response}= Update Context Source Registration With Return ${registration_id} ${fragment_with_id} + ${response}= Update Context Source Registration With Return ${registration_id} ${fragment_with_id} ${CONTENT_TYPE_LD_JSON} Check Response Status Code 204 ${response['status']} [Teardown] Delete Context Source Registration ${registration_id} diff --git a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_02.robot b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_02.robot index 263fc5e8e154633eea04f0996e1310629d908b8d..a059a3927d1ac1560b035bf45e0abc1b7ffee915 100644 --- a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_02.robot +++ b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_02.robot @@ -35,7 +35,7 @@ Update Context Source ${fragment}= Load Json From File ${EXECDIR}/data/csourceRegistrations/${fragment_filename} ${fragment_with_id}= Update Value To Json ${fragment} $..id ${registration_id} - ${response}= Update Context Source Registration With Return ${registration_id} ${fragment_with_id} + ${response}= Update Context Source Registration With Return ${registration_id} ${fragment_with_id} ${CONTENT_TYPE_LD_JSON} Check Response Status Code 400 ${response['status']} Check Response Body Containing ProblemDetails Element Containing Title Element ${response} diff --git a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_03.robot b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_03.robot index d05e504a279954004e461c48043dd4ed3cb9e4bb..63127614c3465a25f32cdbf4c853d9327e758299 100644 --- a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_03.robot +++ b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_03.robot @@ -15,7 +15,7 @@ Update a context source registration by id if the id is not known to the system ${registration_id}= Generate Random Entity Id ${registration_id_prefix} ${fragment}= Load Json From File ${EXECDIR}/data/csourceRegistrations/${filename} ${fragment_with_id}= Update Value To Json ${fragment} $..id ${registration_id} - ${response}= Update Context Source Registration With Return ${registration_id} ${fragment_with_id} + ${response}= Update Context Source Registration With Return ${registration_id} ${fragment_with_id} ${CONTENT_TYPE_LD_JSON} Check Response Status Code 404 ${response['status']} Check Response Body Containing ProblemDetails Element Containing Title Element ${response} diff --git a/data/csourceRegistrations/context-source-registration-without-context-sample.jsonld b/data/csourceRegistrations/context-source-registration-without-context-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..b4a6b06efb3f5a7e307eb5f2467e5b92afb248ac --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-without-context-sample.jsonld @@ -0,0 +1,14 @@ +{ + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Building" + } + ] + } + ], + "endpoint":"http://my.csource.org:1026" +} \ No newline at end of file diff --git a/data/csourceRegistrations/expectations/context-source-registration-with-expiration-expectation.json b/data/csourceRegistrations/expectations/context-source-registration-with-expiration-expectation.json new file mode 100644 index 0000000000000000000000000000000000000000..ee6679e4b5619f74292664acc3332f8c24343d97 --- /dev/null +++ b/data/csourceRegistrations/expectations/context-source-registration-with-expiration-expectation.json @@ -0,0 +1,60 @@ + { + "id": "urn:ngsi-ld:Registration:randomUUID", + "type": "ContextSourceRegistration", + "timestamp": {}, + "endpoint": "http://my.csource.org:1026", + "information": [ + { + "entities": [ + { + "id": "urn:ngsi-ld:Registration:3911535208644330", + "type": "Vehicle" + } + ], + "ngsi-ld:properties": [], + "ngsi-ld:relationships": [] + }, + { + "entities": [ + { + "type": "OffStreetParking", + "idPattern": ".*downtown$" + }, + { + "type": "OffStreetParking", + "idPattern": ".*47$" + } + ], + "ngsi-ld:properties": [], + "ngsi-ld:relationships": [] + } + ], + "ngsi-ld:internal": false, + "location": { + "type": "Polygon", + "coordinates": [ + [ + [ + 100.0, + 0.0 + ], + [ + 101.0, + 0.0 + ], + [ + 101.0, + 1.0 + ], + [ + 100.0, + 1.0 + ], + [ + 100.0, + 0.0 + ] + ] + ] + } + } \ No newline at end of file diff --git a/data/csourceRegistrations/fragments/context-source-registration-update-sample.jsonld b/data/csourceRegistrations/fragments/context-source-registration-update-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..795d209e4484698edd1e43a9a750622e7a8e8c87 --- /dev/null +++ b/data/csourceRegistrations/fragments/context-source-registration-update-sample.jsonld @@ -0,0 +1,6 @@ +{ + "endpoint":"http://my.new.csource.org:1026", + "@context": [ + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.3.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceSubscriptions/expectations/subscription-sample-expectation.json b/data/csourceSubscriptions/expectations/subscription-sample-expectation.json new file mode 100644 index 0000000000000000000000000000000000000000..42d6c58f4bf548fdc25c823c67e20bc5815d05e6 --- /dev/null +++ b/data/csourceSubscriptions/expectations/subscription-sample-expectation.json @@ -0,0 +1,16 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type": "Subscription", + "entities": [ + { + "type": "https://ngsi-ld-test-suite/context#Building" + } + ], + "notification": { + "endpoint": { + "accept": "application/json", + "uri": "http://my.endpoint.org/notify" + }, + "format": "keyValues" + } +} \ No newline at end of file diff --git a/data/csourceSubscriptions/fragments/subscription-update-sample.jsonld b/data/csourceSubscriptions/fragments/subscription-update-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..f721ed26c94fdb61756228d2cb50a356db1d6ca9 --- /dev/null +++ b/data/csourceSubscriptions/fragments/subscription-update-sample.jsonld @@ -0,0 +1,10 @@ +{ + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.second.endpoint.org/notify", + "accept":"application/json" + } + }, + "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" +} \ No newline at end of file diff --git a/data/csourceSubscriptions/subscription-without-context-sample.jsonld b/data/csourceSubscriptions/subscription-without-context-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..36860f5b4da5b44b3b8d439cf28f1861ce1a1c2d --- /dev/null +++ b/data/csourceSubscriptions/subscription-without-context-sample.jsonld @@ -0,0 +1,16 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + } +} \ No newline at end of file diff --git a/data/entities/expectations/building-simple-attributes-sample-expectation.json b/data/entities/expectations/building-simple-attributes-sample-expectation.json new file mode 100644 index 0000000000000000000000000000000000000000..f23a0d025771787c50861e51716a6ff2c1b2402b --- /dev/null +++ b/data/entities/expectations/building-simple-attributes-sample-expectation.json @@ -0,0 +1,22 @@ +{ + "id": "urn:ngsi-ld:Building:randomUUID", + "type": "https://ngsi-ld-test-suite/context#Building", + "name": { + "type": "Property", + "value": "Eiffel Tower" + }, + "https://ngsi-ld-test-suite/context#airQualityLevel": { + "type": "Property", + "value": 4, + "observedAt": "2020-09-09T16:40:00.000Z", + "unitCode": "C62" + }, + "https://ngsi-ld-test-suite/context#almostFull": { + "type": "Property", + "value": false + }, + "https://ngsi-ld-test-suite/context#subCategory": { + "type": "Property", + "value": "tourism" + } +} \ No newline at end of file diff --git a/data/entities/expectations/vehicle-parking-sample-expectation.json b/data/entities/expectations/vehicle-parking-sample-expectation.json new file mode 100644 index 0000000000000000000000000000000000000000..0205a53fbc0486aa63a51f59fefeab0eb8675d1e --- /dev/null +++ b/data/entities/expectations/vehicle-parking-sample-expectation.json @@ -0,0 +1,54 @@ +[ + { + "id": "urn:ngsi-ld:OffStreetParking:randomUUID", + "type": "https://ngsi-ld-test-suite/context#OffStreetParking", + "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 + ] + } + }, + "name": { + "type": "Property", + "value": "Downtown One" + } + }, + { + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "https://ngsi-ld-test-suite/context#Vehicle", + "https://ngsi-ld-test-suite/context#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" + } + } +] \ No newline at end of file diff --git a/data/entities/fragmentEntities/vehicle-brandname-fragment.jsonld b/data/entities/fragmentEntities/vehicle-brandname-fragment.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..819eca55e4631dadf1edda12e9d2523d4f25a8bb --- /dev/null +++ b/data/entities/fragmentEntities/vehicle-brandname-fragment.jsonld @@ -0,0 +1,7 @@ +{ + "https://ngsi-ld-test-suite/context#brandName": { + "type": "Property", + "value": "BMW" + }, + "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" +} \ No newline at end of file diff --git a/data/temporalEntities/bus-temporal-representation-without-context-sample.jsonld b/data/temporalEntities/bus-temporal-representation-without-context-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..9a70e2bd3f3b391d336763d9324aed2bb06454a6 --- /dev/null +++ b/data/temporalEntities/bus-temporal-representation-without-context-sample.jsonld @@ -0,0 +1,44 @@ +{ + "id":"urn:ngsi-ld:Bus:randomUUID", + "type":"Bus", + "brandName":[ + { + "type":"Property", + "value":"Mercedes" + } + ], + "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" + } + ], + "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" + } + ] +} \ No newline at end of file diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-expectation.json b/data/temporalEntities/expectations/vehicle-temporal-representation-expectation.json new file mode 100644 index 0000000000000000000000000000000000000000..7917df3cc19bec2f9b2925ac20860ebc862de024 --- /dev/null +++ b/data/temporalEntities/expectations/vehicle-temporal-representation-expectation.json @@ -0,0 +1,44 @@ +{ + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type": "https://ngsi-ld-test-suite/context#Vehicle", + "https://ngsi-ld-test-suite/context#brandName": { + "type": "Property", + "value": "BMW", + "instanceId": "urn:ngsi-ld:76739600-3d5c-4cfd-939d-34742a13b52d" + }, + "https://ngsi-ld-test-suite/context#fuelLevel": [ + { + "type": "Property", + "datasetId": "urn:ngsi-ld:Vehicle:12345-fuel", + "value": 40, + "instanceId": "urn:ngsi-ld:0f6e7514-e3ed-46a6-9e9f-6bb02ff687bf", + "observedAt": "2020-09-01T14:07:00Z" + }, + { + "type": "Property", + "value": 53, + "instanceId": "urn:ngsi-ld:59ebe244-14d6-4428-87e1-cd313748125c", + "observedAt": "2020-09-01T13:05:00Z" + }, + { + "type": "Property", + "value": 67, + "instanceId": "urn:ngsi-ld:8bfeea42-8ed3-4d4e-a942-c389229bd6ff", + "observedAt": "2020-09-01T12:03:00Z" + } + ], + "https://ngsi-ld-test-suite/context#speed": [ + { + "type": "Property", + "value": 120, + "instanceId": "urn:ngsi-ld:ec47b86f-656e-4182-b1c2-fbe5af5b4862", + "observedAt": "2020-09-01T12:03:00Z" + }, + { + "type": "Property", + "value": 80, + "instanceId": "urn:ngsi-ld:f3ffc7ad-e562-4081-bd8a-5dda92ab0ffd", + "observedAt": "2020-09-01T12:05:00Z" + } + ] +} \ No newline at end of file diff --git a/data/temporalEntities/fragments/vehicle-temporal-intanceid-update-sample.jsonld b/data/temporalEntities/fragments/vehicle-temporal-intanceid-update-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..d7433ad6a3222dae4338f16ea712745cddd9965c --- /dev/null +++ b/data/temporalEntities/fragments/vehicle-temporal-intanceid-update-sample.jsonld @@ -0,0 +1,12 @@ +{ + "speed":[ + { + "type":"Property", + "value":129, + "observedAt":"2020-09-01T12:03: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" + ] +} \ No newline at end of file diff --git a/data/temporalEntities/vehicle-temporal-representation-sample.jsonld b/data/temporalEntities/vehicle-temporal-representation-sample.jsonld index 2dde1c15c62216b7e183b7993c8f15fc99c15df6..5f049b3ece7be9b912c95ca48fa97869c92364b3 100644 --- a/data/temporalEntities/vehicle-temporal-representation-sample.jsonld +++ b/data/temporalEntities/vehicle-temporal-representation-sample.jsonld @@ -17,11 +17,6 @@ "type":"Property", "value":80, "observedAt":"2020-09-01T12:05:00Z" - }, - { - "type":"Property", - "value":100, - "observedAt":"2020-09-01T12:07:00Z" } ], "fuelLevel":[ diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 1789ba867f662ddb6160262aa89bf2cd6fbfe76c..b1243bca75144bac71e53de21dc0f064649bacb7 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -19,15 +19,18 @@ ${ENTITY_OPERATIONS_QUERY_ENDPOINT_PATH} entityOperations/query ${TEMPORAL_ENTITIES_ENDPOINT_PATH} temporal/entities ${TEMPORAL_ENTITY_OPERATIONS_ENDPOINT_PATH} temporal/entityOperations ${CONTEXT_SOURCE_REGISTRATION_ENDPOINT_PATH} csourceRegistrations +${SUBSCRIPTION_ENDPOINT_PATH} subscriptions/ ${CONTEXT_SOURCE_REGISTRATION_SUBSCRIPTION_ENDPOINT_PATH} csourceSubscriptions ${CONTENT_TYPE_JSON} application/json ${CONTENT_TYPE_LD_JSON} application/ld+json +${CONTENT_TYPE_MERGE_PATCH_JSON} application/merge-patch+json -${ERROR_TYPE_BAD_REQUEST_DATA} https://uri.etsi.org/ngsi-ld/errors/BadRequestData -${ERROR_TYPE_INVALID_REQUEST} https://uri.etsi.org/ngsi-ld/errors/InvalidRequest -${ERROR_TYPE_RESOURCE_NOT_FOUND} https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound -${ERROR_TYPE_ALREADY_EXISTS} https://uri.etsi.org/ngsi-ld/errors/AlreadyExists +${ERROR_TYPE_BAD_REQUEST_DATA} http://uri.etsi.org/ngsi-ld/errors/BadRequestData +${ERROR_TYPE_INVALID_REQUEST} http://uri.etsi.org/ngsi-ld/errors/InvalidRequest +${ERROR_TYPE_RESOURCE_NOT_FOUND} http://uri.etsi.org/ngsi-ld/errors/ResourceNotFound +${ERROR_TYPE_ALREADY_EXISTS} http://uri.etsi.org/ngsi-ld/errors/AlreadyExists +${ERROR_TYPE_LD_CONTEXT_NOT_AVAILABLE} http://uri.etsi.org/ngsi-ld/errors/LDContextNotAvailable ${response} @@ -46,32 +49,34 @@ Delete Entity by Id Output response Query Entity - [Arguments] ${id} ${accept} ${attrs}=${EMPTY} ${context}=${EMPTY} ${geoproperty}=${EMPTY} ${options}=${EMPTY} + [Arguments] ${id} ${accept}=${EMPTY} ${attrs}=${EMPTY} ${context}=${EMPTY} ${geoproperty}=${EMPTY} ${options}=${EMPTY} ${attrs_length} = Get Length ${attrs} + ${accept_length} = Get Length ${accept} ${options_length} = Get Length ${options} &{headers}= Create Dictionary &{params}= Create Dictionary - Set To Dictionary ${headers} Accept ${accept} + Run Keyword If ${accept_length}>0 Set To Dictionary ${headers} Accept ${accept} Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type=${accept} Run Keyword If ${attrs_length}>0 Set To Dictionary ${params} attrs=${attrs} Run Keyword If '${geoproperty}'!='' Set To Dictionary ${params} geoproperty=${geoproperty} Run Keyword If ${options_length}>0 Set To Dictionary ${params} options=${options} ${response}= GET ${ENTITIES_ENDPOINT_PATH}${id} headers=${headers} query=${params} - Output request + ${request}= Output request Output response Set Test Variable ${response} [return] ${response} Query Entities - [Arguments] ${entity_ids}=${EMPTY} ${entity_types}=${EMPTY} ${accept}=${CONTENT_TYPE_LD_JSON} ${attrs}=${EMPTY} ${context}=${EMPTY} ${geoproperty}=${EMPTY} ${options}=${EMPTY} ${limit}=${EMPTY} ${entity_id_pattern}=${EMPTY} + [Arguments] ${entity_ids}=${EMPTY} ${entity_types}=${EMPTY} ${accept}=${EMPTY} ${attrs}=${EMPTY} ${context}=${EMPTY} ${geoproperty}=${EMPTY} ${options}=${EMPTY} ${limit}=${EMPTY} ${entity_id_pattern}=${EMPTY} ${attrs_length} = Get Length ${attrs} + ${accept_length} = Get Length ${accept} ${options_length} = Get Length ${options} ${entity_ids_length} = Get Length ${entity_ids} ${entity_types_length} = Get Length ${entity_types} &{headers}= Create Dictionary &{params}= Create Dictionary - Set To Dictionary ${headers} Accept ${accept} + Run Keyword If ${accept_length}>0 Set To Dictionary ${headers} Accept ${accept} Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type=${accept} Run Keyword If ${attrs_length}>0 Set To Dictionary ${params} attrs=${attrs} Run Keyword If '${geoproperty}'!='' Set To Dictionary ${params} geoproperty=${geoproperty} @@ -116,10 +121,11 @@ Retrieve Entity by Id Set Test Variable ${response} Create Entity Selecting Content Type - [Arguments] ${filename} ${entity_id} ${content_type} ${context}=${EMPTY} + [Arguments] ${filename} ${entity_id} ${content_type} ${context}=${EMPTY} ${accept}=${EMPTY} ${entity_payload}= Load Json From File ${EXECDIR}/data/entities/${filename} ${entity}= Update Value To Json ${entity_payload} $..id ${entity_id} &{headers}= Create Dictionary Content-Type=${content_type} + Run Keyword If '${accept}'!='${EMPTY}' Set To Dictionary ${headers} Accept=${accept} Run Keyword If '${context}'!='${EMPTY}' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" ${response}= POST ${ENTITIES_ENDPOINT_PATH} body=${entity} headers=${headers} ${request}= Output request @@ -178,8 +184,9 @@ Delete Entity Attributes [return] ${response} Partial Update Entity Attributes - [Arguments] ${entityId} ${attributeId} ${fragment_filename} ${content_type} + [Arguments] ${entityId} ${attributeId} ${fragment_filename} ${content_type} ${accept}=${EMPTY} &{headers}= Create Dictionary Content-Type=${content_type} + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} ${fragment_payload}= Load Json From File ${EXECDIR}/data/entities/fragmentEntities/${fragment_filename} ${response}= PATCH ${ENTITIES_ENDPOINT_PATH}${entityId}/attrs/${attributeId} body=${fragment_payload} headers=${headers} Output request @@ -187,22 +194,24 @@ Partial Update Entity Attributes [return] ${response} Retrieve Entity Types - [Arguments] ${context}=${EMPTY} ${details}=${FALSE} + [Arguments] ${context}=${EMPTY} ${details}=${FALSE} ${accept}=${EMPTY} &{headers}= Create Dictionary &{params}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" Run Keyword If ${details} Set To Dictionary ${params} details=${details} - ${response}= GET ${ENTITIES_TYPES_ENDPOINT_PATH} headers=${headers} query=${params} + ${response}= GET ${ENTITIES_TYPES_ENDPOINT_PATH}/ headers=${headers} query=${params} Output request Output response Set Test Variable ${response} Retrieve Entity Type - [Arguments] ${type} ${context}=${EMPTY} + [Arguments] ${type} ${context}=${EMPTY} ${accept}=${EMPTY} &{headers}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" ${response}= GET ${ENTITIES_TYPES_ENDPOINT_PATH}/${type} headers=${headers} Output request @@ -211,10 +220,11 @@ Retrieve Entity Type Set Test Variable ${response} Retrieve Attributes - [Arguments] ${context}=${EMPTY} ${details}=${FALSE} + [Arguments] ${context}=${EMPTY} ${details}=${FALSE} ${accept}=${EMPTY} &{headers}= Create Dictionary &{params}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" Run Keyword If ${details} Set To Dictionary ${params} details=${details} ${response}= GET ${ATTRIBUTES_ENDPOINT_PATH} headers=${headers} query=${params} @@ -224,9 +234,10 @@ Retrieve Attributes Set Test Variable ${response} Retrieve Attribute - [Arguments] ${attribute_name} ${context}=${EMPTY} + [Arguments] ${attribute_name} ${context}=${EMPTY} ${accept}=${EMPTY} &{headers}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" ${response}= GET ${ATTRIBUTES_ENDPOINT_PATH}/${attribute_name} headers=${headers} Output request @@ -235,8 +246,9 @@ Retrieve Attribute Set Test Variable ${response} Create Context Source Registration With Return - [Arguments] ${payload} ${content_type}=${CONTENT_TYPE_LD_JSON} ${context}=${EMPTY} + [Arguments] ${payload} ${content_type}=${CONTENT_TYPE_LD_JSON} ${context}=${EMPTY} ${accept}=${EMPTY} &{headers}= Create Dictionary Content-Type=${content_type} + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept=${context} Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" ${response}= POST ${CONTEXT_SOURCE_REGISTRATION_ENDPOINT_PATH} body=${payload} headers=${headers} ${request}= Output request @@ -253,8 +265,9 @@ Create Context Source Registration Using Session [return] ${response} Update Context Source Registration With Return - [Arguments] ${registration_id} ${fragment} - &{headers}= Create Dictionary Content-Type=application/ld+json + [Arguments] ${registration_id} ${fragment} ${content_type} ${accept}=${EMPTY} + &{headers}= Create Dictionary Content-Type=${content_type} + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept=${accept} ${response}= PATCH ${CONTEXT_SOURCE_REGISTRATION_ENDPOINT_PATH}/${registration_id} body=${fragment} headers=${headers} ${request}= Output request Output response @@ -287,10 +300,11 @@ Create Entity Output response Create Or Update Temporal Representation Of Entity Selecting Content Type - [Arguments] ${temporal_entity_representation_id} ${filename} ${content_type} + [Arguments] ${temporal_entity_representation_id} ${filename} ${content_type} ${accept}=${EMPTY} ${temporal_entity_representation_payload}= Load Json From File ${EXECDIR}/data/temporalEntities/${filename} ${temporal_entity_representation}= Update Value To Json ${temporal_entity_representation_payload} $..id ${temporal_entity_representation_id} &{headers}= Create Dictionary Content-Type=${content_type} + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} ${response}= POST ${TEMPORAL_ENTITIES_ENDPOINT_PATH}/ body=${temporal_entity_representation} headers=${headers} Output request Output response @@ -349,11 +363,18 @@ Delete Temporal Representation Of Entity With Returning Response Output response [return] ${response} +Delete Several Temporal Representations Of Entities + [Arguments] @{temporal_entity_representation_ids} + FOR ${temporal_entity_representation_id} IN @{temporal_entity_representation_ids} + Delete Temporal Representation Of Entity With Returning Response ${temporal_entity_representation_id} + END + Get Temporal Representation Of Entity - [Arguments] ${temporal_entity_representation_id} ${content_type} ${options}=${EMPTY} - &{headers}= Create Dictionary Content-Type=${content_type} + [Arguments] ${temporal_entity_representation_id} ${accept}=${EMPTY} ${options}=${EMPTY} + &{headers}= Create Dictionary &{params}= Create Dictionary ${options_length} = Get Length ${options} + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} Run Keyword If ${options_length}>0 Set To Dictionary ${params} options=${options} ${response}= GET ${TEMPORAL_ENTITIES_ENDPOINT_PATH}/${temporal_entity_representation_id} headers=${headers} query=${params} Output request @@ -367,10 +388,20 @@ Delete Attribute Instance From Temporal Entity Output response [return] ${response} +Update Temporal Representation Of Entity Selecting Content Type + [Arguments] ${temporal_entity_representation_id} ${attrId} ${instanceId} ${fragment_filename} ${content_type} + ${temporal_entity_fragment}= Load Json From File ${EXECDIR}/data/temporalEntities/fragments/${fragment_filename} + &{headers}= Create Dictionary Content-Type=${content_type} + ${response}= PATCH ${TEMPORAL_ENTITIES_ENDPOINT_PATH}/${temporal_entity_representation_id}/attrs/${attrId}/${instanceId} body=${temporal_entity_fragment} headers=${headers} + Output request + Output response + [return] ${response} + Batch Create Entities - [Arguments] @{entities_to_be_created} ${content_type}=${CONTENT_TYPE_LD_JSON} ${context}=${EMPTY} + [Arguments] @{entities_to_be_created} ${content_type}=${CONTENT_TYPE_LD_JSON} ${context}=${EMPTY} ${accept}=${EMPTY} ${headers}= Create Dictionary Set To Dictionary ${headers} Content-Type ${content_type} + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" ${response}= POST ${BATCH_CREATE_ENDPOINT_PATH} body=@{entities_to_be_created} headers=${headers} Output request @@ -429,12 +460,13 @@ Create Temporal Representation Of Entity Output response Retrieve Temporal Representation Of Entity - [Arguments] ${temporal_entity_representation_id} ${attrs}=${EMPTY} ${options}=${EMPTY} ${context}=${EMPTY} ${timerel}=${EMPTY} ${timeAt}=${EMPTY} ${endTimeAt}=${EMPTY} ${lastN}=${EMPTY} + [Arguments] ${temporal_entity_representation_id} ${attrs}=${EMPTY} ${options}=${EMPTY} ${context}=${EMPTY} ${timerel}=${EMPTY} ${timeAt}=${EMPTY} ${endTimeAt}=${EMPTY} ${lastN}=${EMPTY} ${accept}=${EMPTY} ${attrs_length} = Get Length ${attrs} ${options_length} = Get Length ${options} &{headers}= Create Dictionary &{params}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept=${accept} Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" Run Keyword If ${attrs_length}>0 Set To Dictionary ${params} attrs=${attrs} Run Keyword If ${options_length}>0 Set To Dictionary ${params} options=${options} @@ -449,12 +481,13 @@ 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} ${csf}=${EMPTY} ${georel}=${EMPTY} ${geometry}=${EMPTY} ${coordinates}=${EMPTY} ${geoproperty}=${EMPTY} ${timerel}=${EMPTY} ${timeAt}=${EMPTY} ${attrs}=${EMPTY} ${limit}=${EMPTY} ${lastN}=${EMPTY} + [Arguments] ${context}=${EMPTY} ${entity_types}=${EMPTY} ${entity_ids}=${EMPTY} ${entity_id_pattern}=${EMPTY} ${ngsild_query}=${EMPTY} ${csf}=${EMPTY} ${georel}=${EMPTY} ${geometry}=${EMPTY} ${coordinates}=${EMPTY} ${geoproperty}=${EMPTY} ${timerel}=${EMPTY} ${timeAt}=${EMPTY} ${attrs}=${EMPTY} ${limit}=${EMPTY} ${lastN}=${EMPTY} ${accept}=${EMPTY} ${entity_types_length} = Get Length ${entity_types} ${entity_ids_length} = Get Length ${entity_ids} ${attrs_length} = Get Length ${attrs} &{headers}= Create Dictionary &{params}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept=${accept} Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" Run Keyword If ${entity_types_length}>0 Set To Dictionary ${params} type=${entity_types} Run Keyword If ${entity_ids_length}>0 Set To Dictionary ${params} id=${entity_ids} @@ -477,9 +510,9 @@ Query Temporal Representation Of Entities Set Test Variable ${response} Query Temporal Representation Of Entities Via Post - [Arguments] ${query_file_name} + [Arguments] ${query_file_name} ${content_type}=${CONTENT_TYPE_LD_JSON} ${headers}= Create Dictionary - Set To Dictionary ${headers} Content-Type ${CONTENT_TYPE_LD_JSON} + Set To Dictionary ${headers} Content-Type ${content_type} ${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 @@ -514,11 +547,12 @@ Update Context Source Registration Set Test Variable ${response} Query Context Source Registrations - [Arguments] ${context}=${EMPTY} ${id}=${EMPTY} ${type}=${EMPTY} ${attrs}=${EMPTY} ${q}=${EMPTY} ${georel}=${EMPTY} ${geometry}=${EMPTY} ${coordinates}=${EMPTY} ${geoproperty}=${EMPTY} ${timeproperty}=${EMPTY} ${timerel}=${EMPTY} ${timeAt}=${EMPTY} ${limit}=${EMPTY} ${page}=${EMPTY} + [Arguments] ${context}=${EMPTY} ${id}=${EMPTY} ${type}=${EMPTY} ${attrs}=${EMPTY} ${q}=${EMPTY} ${georel}=${EMPTY} ${geometry}=${EMPTY} ${coordinates}=${EMPTY} ${geoproperty}=${EMPTY} ${timeproperty}=${EMPTY} ${timerel}=${EMPTY} ${timeAt}=${EMPTY} ${limit}=${EMPTY} ${page}=${EMPTY} ${accept}=${EMPTY} &{headers}= Create Dictionary &{params}= Create Dictionary Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} accept=${accept} Run Keyword If '${id}'!='' Set To Dictionary ${params} id=${id} Run Keyword If '${type}'!='' Set To Dictionary ${params} type=${type} Run Keyword If '${attrs}'!='' Set To Dictionary ${params} attrs=${attrs} @@ -549,9 +583,10 @@ Delete Context Source Registration Set Suite Variable ${response} Retrieve Context Source Registration - [Arguments] ${context_source_registration_id} ${context}=${EMPTY} + [Arguments] ${context_source_registration_id} ${context}=${EMPTY} ${accept}=${EMPTY} &{headers}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept=${accept} Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" ${response}= GET ${CONTEXT_SOURCE_REGISTRATION_ENDPOINT_PATH}/${context_source_registration_id} headers=${headers} Output request @@ -560,9 +595,10 @@ Retrieve Context Source Registration Set Test Variable ${response} Create Context Source Registration Subscription - [Arguments] ${subscription_payload} + [Arguments] ${subscription_payload} ${accept}=${EMPTY} ${content_type}=${CONTENT_TYPE_LD_JSON} - &{headers}= Create Dictionary Content-Type=application/ld+json + &{headers}= Create Dictionary Content-Type=${content_type} + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} ${response}= POST ${CONTEXT_SOURCE_REGISTRATION_SUBSCRIPTION_ENDPOINT_PATH} body=${subscription_payload} headers=${headers} ${request}= Output request Output response @@ -592,10 +628,11 @@ Retrieve Context Source Registration Subscription Set Test Variable ${response} Query Context Source Registration Subscriptions - [Arguments] ${context}=${EMPTY} ${limit}=${EMPTY} ${page}=${EMPTY} + [Arguments] ${context}=${EMPTY} ${limit}=${EMPTY} ${page}=${EMPTY} ${accept}=${EMPTY} &{headers}= Create Dictionary &{params}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept=${accept} Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" Run Keyword If '${limit}'!='' Set To Dictionary ${params} limit=${limit} Run Keyword If '${page}'!='' Set To Dictionary ${params} page=${page} @@ -621,3 +658,187 @@ Update Context Source Registration Subscription From File Create Session CsrsUpdateRequest ${url} ${response}= PATCH On Session CsrsUpdateRequest ${CONTEXT_SOURCE_REGISTRATION_SUBSCRIPTION_ENDPOINT_PATH}/${subscription_id} data=${file_content} expected_status=any Set Test Variable ${response} + +Create Subscription + [Arguments] ${subscription_id} ${filename_path} ${content_type} ${accept}=${EMPTY} + &{headers}= Create Dictionary Content-Type=${content_type} + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} + ${subscription_payload}= Load Json From File ${EXECDIR}/data/${filename_path} + ${subscription}= Update Value To Json ${subscription_payload} $..id ${subscription_id} + ${response}= POST ${SUBSCRIPTION_ENDPOINT_PATH} body=${subscription} headers=${headers} + Output request + Output response + [return] ${response} + +Update Subscription + [Arguments] ${subscription_id} ${fragment_filename} ${content_type} ${accept}=${EMPTY} + &{headers}= Create Dictionary Content-Type=${content_type} + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} + ${subscription_update_fragment}= Load Json From File ${EXECDIR}/data/${fragment_filename} + ${response}= PATCH ${SUBSCRIPTION_ENDPOINT_PATH}${subscription_id} body=${subscription_update_fragment} headers=${headers} + Output request + Output response + [return] ${response} + +Delete Subscription + [Arguments] ${subscription_id} + ${response}= DELETE ${SUBSCRIPTION_ENDPOINT_PATH}${subscription_id} + Output request + Output response + [return] ${response} + +Query Subscriptions + [Arguments] ${limit}=${EMPTY} ${accept}=${EMPTY} + &{headers}= Create Dictionary + &{params}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} + Run Keyword If '${limit}'!='' Set To Dictionary ${params} limit=${limit} + + ${response}= GET ${SUBSCRIPTION_ENDPOINT_PATH} headers=${headers} query=${params} + Output request + Output response + [return] ${response} + +Retrieve Subscription + [Arguments] ${id} ${accept}=${EMPTY} + &{headers}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} + + ${response}= GET ${SUBSCRIPTION_ENDPOINT_PATH}${id} headers=${headers} + ${request}= Output request + Output response + [return] ${request} ${response} + +Update Context Source Registration Subscription By Selecting Content Type + [Arguments] ${subscription_id} ${subscription_update_fragment} ${content_type} ${accept}=${EMPTY} + &{headers}= Create Dictionary Content-Type=${content_type} + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} + ${response}= PATCH ${CONTEXT_SOURCE_REGISTRATION_SUBSCRIPTION_ENDPOINT_PATH}/${subscription_id} body=${subscription_update_fragment} headers=${headers} + Output request + Output response + [return] ${response} + +Retrieve Entity Types With Return + [Arguments] ${accept}=${EMPTY} + &{headers}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} + ${response}= GET ${ENTITIES_TYPES_ENDPOINT_PATH} headers=${headers} + Output request + Output response + [return] ${response} + +Retrieve Entity Type With Return + [Arguments] ${type} ${accept}=${EMPTY} + &{headers}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} + ${response}= GET ${ENTITIES_TYPES_ENDPOINT_PATH}/${type} headers=${headers} + Output request + Output response + [return] ${response} + +Retrieve Attributes With Return + [Arguments] ${accept}=${EMPTY} + &{headers}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} + ${response}= GET ${ATTRIBUTES_ENDPOINT_PATH} headers=${headers} + Output request + Output response + [return] ${response} + +Retrieve Attribute With Return + [Arguments] ${attribute_name} ${accept}=${EMPTY} + &{headers}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} + ${response}= GET ${ATTRIBUTES_ENDPOINT_PATH}/${attribute_name} headers=${headers} + Output request + Output response + [return] ${response} + +Create Context Source Registration Subscription With Return + [Arguments] ${subscription_payload} ${content_type} + &{headers}= Create Dictionary Content-Type=${content_type} + ${response}= POST ${CONTEXT_SOURCE_REGISTRATION_SUBSCRIPTION_ENDPOINT_PATH} body=${subscription_payload} headers=${headers} + ${request}= Output request + Output ${response} + [return] ${request} ${response} + +Batch Upsert Entities By Selecting Content Type + [Arguments] @{entities_to_be_upserted} ${content_type}=${CONTENT_TYPE_LD_JSON} ${update_option}=replace + &{headers}= Create Dictionary Content-Type=${content_type} + ${response}= POST ${BATCH_UPSERT_ENDPOINT_PATH}?options=${update_option} body=@{entities_to_be_upserted} headers=${headers} + Output request + Output response + Set Test Variable ${response} + +Batch Update Entities By Selecting Content Type + [Arguments] @{entities_to_be_updated} ${content_type}=${CONTENT_TYPE_LD_JSON} ${overwrite_option}=overwrite + &{headers}= Create Dictionary Content-Type=${content_type} + ${response}= POST ${BATCH_UPDATE_ENDPOINT_PATH}?options=${overwrite_option} body=@{entities_to_be_updated} headers=${headers} + Output request + Output response + Set Test Variable ${response} + +Batch Delete Entities By Selecting Content Type + [Arguments] @{entities_ids_to_be_deleted} ${content_type}=${CONTENT_TYPE_LD_JSON} ${teardown}=False + &{headers}= Create Dictionary Content-Type=${content_type} + ${response}= POST ${BATCH_DELETE_ENDPOINT_PATH} body=@{entities_ids_to_be_deleted} headers=${headers} + Output request + Output response + Run Keyword If not ${teardown} Set Test Variable ${response} + Set Test Variable ${response} + +Query Context Source Registrations With Return + [Arguments] ${context}=${EMPTY} ${id}=${EMPTY} ${type}=${EMPTY} ${attrs}=${EMPTY} ${q}=${EMPTY} ${georel}=${EMPTY} ${geometry}=${EMPTY} ${coordinates}=${EMPTY} ${geoproperty}=${EMPTY} ${timeproperty}=${EMPTY} ${timerel}=${EMPTY} ${timeAt}=${EMPTY} ${limit}=${EMPTY} ${page}=${EMPTY} ${accept}=${EMPTY} + + &{headers}= Create Dictionary + &{params}= Create Dictionary + Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} accept=${accept} + Run Keyword If '${id}'!='' Set To Dictionary ${params} id=${id} + Run Keyword If '${type}'!='' Set To Dictionary ${params} type=${type} + Run Keyword If '${attrs}'!='' Set To Dictionary ${params} attrs=${attrs} + Run Keyword If '${q}'!='' Set To Dictionary ${params} q=${q} + Run Keyword If '${georel}'!='' Set To Dictionary ${params} georel=${georel} + 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 '${timeproperty}'!='' Set To Dictionary ${params} timeproperty=${timeproperty} + Run Keyword If '${timerel}'!='' Set To Dictionary ${params} timerel=${timerel} + Run Keyword If '${timeAt}'!='' Set To Dictionary ${params} timeAt=${timeAt} + Run Keyword If '${limit}'!='' Set To Dictionary ${params} limit=${limit} + Run Keyword If '${page}'!='' Set To Dictionary ${params} page=${page} + + ${response}= GET ${CONTEXT_SOURCE_REGISTRATION_ENDPOINT_PATH} headers=${headers} query=${params} + ${request}= Output request + Output response + + [return] ${request} ${response} + +Query Temporal Representation Of Entities With Return + [Arguments] ${context}=${EMPTY} ${entity_types}=${EMPTY} ${entity_ids}=${EMPTY} ${entity_id_pattern}=${EMPTY} ${ngsild_query}=${EMPTY} ${csf}=${EMPTY} ${georel}=${EMPTY} ${geometry}=${EMPTY} ${coordinates}=${EMPTY} ${geoproperty}=${EMPTY} ${timerel}=${EMPTY} ${timeAt}=${EMPTY} ${attrs}=${EMPTY} ${limit}=${EMPTY} ${lastN}=${EMPTY} ${accept}=${EMPTY} + ${entity_types_length} = Get Length ${entity_types} + ${entity_ids_length} = Get Length ${entity_ids} + ${attrs_length} = Get Length ${attrs} + &{headers}= Create Dictionary + &{params}= Create Dictionary + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept=${accept} + Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" + Run Keyword If ${entity_types_length}>0 Set To Dictionary ${params} type=${entity_types} + Run Keyword If ${entity_ids_length}>0 Set To Dictionary ${params} id=${entity_ids} + Run Keyword If '${timerel}'!='' Set To Dictionary ${params} timerel=${timerel} + Run Keyword If '${timeAt}'!='' Set To Dictionary ${params} timeAt=${timeAt} + Run Keyword If ${attrs_length}>0 Set To Dictionary ${params} attrs=${attrs} + Run Keyword If '${lastN}'!='' Set To Dictionary ${params} lastN=${lastN} + Run Keyword If '${entity_id_pattern}'!='' Set To Dictionary ${params} idPattern=${entity_id_pattern} + Run Keyword If '${ngsild_query}'!='' Set To Dictionary ${params} q=${ngsild_query} + Run Keyword If '${csf}'!='' Set To Dictionary ${params} csf=${csf} + Run Keyword If '${georel}'!='' Set To Dictionary ${params} georel=${georel} + 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} + ${request}= Output request + Output response + [return] ${request} ${response} \ No newline at end of file diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 261fcd303f271905875fe22290fc5ebf13b2f9d7..0fc84a3f4224d4af65e2f375abea009c5e876018 100755 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -40,6 +40,12 @@ Check Response Body Content ${comparison_result}= Compare Dictionaries Ignoring Keys ${response_body} ${entity_payload} ${instance_id_regex_expr} Should Be True ${comparison_result} msg=Entity Comparison Failed +Check Request Containing Accept Header Set To + [Arguments] ${request} ${expected_accept_content} + + Run Keyword If 'Accept' in ${request['headers']} Should Be Equal ${expected_accept_content} ${request['headers']['Accept']} ignore_order=True + Run Keyword If 'accept' in ${request['headers']} Should Be Equal ${expected_accept_content} ${request['headers']['accept']} ignore_order=True + # Since Http headers names are case-insensitive (from Http specification) # We check both Location and location headers Check Response Headers Containing URI set to @@ -286,6 +292,19 @@ Check Pagination Prev And Next Headers Run Keyword If '${prev_link}'!='' and '${next_link}'=='' Should Be Equal ${response['headers']['Link']} ${prev_link} Run Keyword If '${prev_link}'=='' and '${next_link}'!='' Should Be Equal ${response['headers']['Link']} ${next_link} +Check Response Body Containing One Subscription element + [Arguments] ${expectation_filename} ${response_body} + ${payload}= Load Json From File ${EXECDIR}/data/csourceSubscriptions/expectations/${expectation_filename} + ${subscription}= Update Value To Json ${payload} $..id ${response_body['id']} + ${comparison_result}= Compare Dictionaries Ignoring Keys ${response_body} ${subscription} ${instance_id_regex_expr} + Should Be True ${comparison_result} msg=Entity Comparison Failed + +Check Response Body Containing One Registration element + [Arguments] ${expectation_filename} ${response_body} + ${payload}= Load Json From File ${EXECDIR}/data/csourceRegistrations/expectations/${expectation_filename} + ${registration}= Update Value To Json ${payload} $..id ${response_body['id']} + ${comparison_result}= Compare Dictionaries Ignoring Keys ${response_body} ${registration} ${instance_id_regex_expr} + Should Be True ${comparison_result} msg=Entity Comparison Failed Check Resource Set To [Arguments] ${resource} ${ignored_keys}=${None} ${error_message}=${EMPTY}