Skip to content
Commits on Source (23)
......@@ -2,22 +2,22 @@ Copyright 2021 ETSI
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
*** Settings ***
Documentation Check that you can query several entities based on scopes
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Suite Setup Setup Initial Entities
Suite Teardown Delete Entities
Test Template Query several entities based on scopes
*** Variables ***
${building_id_prefix}= urn:ngsi-ld:Building:
${entity_one_scope}= building-minimal-with-one-scope.json
${entity_many_scopes}= building-minimal-with-many-scopes.json
${entity_type}= https://ngsi-ld-test-suite/context#Building
*** Test Cases *** SCOPEQ EXPECTED_COUNT
019_01_06 QueryWithFullScope
[Tags] e-query 4_19 since_v1.5.1
/Madrid/Gardens/ParqueNorte ${2}
019_01_06 QueryWithPlusMatching
[Tags] e-query 4_19 since_v1.5.1
/Madrid/+/ParqueNorte ${2}
019_01_06 QueryWithHashMatching
[Tags] e-query 4_19 since_v1.5.1
/CompanyA/# ${1}
019_01_06 QueryNonEmptyScope
[Tags] e-query 4_19 since_v1.5.1
/# ${2}
019_01_06 QueryWithAndScope
[Tags] e-query 4_19 since_v1.5.1
/Madrid/Gardens/ParqueNorte;/CompanyA/OrganizationB/UnitC ${1}
019_01_06 QueryWithOrScope
[Tags] e-query 4_19 since_v1.5.1
/Madrid/Gardens/ParqueNorte,/CompanyA/OrganizationB/UnitC ${2}
*** Keywords ***
Query several entities based on scopes
[Documentation] Check that you can query several entities based on scopes
[Arguments] ${scopeq} ${expected_count}
${response}= Query Entities
... scopeq=${scopeq}
... entity_types=${entity_type}
Check Response Status Code 200 ${response.status_code}
Check Response Body Containing Number Of Entities ${entity_type} ${expected_count} ${response.json()}
Setup Initial Entities
${entity_one_scope_id}= Generate Random Entity Id ${building_id_prefix}
Set Suite Variable ${entity_one_scope_id}
Create Entity Selecting Content Type
... ${entity_one_scope}
... ${entity_one_scope_id}
... ${CONTENT_TYPE_JSON}
... ${ngsild_test_suite_context}
${entity_many_scopes_id}= Generate Random Entity Id ${building_id_prefix}
Set Suite Variable ${entity_many_scopes_id}
Create Entity Selecting Content Type
... ${entity_many_scopes}
... ${entity_many_scopes_id}
... ${CONTENT_TYPE_JSON}
... ${ngsild_test_suite_context}
Delete Entities
Delete Entity by Id ${entity_one_scope_id}
Delete Entity by Id ${entity_many_scopes_id}
*** Settings ***
Documentation Query entities with Entity Type Selection Language.
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Suite Setup Setup Initial Entities
Suite Teardown Delete Initial Entities
Test Template Query entities using Entity Type Selection Language
*** Variables ***
${entity_id_prefix} urn:ngsi-ld:MultiTypes:
${first_entity_filename} building-simple-attributes-sample.jsonld
${second_entity_filename} building-with-different-type-sample.jsonld
${third_entity_filename} building-with-two-types-sample.jsonld
${building_entity_type} Building
${parking_entity_type} Parking
${tourist_destination_entity_type} TouristDestination
*** Test Cases *** ENTITY_TYPES_SELECTION EXPECTED_ENTITIES_IDS
019_08_01 query with one type ${building_entity_type} ${first_entity_id},${third_entity_id}
019_08_02 query with the AND operator (${building_entity_type};${tourist_destination_entity_type}) ${third_entity_id}
019_08_03 query with the OR operator ${building_entity_type},${parking_entity_type} ${first_entity_id},${second_entity_id},${third_entity_id}
019_08_04 different query with the OR operator ${parking_entity_type},${tourist_destination_entity_type} ${second_entity_id},${third_entity_id}
019_08_05 query with two operators (${building_entity_type};${parking_entity_type}),${tourist_destination_entity_type} ${third_entity_id}
*** Keywords ***
Query entities using Entity Type Selection Language
[Documentation] Query entities with Entity Type Selection Language.
[Tags] e-query 4_17 5_7_2 since_v1.5.1
[Arguments] ${entity_types_selection} ${expected_entities_ids}
${entities_ids}= Split String ${expected_entities_ids} ,
@{entities_ids_list}= Create List ${entities_ids}
${response}= Query Entities
... entity_types=${entity_types_selection}
... context=${ngsild_test_suite_context}
Check Response Status Code 200 ${response.status_code}
Check Response Body Containing Entities URIS set to
... @{entities_ids_list}
... ${response.json()}
Setup Initial Entities
${first_entity_id}= Generate Random Entity Id ${entity_id_prefix}
Set Suite Variable ${first_entity_id}
${create_response1}= Create Entity Selecting Content Type
... ${first_entity_filename}
... ${first_entity_id}
... ${CONTENT_TYPE_LD_JSON}
Check Response Status Code 201 ${create_response1.status_code}
${second_entity_id}= Generate Random Entity Id ${entity_id_prefix}
Set Suite Variable ${second_entity_id}
${create_response2}= Create Entity Selecting Content Type
... ${second_entity_filename}
... ${second_entity_id}
... ${CONTENT_TYPE_LD_JSON}
Check Response Status Code 201 ${create_response2.status_code}
${third_entity_id}= Generate Random Entity Id ${entity_id_prefix}
Set Suite Variable ${third_entity_id}
${create_response3}= Create Entity Selecting Content Type
... ${third_entity_filename}
... ${third_entity_id}
... ${CONTENT_TYPE_LD_JSON}
Check Response Status Code 201 ${create_response3.status_code}
Delete Initial Entities
Delete Entity by Id ${first_entity_id}
Delete Entity by Id ${second_entity_id}
Delete Entity by Id ${third_entity_id}
*** Settings ***
Documentation Check that you can retrieve an entity using Language Filter
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Suite Setup Create Initial Entity
Suite Teardown Delete Created Entity
Test Template Retrieve Entity With Language Filter
*** Variables ***
${building_id_prefix}= urn:ngsi-ld:Building:
${filename}= building-language-property-sample.jsonld
*** Test Cases *** LANGUAGE_FILTER OPTIONS EXPECTATION_FILENAME
018_07_01 Retrieve an entity using a specific natural language
[Tags] e-retrieve 5_7_1 4_15 since_v1.4.1
fr ${EMPTY} building-language-property-fr-filter.jsonld
018_07_02 Retrieve an entity using multiple natural languages with no ranked preference
[Tags] e-retrieve 5_7_1 4_15 since_v1.4.1
fr-CH,fr ${EMPTY} building-language-property-fr-filter.jsonld
018_07_03 Retrieve an entity with any supported language
[Tags] e-retrieve 5_7_1 4_15 since_v1.4.1
* ${EMPTY} building-language-property-any-language-filter.jsonld
018_07_04 Retrieve an entity using multiple natural languages with ranked preferences
[Tags] e-retrieve 5_7_1 4_15 since_v1.4.1
fr-CH,fr;q=0.9,en;q=0.8,*;q=0.5 ${EMPTY} building-language-property-fr-filter.jsonld
018_07_05 Retrieve an entity using a specific natural language with simplified representation
[Tags] e-retrieve 5_7_1 4_15 since_v1.4.1
fr keyValues building-language-property-fr-filter-simplified.jsonld
018_07_06 Retrieve an entity with any supported language with simplified representation
[Tags] e-retrieve 5_7_1 4_15 since_v1.4.1
* keyValues building-language-property-any-language-filter-simplified.jsonld
*** Keywords ***
Retrieve Entity With Language Filter
[Documentation] Check that you can retrieve an entity using Language Filter
[Arguments] ${language_filter} ${options} ${expectation_filename}
${response}= Query Entity
... id=${entity_id}
... accept=${CONTENT_TYPE_LD_JSON}
... context=${ngsild_test_suite_context}
... options=${options}
... lang=${language_filter}
Check Response Status Code 200 ${response.status_code}
Check Response Body Containing Entity element
... ${expectation_filename}
... ${entity_id}
... ${response.json()}
... ${True}
Create Initial Entity
${entity_id}= Generate Random Entity Id ${building_id_prefix}
Set Suite Variable ${entity_id}
${response}= Create Entity Selecting Content Type
... ${filename}
... ${entity_id}
... ${CONTENT_TYPE_LD_JSON}
Check Response Status Code 201 ${response.status_code}
Delete Created Entity
Delete Entity by Id ${entity_id}
*** Settings ***
Documentation Check that you can retrieve the temporal evolution of an entity with the aggregated temporal representation
Resource ${EXECDIR}/resources/ApiUtils/TemporalContextInformationConsumption.resource
Resource ${EXECDIR}/resources/ApiUtils/TemporalContextInformationProvision.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Suite Setup Create Temporal Entity
Suite Teardown Delete Initial Temporal Entity
Test Template Retrieve the temporal evolution of an entity with the aggregated temporal representation
*** Variables ***
${vehicule_id_prefix}= urn:ngsi-ld:Vehicle:
${vehicle_payload_file}= 2020-08-vehicule-temporal-representation-sample.jsonld
*** Test Cases *** AGGRMETHODS AGGRPERIODDURATION ATTRS VEHICLE_EXPECTATION_FILE
020_11_01 One aggregate method aggregated by one hour duration
[Tags] te-retrieve 5_7_3 4_5_19 since_v1.4.1
avg PT1H ${EMPTY} vehicle-temporal-representation-020-11-01-expectation.json
020_11_02 One aggregate method aggregated by one hour duration asking for one attribute
[Tags] te-retrieve 5_7_3 4_5_19 since_v1.4.1
avg PT1H fuelLevel vehicle-temporal-representation-020-11-02-expectation.json
020_11_03 Multiple aggregate methods aggregated by one hour duration
[Tags] te-retrieve 5_7_3 4_5_19 since_v1.4.1
avg,max PT1H ${EMPTY} vehicle-temporal-representation-020-11-03-expectation.json
020_11_04 Multiple aggregate methods aggregated by one day duration
[Tags] te-retrieve 5_7_3 4_5_19 since_v1.4.1
min,max P1D ${EMPTY} vehicle-temporal-representation-020-11-04-expectation.json
*** Keywords ***
Retrieve the temporal evolution of an entity with the aggregated temporal representation
[Documentation] Check that you can retrieve the temporal evolution of an entity with the aggregated temporal representation
[Arguments] ${aggrmethods} ${aggrperiodduration} ${attrs} ${vehicle_expectation_file}
@{options}= Create List aggregatedValues
${response}= Retrieve Temporal Representation Of Entity
... temporal_entity_representation_id=${temporal_entity_representation_id}
... attrs=${attrs}
... options=${options}
... aggrMethods=${aggrmethods}
... aggrPeriodDuration=${aggrperiodduration}
... context=${ngsild_test_suite_context}
Check Response Status Code 200 ${response.status_code}
Check Response Body Containing EntityTemporal element
... ${vehicle_expectation_file}
... ${temporal_entity_representation_id}
... ${response.json()}
Create Temporal Entity
${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 Temporal Entity
Delete Temporal Representation Of Entity ${temporal_entity_representation_id}
*** Settings ***
Documentation Check that you can retrieve the temporal evolution of an entity with a LanguageProperty property
Resource ${EXECDIR}/resources/ApiUtils/TemporalContextInformationConsumption.resource
Resource ${EXECDIR}/resources/ApiUtils/TemporalContextInformationProvision.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Suite Setup Create Temporal Entity
Suite Teardown Delete Initial Temporal Entity
Test Template Retrieve Temporal Entity
*** Variables ***
${vehicule_id_prefix}= urn:ngsi-ld:Vehicle:
${vehicle_payload_file}= vehicle-language-property-temporal-representation-sample.jsonld
*** Test Cases *** REPRESENTATION EXPECTATION_FILENAME
020_12_01 Retrieve the normalized temporal representation of an entity with a LanguageProperty property
[Tags] te-retrieve 5_7_3 4_5_7 4_5_18 since_v1.4.1
${EMPTY} vehicle-language-property-normalized-temporal-representation-expectation.jsonld
020_12_02 Retrieve the simplified temporal representation of an entity with a LanguageProperty property
[Tags] te-retrieve 5_7_3 4_5_9 4_5_18 since_v1.4.1
temporalValues vehicle-language-property-simplified-temporal-representation-expectation.jsonld
*** Keywords ***
Retrieve Temporal Entity
[Documentation] Check that you can retrieve the temporal evolution of an entity with a LanguageProperty property
[Arguments] ${representation} ${expectation_filename}
${response}= Retrieve Temporal Representation Of Entity
... temporal_entity_representation_id=${temporal_entity_representation_id}
... options=${representation}
... context=${ngsild_test_suite_context}
Check Response Status Code 200 ${response.status_code}
Check Response Body Containing EntityTemporal element
... ${expectation_filename}
... ${temporal_entity_representation_id}
... ${response.json()}
Create Temporal Entity
${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 Temporal Entity
Delete Temporal Representation Of Entity ${temporal_entity_representation_id}
*** Settings ***
Documentation Check that you can create a batch of entities where two have the same id
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Test Teardown Delete Entities
*** Variables ***
${building_id_prefix}= urn:ngsi-ld:Building:
*** Test Cases ***
003_10_01 Create a batch of three valid entities where two have the same id
[Documentation] Check that you can create a batch of entities where two have the same id
[Tags] be-create 5_6_7 since_v1.5.1
${first_entity_id}= Generate Random Entity Id ${building_id_prefix}
Set Suite Variable ${first_entity_id}
${second_entity_id}= Generate Random Entity Id ${building_id_prefix}
Set Suite Variable ${second_entity_id}
${first_entity}= Load Entity building-minimal-sample.jsonld ${first_entity_id}
${second_entity}= Load Entity building-minimal-sample.jsonld ${second_entity_id}
@{entities_to_be_created}= Create List ${first_entity} ${second_entity} ${first_entity}
${response}= Batch Create Entities @{entities_to_be_created}
@{expected_successful_entities_ids}= Create List ${first_entity_id} ${second_entity_id}
Set Test Variable @{expected_successful_entities_ids}
@{expected_failed_entities_ids}= Create List ${first_entity_id}
&{expected_batch_operation_result}= Create Batch Operation Result
... ${expected_successful_entities_ids}
... ${expected_failed_entities_ids}
Check Response Status Code 207 ${response.status_code}
Check Response Body Containing Batch Operation Result ${expected_batch_operation_result} ${response.json()}
*** Keywords ***
Delete Entities
${response}= Batch Delete Entities
... entities_ids_to_be_deleted=@{expected_successful_entities_ids}
*** Settings ***
Documentation Check that you can delete a batch of entities with the same id
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Test Setup Setup Initial Entity
*** Variables ***
${building_id_prefix}= urn:ngsi-ld:Building:
*** Test Cases ***
006_04_01 Delete a batch of existing entities with the same id
[Documentation] Check that you can delete a batch entities with the same id
[Tags] be-delete 5_6_10 since_v1.5.1
${new_entity_id}= Generate Random Entity Id ${building_id_prefix}
@{entities_ids_to_be_deleted}= Create List ${entity_id} ${entity_id}
${response}= Batch Delete Entities entities_ids_to_be_deleted=@{entities_ids_to_be_deleted}
@{expected_successful_entities_ids}= Create List ${entity_id}
@{expected_failed_entities_ids}= Create List ${entity_id}
&{response1}= Create Batch Operation Result
... ${expected_successful_entities_ids}
... ${expected_failed_entities_ids}
Check Response Status Code 207 ${response.status_code}
Check Response Body Containing Batch Operation Result ${response1} ${response.json()}
*** Keywords ***
Setup Initial Entity
${entity_id}= Generate Random Entity Id ${building_id_prefix}
Create Entity building-simple-attributes-sample.jsonld ${entity_id}
Set Test Variable ${entity_id}
*** Settings ***
Documentation Check that you can upsert a batch of entities where two have the same id
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Test Teardown Delete Entities
*** Variables ***
${building_id_prefix}= urn:ngsi-ld:Building:
*** Test Cases ***
004_07_01 Upsert a batch of three valid entities where two have the same id
[Documentation] Check that you can upsert a batch of where two have the same id
[Tags] be-upsert 5_6_8 since_v1.5.1
${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-minimal-sample.jsonld ${first_entity_id}
${second_entity}= Load Entity building-minimal-sample.jsonld ${second_entity_id}
@{entities_to_be_upserted}= Create List ${first_entity} ${second_entity} ${first_entity}
${response}= Batch Upsert Entities @{entities_to_be_upserted}
@{expected_successful_entities_ids}= Create List ${first_entity_id} ${second_entity_id}
Set Test Variable @{expected_successful_entities_ids}
Check Response Status Code 201 ${response.status_code}
Check Response Body Containing Array Of URIs set to ${expected_successful_entities_ids} ${response.json()}
*** Keywords ***
Delete Entities
${response}= Batch Delete Entities
... entities_ids_to_be_deleted=@{expected_successful_entities_ids}
......@@ -17,7 +17,7 @@ ${building_id_prefix}= urn:ngsi-ld:Building:
*** Test Cases *** FILENAME CONTENT_TYPE
001_01_01 MinimalEntity
[Tags] e-create 5_6_1
building-minimal-without-context-sample.jsonld application/json
building-minimal-sample.json application/json
001_01_02 EntityWithSimpleProperties
[Tags] e-create 5_6_1
building-simple-attributes-sample.jsonld application/ld+json
......
......@@ -16,7 +16,7 @@ Test Template Create Entity With Invalid Request Scenarios
empty-sample.jsonld ${ERROR_TYPE_INVALID_REQUEST}
001_02_03 EntityWithNoContext
[Tags] e-create 5_6_1
building-minimal-without-context-sample.jsonld ${ERROR_TYPE_BAD_REQUEST_DATA}
building-minimal-sample.json ${ERROR_TYPE_BAD_REQUEST_DATA}
*** Keywords ***
......
*** Settings ***
Documentation Check that you can create an entity with a LanguageProperty property
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Test Teardown Delete Initial Entity
Test Template Create Entity Scenarios
*** Variables ***
${building_id_prefix}= urn:ngsi-ld:Building:
*** Test Cases *** FILENAME CONTENT_TYPE
001_10_01 EntityWithLanguageProperty
[Tags] e-create 5_6_1 4_5_18 since_v1.4.1
building-language-property-sample.jsonld application/ld+json
*** Keywords ***
Create Entity Scenarios
[Documentation] Check that you can create an entity with a LanguageProperty property
[Arguments] ${filename} ${content_type}
${entity_id}= Generate Random Entity Id ${building_id_prefix}
Set Test Variable ${entity_id}
${response}= Create Entity Selecting Content Type
... ${filename}
... ${entity_id}
... ${content_type}
Check Response Status Code 201 ${response.status_code}
Check Response Headers Containing URI set to ${entity_id} ${response.headers}
${created_entity}= Load Test Sample entities/${filename} ${entity_id}
${response1}= Retrieve Entity by Id
... id=${entity_id}
... accept=${content_type}
... context=${ngsild_test_suite_context}
Check Created Resource Set To
... created_resource=${created_entity}
... response_body=${response1.json()}
Delete Initial Entity
Delete Entity by Id ${entity_id}
*** Settings ***
Documentation Check that you can create an entity with one or more scopes
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Test Teardown Delete Initial Entity
Test Template Create Entity Scenarios
*** Variables ***
${building_id_prefix}= urn:ngsi-ld:Building:
*** Test Cases *** FILENAME CONTENT_TYPE
001_11_01 EntityWithOneScope
[Tags] e-create 4_18 since_v1.5.1
building-minimal-with-one-scope.json application/json
001_11_02 EntityWithManyScopes
[Tags] e-create 4_18 since_v1.5.1
building-minimal-with-many-scopes.json application/json
*** Keywords ***
Create Entity Scenarios
[Documentation] Check that you can create an entity with one or more scopes
[Arguments] ${filename} ${content_type}
${entity_id}= Generate Random Entity Id ${building_id_prefix}
Set Test Variable ${entity_id}
${response}= Create Entity Selecting Content Type
... ${filename}
... ${entity_id}
... ${content_type}
Check Response Status Code 201 ${response.status_code}
Check Response Headers Containing URI set to ${entity_id} ${response.headers}
${created_entity}= Load Test Sample entities/${filename} ${entity_id}
${response1}= Retrieve Entity by Id ${entity_id} ${content_type}
Check Created Resource Set To ${created_entity} ${response1.json()}
Delete Initial Entity
Delete Entity by Id ${entity_id}
......@@ -18,15 +18,16 @@ ${filename}= vehicle-speed-two-datasetid-sample.jsonld
*** Test Cases *** STATUS_CODE FRAGMENT_FILENAME EXPECTATION_FILENAME
010_01_01 Append entity attributes
[Tags] ea-append 5_6_3
204 vehicle-new-attribute-fragment.jsonld vehicle-speed-appended-expectation.jsonld
010_01_02 Append entity attributes with different datasetid
[Tags] ea-append 5_6_3
204 vehicle-speed-different-datasetid-fragment.jsonld vehicle-speed-different-datasetid-expectation.jsonld
*** Keywords ***
Append Attributes Without Params
[Documentation] Check that you can append entity attributes
[Tags] ea-append 5_6_3
[Arguments] ${status_code} ${fragment_filename} ${expectation_filename}
${response}= Append Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON}
Check Response Status Code ${status_code} ${response.status_code}
......
*** Settings ***
Documentation Check that you can append a LanguageProperty property to an entity
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Test Setup Create Initial Entity
Test Teardown Delete Initial Entity
Test Template Append Attributes Without Params
*** Variables ***
${vehicle_id_prefix}= urn:ngsi-ld:Vehicle:
${filename}= vehicle-speed-two-datasetid-sample.jsonld
*** Test Cases *** STATUS_CODE FRAGMENT_FILENAME EXPECTATION_FILENAME
010_06_01 Append a LanguageProperty property
[Tags] ea-append 5_6_3 4_5_18 since_v1.4.1
204 vehicle-new-language-property-fragment.jsonld vehicle-language-property-appended-expectation.jsonld
*** Keywords ***
Append Attributes Without Params
[Documentation] Check that you can append a LanguageProperty property to an entity
[Arguments] ${status_code} ${fragment_filename} ${expectation_filename}
${response}= Append Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON}
Check Response Status Code ${status_code} ${response.status_code}
${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id}
${response1}= Retrieve Entity by Id
... id=${entity_id}
... context=${ngsild_test_suite_context}
... accept=${CONTENT_TYPE_LD_JSON}
Check Updated Resource Set To ${entity_expectation_payload} ${response1.json()}
Create Initial Entity
${entity_id}= Generate Random Entity Id ${vehicle_id_prefix}
${response}= Create Entity Selecting Content Type
... ${filename}
... ${entity_id}
... ${CONTENT_TYPE_LD_JSON}
Check Response Status Code 201 ${response.status_code}
Set Suite Variable ${entity_id}
Delete Initial Entity
Delete Entity by Id ${entity_id}
*** Settings ***
Documentation Check that you can append a scope to an entity
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Test Setup Create Initial Entity
Test Teardown Delete Initial Entity
*** Variables ***
${vehicle_id_prefix}= urn:ngsi-ld:Vehicle:
${filename}= building-minimal-with-one-scope.json
${scope_fragment_filename}= one-scope-fragment.json
*** Test Cases ***
010_07_01 Append scope to an entity with overwrite enabled
[Documentation] Check that scope is replaced if overwrite is enabled
[Tags] ea-append 5_6_3 4_18 since_v1.5.1
${response}= Append Entity Attributes
... ${entity_id}
... ${scope_fragment_filename}
... ${CONTENT_TYPE_JSON}
Check Response Status Code 204 ${response.status_code}
${expectation_filename}= Set Variable building-minimal-with-one-scope-expectation.json
${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id}
${response}= Retrieve Entity by Id
... ${entity_id}
... accept=${CONTENT_TYPE_JSON}
... context=${ngsild_test_suite_context}
Check Updated Resource Set To ${entity_expectation_payload} ${response.json()}
010_07_01 Append scope to an entity with overwrite disabled
[Documentation] Check that scope is appended if overwrite is disabled
[Tags] ea-append 5_6_3 4_18 since_v1.5.1
${response}= Append Entity Attributes With Parameters
... ${entity_id}
... ${scope_fragment_filename}
... ${CONTENT_TYPE_JSON}
... noOverwrite
Check Response Status Code 204 ${response.status_code}
${expectation_filename}= Set Variable building-minimal-with-two-scopes-expectation.json
${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id}
${response}= Retrieve Entity by Id
... ${entity_id}
... accept=${CONTENT_TYPE_JSON}
... context=${ngsild_test_suite_context}
Check Updated Resource Set To ${entity_expectation_payload} ${response.json()}
*** Keywords ***
Create Initial Entity
${entity_id}= Generate Random Entity Id ${vehicle_id_prefix}
Set Test Variable ${entity_id}
${response}= Create Entity Selecting Content Type
... ${filename}
... ${entity_id}
... ${CONTENT_TYPE_JSON}
... ${ngsild_test_suite_context}
Check Response Status Code 201 ${response.status_code}
Delete Initial Entity
Delete Entity by Id ${entity_id}
*** Settings ***
Documentation Check that you can delete a scope from an entity
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Test Setup Create Initial Entity
Test Teardown Delete Initial Entity
*** Variables ***
${vehicle_id_prefix}= urn:ngsi-ld:Vehicle:
${filename}= building-minimal-with-one-scope.json
${expectation_filename}= building-minimal-compacted-expectation.json
*** Test Cases ***
013_04 Delete scope from an entity
[Documentation] Check that you can delete a scope from an entity
[Tags] ea-delete 5_6_5 4_18 since_v1.5.1
${response}= Delete Entity Attributes
... ${entity_id}
... scope
... ${EMPTY}
... false
Check Response Status Code 204 ${response.status_code}
${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id}
${response}= Retrieve Entity by Id
... ${entity_id}
... accept=${CONTENT_TYPE_JSON}
Check Updated Resource Set To ${entity_expectation_payload} ${response.json()}
*** Keywords ***
Create Initial Entity
${entity_id}= Generate Random Entity Id ${vehicle_id_prefix}
Set Test Variable ${entity_id}
${response}= Create Entity Selecting Content Type
... ${filename}
... ${entity_id}
... ${CONTENT_TYPE_JSON}
Check Response Status Code 201 ${response.status_code}
Delete Initial Entity
Delete Entity by Id ${entity_id}
*** Settings ***
Documentation Check that you can perform a partial update on a LanguageProperty property
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Test Setup Initiate Test Case
Test Teardown Delete Initial Entities
Test Template Update Attributes
*** Variables ***
${vehicle_id_prefix}= urn:ngsi-ld:Building:
${filename}= building-language-property-sub-property-sample.jsonld
${status_code}= 204
*** Test Cases *** FRAGMENT_FILENAME ATTRIBUTE_ID EXPECTATION_FILENAME
012_04_01 Check that you can partially update a LanguageProperty property
[Tags] ea-partial-update 5_6_4 4_5_18 since_v1.4.1
building-language-property-fragment.jsonld street building-language-property-update-expectation.jsonld
*** Keywords ***
Update Attributes
[Documentation] Check that you can perform a partial update on a LanguageProperty property
[Arguments] ${fragment_filename} ${attribute_id} ${expectation_filename}
${response}= Partial Update Entity Attributes
... entityId=${entity_id}
... attributeId=${attribute_id}
... fragment_filename=${fragment_filename}
... content_type=${CONTENT_TYPE_LD_JSON}
Check Response Status Code ${status_code} ${response.status_code}
${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id}
${response1}= Retrieve Entity by Id
... id=${entity_id}
... context=${ngsild_test_suite_context}
... accept=${CONTENT_TYPE_LD_JSON}
${ignored_attributes}= Create List @context
Check Updated Resource Set To ${entity_expectation_payload} ${response1.json()} ${ignored_attributes}
Initiate Test Case
${entity_id}= Generate Random Entity Id ${vehicle_id_prefix}
Set Test Variable ${entity_id}
${response}= Create Entity Selecting Content Type
... ${filename}
... ${entity_id}
... ${CONTENT_TYPE_LD_JSON}
Check Response Status Code 201 ${response.status_code}
Delete Initial Entities
Delete Entity by Id ${entity_id}
*** Settings ***
Documentation Check that you can update a scope in an entity
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Test Teardown Delete Initial Entity
*** Variables ***
${vehicle_id_prefix}= urn:ngsi-ld:Vehicle:
${scope_fragment_filename}= one-scope-fragment.json
*** Test Cases ***
011_05_01 Update scope to an entity already having a scope
[Documentation] Check that scope is replaced if entity already has a scope
[Tags] ea-append 5_6_2 4_18 since_v1.5.1
[Setup] Create Initial Entity building-minimal-with-one-scope.json
${response}= Update Entity Attributes
... ${entity_id}
... ${scope_fragment_filename}
... ${CONTENT_TYPE_JSON}
Check Response Status Code 204 ${response.status_code}
${expectation_filename}= Set Variable building-minimal-with-one-scope-expectation.json
${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id}
${response}= Retrieve Entity by Id
... ${entity_id}
... accept=${CONTENT_TYPE_JSON}
... context=${ngsild_test_suite_context}
Check Updated Resource Set To ${entity_expectation_payload} ${response.json()}
011_05_02 Update scope to an entity not having a scope
[Documentation] Check that scope is not added if entity does not already have a scope
[Tags] ea-append 5_6_2 4_18 since_v1.5.1
[Setup] Create Initial Entity building-minimal-sample.json
${response}= Update Entity Attributes
... ${entity_id}
... ${scope_fragment_filename}
... ${CONTENT_TYPE_JSON}
Check Response Status Code 207 ${response.status_code}
${expectation_filename}= Set Variable building-minimal-compacted-expectation.json
${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id}
${response}= Retrieve Entity by Id
... ${entity_id}
... accept=${CONTENT_TYPE_JSON}
... context=${ngsild_test_suite_context}
Check Updated Resource Set To ${entity_expectation_payload} ${response.json()}
*** Keywords ***
Create Initial Entity
[Arguments] ${filename}
${entity_id}= Generate Random Entity Id ${vehicle_id_prefix}
Set Test Variable ${entity_id}
${response}= Create Entity Selecting Content Type
... ${filename}
... ${entity_id}
... ${CONTENT_TYPE_JSON}
... ${ngsild_test_suite_context}
Check Response Status Code 201 ${response.status_code}
Delete Initial Entity
Delete Entity by Id ${entity_id}
*** Settings ***
Documentation If a subscription defines an entity type selection query, a notification shall be sent whenever an entity matches the query.
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Resource ${EXECDIR}/resources/NotificationUtils.resource
Suite Setup Before Test
Suite Teardown After Test
*** Variables ***
${subscription_id_prefix}= urn:ngsi-ld:Subscription:
${subscription_payload_file_path}= subscriptions/subscription-building-entities-type-selection.jsonld
${building_id_prefix}= urn:ngsi-ld:Building:
${notification_server_send_url}= http://${notification_server_host}:${notification_server_port}/notify
${entity_building_filepath}= building-simple-attributes-sample.jsonld
${content_type}= application/ld+json
*** Test Cases ***
046_16_01 Check that a notification is sent with entity matching the entity type selection
[Documentation] If a subscription defines an entity type selection query, a notification shall be sent whenever an entity matches the query.
[Tags] sub-notification 5_8_6 since_v1.5.1
${entity_id}= Generate Random Entity Id ${building_id_prefix}
${response}= Create Entity Selecting Content Type
... ${entity_building_filepath}
... ${entity_id}
... ${content_type}
Set Suite Variable ${entity_id}
${notification} ${headers}= Wait for notification timeout=${5}
Should be Equal ${subscription_id} ${notification}[subscriptionId]
Dictionary Should Contain Key ${notification} data
Should Not Be Empty ${notification}[data] Notification data should not be empty
Should be Equal ${entity_id} ${notification}[data][0][id]
*** Keywords ***
Setup Initial Subscription
${subscription_id}= Generate Random Entity Id ${subscription_id_prefix}
${subscription_payload}= Load Subscription Sample With Reachable Endpoint
... ${subscription_payload_file_path}
... ${subscription_id}
... ${notification_server_send_url}
Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON}
Set Suite Variable ${subscription_id}
Before Test
Start Local Server ${notification_server_host} ${notification_server_port}
Sleep 1s
Setup Initial Subscription
After Test
Delete Subscription ${subscription_id}
Delete Entity by Id ${entity_id}
Stop Local Server