diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_07.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_07.robot new file mode 100644 index 0000000000000000000000000000000000000000..e69cddcee236731d8665b89ae9ecad9589edcf43 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_07.robot @@ -0,0 +1,68 @@ +*** Settings *** +Documentation Check that one can query entities via POST based on q + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Suite Teardown Delete Entities +Test Template Query entities via POST based on q + + +*** Test Cases *** Q EXPECTED_COUNT +019_02_07_01 QueryOnNameEquality + [Tags] e-query 5_7_2 + name=="Eiffel Tower" 1 +019_02_07_02 QueryOnNameEqualityAndBoolean + [Tags] e-query 5_7_2 + name=="Pisa Tower";almostFull==false 1 +019_02_07_03 QueryOnNameEqualityOrBoolean + [Tags] e-query 5_7_2 + name=="Pisa Tower"|almostFull==false 3 + + +*** Keywords *** +Query entities via POST based on q + [Documentation] Check that one can query entities via POST based on q + [Arguments] ${q} ${expected_count} + + ${response}= Query Entities Via POST + ... q=${q} + ... count=true + ... context=${ngsild_test_suite_context} + + Check Response Status Code 200 ${response.status_code} + Check Response Headers Containing NGSILD-Results-Count Equals To ${expected_count} ${response.headers} + +Setup Initial Entities + ${first_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${first_entity_id} + ${create_response1}= Create Entity Selecting Content Type + ... building-simple-attributes.jsonld + ... ${first_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response1.status_code} + + ${second_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${second_entity_id} + ${create_response2}= Create Entity Selecting Content Type + ... building-simple-attributes-second.jsonld + ... ${second_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response2.status_code} + + ${third_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${third_entity_id} + ${create_response3}= Create Entity Selecting Content Type + ... building-simple-attributes-third.jsonld + ... ${third_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response3.status_code} + +Delete Entities + Delete Entity ${first_entity_id} + Delete Entity ${second_entity_id} + Delete Entity ${third_entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_08.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_08.robot new file mode 100644 index 0000000000000000000000000000000000000000..136ef2e8941a902330dbc8ed8903185d9ea5f37d --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_08.robot @@ -0,0 +1,67 @@ +*** Settings *** +Documentation Check that one can query entities via POST based on q on a JsonProperty + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Suite Teardown Delete Entities +Test Template Query entities via POST based on q on a JsonProperty + + +*** Test Cases *** Q JSON_KEYS EXPECTED_COUNT +019_02_08_01 QueryOnNameEquality + [Tags] e-query 5_7_2 4_5_24 since_v1.8.1 + jsonProperty[id]=="some-id" jsonProperty 1 +019_02_08_02 QueryOnJsonPropertyTypeEqual + [Tags] e-query 5_7_2 4_5_24 since_v1.8.1 + jsonProperty[type]=="some-type" jsonProperty 2 +019_02_08_03 QueryOnJsonPropertyIdNoMatch + [Tags] e-query 5_7_2 4_5_24 since_v1.8.1 + jsonProperty[id]=="wrong-id" jsonProperty 0 +019_02_08_04 QueryOnJsonPropertyIdUnequal + [Tags] e-query 5_7_2 4_5_24 since_v1.8.1 + jsonProperty[id]!="wrong-id" jsonProperty 2 +019_02_08_05 QueryOnJsonPropertyUnmatchedJsonKeys + [Tags] e-query 5_7_2 4_5_24 since_v1.8.1 + jsonProperty[id]=="some-id" anotherProperty 0 + + +*** Keywords *** +Query entities via POST based on q on a JsonProperty + [Documentation] Check that one can query entities via POST based on q on a JsonProperty + [Arguments] ${q} ${json_keys} ${expected_count} + + @{json_keys_list}= Create List ${json_keys} + ${response}= Query Entities Via POST + ... q=${q} + ... jsonKeys=@{json_keys_list} + ... count=true + ... context=${ngsild_test_suite_context} + + Check Response Status Code 200 ${response.status_code} + Check Response Headers Containing NGSILD-Results-Count Equals To ${expected_count} ${response.headers} + +Setup Initial Entities + ${first_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${first_entity_id} + ${create_response}= Create Entity Selecting Content Type + ... building-json-property-object.jsonld + ... ${first_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response.status_code} + + ${second_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${second_entity_id} + ${create_response}= Create Entity Selecting Content Type + ... building-json-property-object-second.jsonld + ... ${second_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response.status_code} + +Delete Entities + Delete Entity ${first_entity_id} + Delete Entity ${second_entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_09.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_09.robot new file mode 100644 index 0000000000000000000000000000000000000000..5ebbc05e19d0f459ca764b3cced468a63f431a40 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_09.robot @@ -0,0 +1,84 @@ +*** Settings *** +Documentation Check that one can query entities via POST based on q on a VocabProperty + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Suite Teardown Delete Entities +Test Template Query entities via POST based on q on a VocabProperty + + +*** Variables *** +# "monument" and "sightseeing" are not in the test suite @context, so they expand via the default namespace +${MONUMENT_URI} https://uri.etsi.org/ngsi-ld/default-context/monument +${SIGHTSEEING_URI} https://uri.etsi.org/ngsi-ld/default-context/sightseeing + + +*** Test Cases *** Q EXPAND_VALUES EXPECTED_COUNT +# first entity: vocabProperty = "monument" (string) +# second entity: vocabProperty = ["monument", "sightseeing"] (array) +019_02_09_01 QueryWithExpandValuesEqualMonument + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty==monument vocabProperty 2 +019_02_09_02 QueryWithExpandValuesEqualSightseeing + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty==sightseeing vocabProperty 1 +019_02_09_03 QueryWithExpandValuesUnequalSightseeing + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty!=monument vocabProperty 1 +019_02_09_04 QueryWithUriMonument + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty=="${MONUMENT_URI}" ${EMPTY} 2 +019_02_09_05 QueryWithUriSightseeing + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty=="${SIGHTSEEING_URI}" ${EMPTY} 1 +019_02_09_06 QueryWithExpandValuesValueListEqual + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty==monument,sightseeing vocabProperty 2 +019_02_09_07 QueryWithExpandValuesValueListUnequal + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty!=monument,sightseeing vocabProperty 0 +019_02_09_08 QueryWithUriValueList + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty=="${MONUMENT_URI}","${SIGHTSEEING_URI}" ${EMPTY} 2 + + +*** Keywords *** +Query entities via POST based on q on a VocabProperty + [Documentation] Check that one can query entities based on q on a VocabProperty + [Arguments] ${q} ${expand_values} ${expected_count} + + @{expand_values_list}= Create List ${expand_values} + ${response}= Query Entities Via POST + ... q=${q} + ... expandValues=${expand_values_list} + ... count=true + ... context=${ngsild_test_suite_context} + + Check Response Status Code 200 ${response.status_code} + Check Response Headers Containing NGSILD-Results-Count Equals To ${expected_count} ${response.headers} + +Setup Initial Entities + ${first_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${first_entity_id} + ${create_response1}= Create Entity Selecting Content Type + ... building-vocab-property-string.jsonld + ... ${first_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response1.status_code} + + ${second_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${second_entity_id} + ${create_response2}= Create Entity Selecting Content Type + ... building-vocab-property-array.jsonld + ... ${second_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response2.status_code} + +Delete Entities + Delete Entity ${first_entity_id} + Delete Entity ${second_entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_06.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_06.robot new file mode 100644 index 0000000000000000000000000000000000000000..8388c36b9a94e566fe39a8f63f917b38e9943122 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_06.robot @@ -0,0 +1,49 @@ +*** Settings *** +Documentation Check that one cannot query entities if the q parameter is syntactically invalid + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Template Query entities with invalid q + + +*** Test Cases *** Q +019_03_06_01 QueryWithOperatorMissingValue + [Tags] e-query 5_7_2 + attr== +019_03_06_02 QueryWithUnclosedBracket + [Tags] e-query 5_7_2 + attr[ +019_03_06_03 QueryWithInvalidSingleExclamationOperator + [Tags] e-query 5_7_2 + attr!value +019_03_06_04 QueryStartingWithLogicalOperator + [Tags] e-query 5_7_2 + ;attr=="value" +019_03_06_05 QueryWithConsecutiveLogicalOperators + [Tags] e-query 5_7_2 + attr=="value";;attr2=="value2" +019_03_06_06 QueryWithInvertedRegexOperator + [Tags] e-query 5_7_2 + attr=~"value*" +019_03_06_07 QueryWithUnknownOperator + [Tags] e-query 5_7_2 + attr="value" + + +*** Keywords *** +Query entities with invalid q + [Documentation] Check that a BadRequestData error is returned when q is syntactically invalid + [Arguments] ${q} + + ${response}= Query Entities + ... q=${q} + ... context=${ngsild_test_suite_context} + + Check Response Status Code 400 ${response.status_code} + Check Response Body Containing ProblemDetails Element Containing Type Element set to + ... ${response.json()} + ... ${ERROR_TYPE_BAD_REQUEST_DATA} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response.json()} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_09.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_09.robot index 8e446776353bca65ff5caf494a707def8a9a0c52..ba0076422822a58922db9faaa654180d4c494831 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_09.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_09.robot @@ -47,6 +47,39 @@ ${entity_type}= https://ngsi-ld-test-suite/context#Building 019_09_10 QueryOnLocatedInTwoCities [Tags] e-query 5_7_2 locatedIn==urn:ngsi-ld:City:Pisa|locatedIn==urn:ngsi-ld:City:Paris 1 +019_09_11 QueryOnNameUnequal + [Tags] e-query 5_7_2 + name!="Eiffel Tower" 2 +019_09_12 QueryOnAirQualityLevelUnequal + [Tags] e-query 5_7_2 + airQualityLevel!=4 2 +019_09_13 QueryOnExistenceOfAttribute + [Tags] e-query 5_7_2 + locatedIn 1 +019_09_14 QueryOnSubAttributeObservedAt + [Tags] e-query 5_7_2 + airQualityLevel.observedAt>="2021-01-01T00:00:00Z" 1 +019_09_15 QueryOnAirQualityLevelValueListEqual + [Tags] e-query 5_7_2 + airQualityLevel==4,6 2 +019_09_16 QueryOnAirQualityLevelValueListUnequal + [Tags] e-query 5_7_2 + airQualityLevel!=4,6 1 +019_09_17 QueryOnAirQualityLevelRangeEqual + [Tags] e-query 5_7_2 + airQualityLevel==5..7 2 +019_09_18 QueryOnAirQualityLevelRangeUnequal + [Tags] e-query 5_7_2 + airQualityLevel!=5..7 1 +019_09_19 QueryOnNameMatchPattern + [Tags] e-query 5_7_2 + name~=Eiffel.* 1 +019_09_20 QueryOnNameMatchPatternAllTowers + [Tags] e-query 5_7_2 + name~=.*Tower 3 +019_09_21 QueryOnNameNotMatchPattern + [Tags] e-query 5_7_2 + name!~=Pisa.* 1 *** Keywords *** diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_26.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_26.robot new file mode 100644 index 0000000000000000000000000000000000000000..1148d4b579b2d633ce00d4f5eb4a1a1f183947f0 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_26.robot @@ -0,0 +1,70 @@ +*** Settings *** +Documentation Check that one can query entities based on q on a LanguageProperty + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Suite Teardown Delete Entities +Test Template Query entities based on q on a LanguageProperty + + +*** Test Cases *** Q EXPECTED_COUNT +# first entity: street { fr: "Grand Place", nl: "Grote Markt" } +# second entity: street { fr: "Grande Place", nl: "Grote Markt" } +019_26_01 QueryOnSpecificLanguageFrEqual + [Tags] e-query 5_7_2 4_5_18 since_v1.6.1 + street[fr]=="Grand Place" 1 +019_26_02 QueryOnSpecificLanguageFrWrongValue + [Tags] e-query 5_7_2 4_5_18 since_v1.6.1 + street[fr]=="Grote Markt" 0 +019_26_03 QueryOnWildcardLanguageEqualFrValue + [Tags] e-query 5_7_2 4_5_18 since_v1.6.1 + street[*]=="Grand Place" 1 +019_26_04 QueryOnSpecificLanguageFrUnequal + [Tags] e-query 5_7_2 4_5_18 since_v1.6.1 + street[fr]!="Grote Markt" 2 +019_26_05 QueryOnWildcardLanguageUnequalAbsentValue + [Tags] e-query 5_7_2 4_5_18 since_v1.6.1 + street[*]!="SomeOtherValue" 2 +019_26_06 QueryOnWildcardLanguageMatchPatternFrValue + [Tags] e-query 5_7_2 4_5_18 since_v1.6.1 + street[*]~=".*Place" 2 + + +*** Keywords *** +Query entities based on q on a LanguageProperty + [Documentation] Check that one can query entities based on q on a LanguageProperty + [Arguments] ${q} ${expected_count} + + ${response}= Query Entities + ... q=${q} + ... count=true + ... context=${ngsild_test_suite_context} + + Check Response Status Code 200 ${response.status_code} + Check Response Headers Containing NGSILD-Results-Count Equals To ${expected_count} ${response.headers} + +Setup Initial Entities + ${first_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${first_entity_id} + ${create_response}= Create Entity Selecting Content Type + ... building-language-property.jsonld + ... ${first_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response.status_code} + + ${second_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${second_entity_id} + ${create_response}= Create Entity Selecting Content Type + ... building-language-property-second.jsonld + ... ${second_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response.status_code} + +Delete Entities + Delete Entity ${first_entity_id} + Delete Entity ${second_entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_27.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_27.robot new file mode 100644 index 0000000000000000000000000000000000000000..a3e1dd0b0ac0e214d3766c561a684683752ceffc --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_27.robot @@ -0,0 +1,70 @@ +*** Settings *** +Documentation Check that one can query entities based on q on a JsonProperty + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Suite Teardown Delete Entities +Test Template Query entities based on q on a JsonProperty + + +*** Test Cases *** Q JSON_KEYS EXPECTED_COUNT +# first entity: +# jsonProperty { type: JsonProperty, json: { id: "some-id", type: "some-type", null: null, anythingElse: "anything-else" } } +# second entity: +# jsonProperty { type: JsonProperty, json: { id: "another-id", type: "some-type" } } +019_27_01 QueryOnJsonPropertyIdEqual + [Tags] e-query 5_7_2 4_5_24 since_v1.8.1 + jsonProperty[id]=="some-id" jsonProperty 1 +019_27_02 QueryOnJsonPropertyTypeEqual + [Tags] e-query 5_7_2 4_5_24 since_v1.8.1 + jsonProperty[type]=="some-type" jsonProperty 2 +019_27_03 QueryOnJsonPropertyIdNoMatch + [Tags] e-query 5_7_2 4_5_24 since_v1.8.1 + jsonProperty[id]=="wrong-id" jsonProperty 0 +019_27_04 QueryOnJsonPropertyIdUnequal + [Tags] e-query 5_7_2 4_5_24 since_v1.8.1 + jsonProperty[id]!="wrong-id" jsonProperty 2 +019_27_05 QueryOnJsonPropertyUnmatchedJsonKeys + [Tags] e-query 5_7_2 4_5_24 since_v1.8.1 + jsonProperty[id]=="some-id" anotherProperty 0 + + +*** Keywords *** +Query entities based on q on a JsonProperty + [Documentation] Check that one can query entities based on q on a JsonProperty + [Arguments] ${q} ${json_keys} ${expected_count} + + ${response}= Query Entities + ... q=${q} + ... jsonKeys=${json_keys} + ... count=true + ... context=${ngsild_test_suite_context} + + Check Response Status Code 200 ${response.status_code} + Check Response Headers Containing NGSILD-Results-Count Equals To ${expected_count} ${response.headers} + +Setup Initial Entities + ${first_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${first_entity_id} + ${create_response}= Create Entity Selecting Content Type + ... building-json-property-object.jsonld + ... ${first_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response.status_code} + + ${second_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${second_entity_id} + ${create_response}= Create Entity Selecting Content Type + ... building-json-property-object-second.jsonld + ... ${second_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response.status_code} + +Delete Entities + Delete Entity ${first_entity_id} + Delete Entity ${second_entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_28.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_28.robot new file mode 100644 index 0000000000000000000000000000000000000000..b5d8580e22aea42252dac678d0d07248dffc821b --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_28.robot @@ -0,0 +1,83 @@ +*** Settings *** +Documentation Check that one can query entities based on q on a VocabProperty + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Suite Teardown Delete Entities +Test Template Query entities based on q on a VocabProperty + + +*** Variables *** +# "monument" and "sightseeing" are not in the test suite @context, so they expand via the default namespace +${MONUMENT_URI}= https://uri.etsi.org/ngsi-ld/default-context/monument +${SIGHTSEEING_URI}= https://uri.etsi.org/ngsi-ld/default-context/sightseeing + + +*** Test Cases *** Q EXPAND_VALUES EXPECTED_COUNT +# first entity: vocabProperty = "monument" (string) +# second entity: vocabProperty = ["monument", "sightseeing"] (array) +019_28_01 QueryWithExpandValuesEqualMonument + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty==monument vocabProperty 2 +019_28_02 QueryWithExpandValuesEqualSightseeing + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty==sightseeing vocabProperty 1 +019_28_03 QueryWithExpandValuesUnequalSightseeing + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty!=monument vocabProperty 1 +019_28_04 QueryWithUriMonument + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty=="${MONUMENT_URI}" ${EMPTY} 2 +019_28_05 QueryWithUriSightseeing + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty=="${SIGHTSEEING_URI}" ${EMPTY} 1 +019_28_06 QueryWithExpandValuesValueListEqual + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty==monument,sightseeing vocabProperty 2 +019_28_07 QueryWithExpandValuesValueListUnequal + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty!=monument,sightseeing vocabProperty 0 +019_28_08 QueryWithUriValueList + [Tags] e-query 5_7_2 4_5_20 since_v1.7.1 + vocabProperty=="${MONUMENT_URI}","${SIGHTSEEING_URI}" ${EMPTY} 2 + + +*** Keywords *** +Query entities based on q on a VocabProperty + [Documentation] Check that one can query entities based on q on a VocabProperty + [Arguments] ${q} ${expand_values} ${expected_count} + + ${response}= Query Entities + ... q=${q} + ... expandValues=${expand_values} + ... count=true + ... context=${ngsild_test_suite_context} + + Check Response Status Code 200 ${response.status_code} + Check Response Headers Containing NGSILD-Results-Count Equals To ${expected_count} ${response.headers} + +Setup Initial Entities + ${first_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${first_entity_id} + ${create_response1}= Create Entity Selecting Content Type + ... building-vocab-property-string.jsonld + ... ${first_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response1.status_code} + + ${second_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${second_entity_id} + ${create_response2}= Create Entity Selecting Content Type + ... building-vocab-property-array.jsonld + ... ${second_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response2.status_code} + +Delete Entities + Delete Entity ${first_entity_id} + Delete Entity ${second_entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_29.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_29.robot new file mode 100644 index 0000000000000000000000000000000000000000..0dfce6b991502751886de1c0fdd3dd2056843e0e --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_29.robot @@ -0,0 +1,80 @@ +*** Settings *** +Documentation Check that one can query entities based on q on the value of a Property being a JSON object + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Suite Teardown Delete Entities +Test Template Query entities based on q on a compound Property value + + +*** Test Cases *** Q EXPECTED_COUNT +# first entity: +# address { type: Property, value: { city: "Berlin", street: "Ulrich Strasse" } } +# sensor { type: Property, value: 40, rawData: { type: Property, value: { particulate: 40, PM20: 85 } } } +# second entity: +# address { type: Property, value: { city: "Nantes", street: "Route de Saint Luce" } } +# sensor { type: Property, value: 50, rawData: { type: Property, value: { particulate: 52, PM20: 90 } } } +019_29_01 QueryOnAddressCityEqual + [Tags] e-query 5_7_2 + address[city]=="Berlin" 1 +019_29_02 QueryOnAddressCityUnequal + [Tags] e-query 5_7_2 + address[city]!="Paris" 2 +019_29_03 QueryOnAddressCityNoMatch + [Tags] e-query 5_7_2 + address[city]=="Paris" 0 +019_29_04 QueryOnAddressCityInListOfValues + [Tags] e-query 5_7_2 + address[city]=="Paris","Nantes" 1 +019_29_05 QueryOnSensorRawDataParticulateEqual + [Tags] e-query 5_7_2 + sensor.rawData[particulate]==40 1 +019_29_06 QueryOnSensorRawDataParticulateNoMatch + [Tags] e-query 5_7_2 + sensor.rawData[particulate]==99 0 +019_29_07 QueryOnSensorRawDataParticulateRange + [Tags] e-query 5_7_2 + sensor.rawData[particulate]==40..60 2 +019_29_08 QueryOnSensorRawDataParticulateListOfValues + [Tags] e-query 5_7_2 + sensor.rawData[particulate]==40,50,52 2 + + +*** Keywords *** +Query entities based on q on a compound Property value + [Documentation] Check that one can query entities based on q on a Property whose value is a JSON object + [Arguments] ${q} ${expected_count} + + ${response}= Query Entities + ... q=${q} + ... count=true + ... context=${ngsild_test_suite_context} + + Check Response Status Code 200 ${response.status_code} + Check Response Headers Containing NGSILD-Results-Count Equals To ${expected_count} ${response.headers} + +Setup Initial Entities + ${first_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${first_entity_id} + ${create_response}= Create Entity Selecting Content Type + ... building-property-json-object.jsonld + ... ${first_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response.status_code} + + ${second_entity_id}= Generate Random Building Entity Id + Set Suite Variable ${second_entity_id} + ${create_response}= Create Entity Selecting Content Type + ... building-property-json-object-second.jsonld + ... ${second_entity_id} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${create_response.status_code} + +Delete Entities + Delete Entity ${first_entity_id} + Delete Entity ${second_entity_id} diff --git a/data/entities/building-json-property-object-second.jsonld b/data/entities/building-json-property-object-second.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..4ce6fc3eacd306adececb1ede9f18ad239fd57f2 --- /dev/null +++ b/data/entities/building-json-property-object-second.jsonld @@ -0,0 +1,14 @@ +{ + "id": "urn:ngsi-ld:Building:randomUUID", + "type": "Building", + "jsonProperty": { + "type": "JsonProperty", + "json": { + "id": "another-id", + "type": "some-type" + } + }, + "@context": [ + "https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld" + ] +} \ No newline at end of file diff --git a/data/entities/building-language-property-second.jsonld b/data/entities/building-language-property-second.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..020a8b123655a1cd99c9dd7cd79c25bad5613674 --- /dev/null +++ b/data/entities/building-language-property-second.jsonld @@ -0,0 +1,14 @@ +{ + "id": "urn:ngsi-ld:Building:randomUUID", + "type": "Building", + "street": { + "type": "LanguageProperty", + "languageMap": { + "fr": "Grande Place", + "nl": "Grote Markt" + } + }, + "@context": [ + "https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld" + ] +} \ No newline at end of file diff --git a/data/entities/building-property-json-object-second.jsonld b/data/entities/building-property-json-object-second.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..60657a5db0b681f7d30fb4f2a5d52e37a809822f --- /dev/null +++ b/data/entities/building-property-json-object-second.jsonld @@ -0,0 +1,25 @@ +{ + "id": "urn:ngsi-ld:Building:randomUUID", + "type": "Building", + "address": { + "type": "Property", + "value": { + "city": "Nantes", + "street": "Route de Saint Luce" + } + }, + "sensor": { + "type": "Property", + "value": 50, + "rawData": { + "type": "Property", + "value": { + "particulate": 52, + "PM20": 90 + } + } + }, + "@context": [ + "https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld" + ] +} diff --git a/data/entities/building-property-json-object.jsonld b/data/entities/building-property-json-object.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..0f4e15965b30e40049993b7e7c81c97cac2eccd7 --- /dev/null +++ b/data/entities/building-property-json-object.jsonld @@ -0,0 +1,25 @@ +{ + "id": "urn:ngsi-ld:Building:randomUUID", + "type": "Building", + "address": { + "type": "Property", + "value": { + "city": "Berlin", + "street": "Ulrich Strasse" + } + }, + "sensor": { + "type": "Property", + "value": 40, + "rawData": { + "type": "Property", + "value": { + "particulate": 40, + "PM20": 85 + } + } + }, + "@context": [ + "https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld" + ] +} diff --git a/doc/analysis/requests.py b/doc/analysis/requests.py index 00c9c054f8f4567ab54d9559c1b2c52087f212ee..e7200f353bade350ab709d12986345d8ef0989d6 100644 --- a/doc/analysis/requests.py +++ b/doc/analysis/requests.py @@ -96,16 +96,15 @@ class Requests: }, 'Query Entities': { 'positions': [], - 'params': ['entity_ids', 'entity_types', 'accept', - 'attrs', 'context', 'geoproperty', - 'options', 'limit', 'entity_id_pattern', - 'scopeq', 'georel', 'coordinates', 'geometry', 'count', 'q', 'datasetId', - 'join', 'joinLevel', 'pick', 'omit', 'orderBy', 'local'] + 'params': ['entity_ids', 'entity_types', 'accept', 'attrs', 'context', 'geoproperty', 'options', + 'limit', 'entity_id_pattern', 'scopeq', 'georel', 'coordinates', 'geometry', 'count', 'q', + 'datasetId', 'join', 'joinLevel', 'pick', 'omit', 'orderBy', 'jsonKeys', 'expandValues', + 'local'] }, 'Query Entities Via POST': { 'positions': [], - 'params': ['entities', 'content_type', 'accept', - 'context', 'attrs', 'geometry_property', 'join', 'joinLevel', 'options', 'local'] + 'params': ['entities', 'content_type', 'accept', 'context', 'attrs', 'geometry_property', + 'join', 'joinLevel', 'options', 'q', 'jsonKeys', 'expandValues', 'count', 'local'] }, 'Retrieve Temporal Representation Of Entity': { 'positions': [], @@ -1366,11 +1365,10 @@ class Requests: @staticmethod def query_entities(kwargs) -> str: - expected_parameters = ['entity_ids', 'entity_types', 'accept', - 'attrs', 'context', 'geoproperty', - 'options', 'limit', 'entity_id_pattern', - 'scopeq', 'georel', 'coordinates', 'geometry', 'count' , 'q' , 'datasetId', - 'join', 'joinLevel', 'pick', 'omit', 'local', 'orderBy', 'local'] + expected_parameters = ['entity_ids', 'entity_types', 'accept', 'attrs', 'context', 'geoproperty', 'options', + 'limit', 'entity_id_pattern', 'scopeq', 'georel', 'coordinates', 'geometry', 'count', + 'q' , 'datasetId', 'join', 'joinLevel', 'pick', 'omit', 'local', 'orderBy', 'jsonKeys', + 'expandValues', 'local'] result = [x for x in kwargs if x not in expected_parameters] response = "Get Entities Request:" @@ -1421,6 +1419,10 @@ class Requests: response = f"{response} and\n Query Parameter: local set to '{value}'" case 'orderBy': response = f"{response} and\n Query Parameter: orderBy set to '{value}'" + case 'jsonKeys': + response = f"{response} and\n Query Parameter: jsonKeys set to '{value}'" + case 'expandValues': + response = f"{response} and\n Query Parameter: expandValues set to '{value}'" case _: raise Exception(f"ERROR: unexpected attribute(s) {result}, the attributes expected are " f"{expected_parameters}, but received: {kwargs}") @@ -1429,7 +1431,7 @@ class Requests: def query_entities_via_post(kwargs) -> str: expected_parameters = ['entities', 'content_type', 'accept', 'attrs', 'geometry_property', 'join', - 'joinLevel', 'options', 'local'] + 'joinLevel', 'options', 'q', 'jsonKeys', 'expandValues', 'count', 'local'] if 'content_type' not in kwargs: kwargs['content_type'] = 'application/json' @@ -1461,6 +1463,14 @@ class Requests: response = f"{response} and\n Query Parameter: options set to '{value}'" case 'local': response = f"{response} and\n Query Parameter: local set to '{value}'" + case 'q': + response = f"{response} and\n Query Parameter: q set to '{value}'" + case 'jsonKeys': + response = f"{response} and\n Query Parameter: jsonKeys set to '{value}'" + case 'expandValues': + response = f"{response} and\n Query Parameter: expandValues set to '{value}'" + case 'count': + response = f"{response} and\n Query Parameter: count set to '{value}'" case _: raise Exception(f"ERROR: unexpected attribute(s) {result}, the attributes expected are " f"{expected_parameters}, but received: {kwargs}") diff --git a/resources/ApiUtils/ContextInformationConsumption.resource b/resources/ApiUtils/ContextInformationConsumption.resource index 332029af3fd6d19590c97b847489f4002a7f32f8..213616cc986f6687ed25fb0dc94b2af1d7ee9602 100755 --- a/resources/ApiUtils/ContextInformationConsumption.resource +++ b/resources/ApiUtils/ContextInformationConsumption.resource @@ -50,6 +50,8 @@ Query Entities ... ${pick}=${EMPTY} ... ${omit}=${EMPTY} ... ${orderBy}=${EMPTY} + ... ${jsonKeys}=${EMPTY} + ... ${expandValues}=${EMPTY} ... ${broker_url}=${EMPTY} ${final_url}= Set Variable If '${broker_url}'!='' ${broker_url} ${url} ${attrs_length}= Get Length ${attrs} @@ -111,6 +113,12 @@ Query Entities IF ${orderBy_length}>0 Set To Dictionary ${params} orderBy=${orderBy} END + IF '${jsonKeys}'!='' + Set To Dictionary ${params} jsonKeys=${jsonKeys} + END + IF '${expandValues}'!='' + Set To Dictionary ${params} expandValues=${expandValues} + END ${response}= GET ... url=${final_url}/${ENTITIES_ENDPOINT_PATH} @@ -133,6 +141,10 @@ Query Entities Via POST ... ${joinLevel}=${EMPTY} ... ${local}=${EMPTY} ... ${options}=${EMPTY} + ... ${q}=${EMPTY} + ... ${expandValues}=${EMPTY} + ... ${jsonKeys}=${EMPTY} + ... ${count}=${EMPTY} ... ${broker_url}=${EMPTY} ${final_url}= Set Variable If '${broker_url}'!='' ${broker_url} ${url} &{headers}= Create Dictionary @@ -150,6 +162,7 @@ Query Entities Via POST Set To Dictionary ${params} options=${options} END IF '${local}'!='' Set To Dictionary ${params} local=${local} + IF '${count}'!='' Set To Dictionary ${params} count=${count} &{body}= Create Dictionary Set To Dictionary ${body} type=Query @@ -166,6 +179,15 @@ Query Entities Via POST IF '${join_level}'!='' Set To Dictionary ${body} joinLevel=${joinLevel} END + IF '${q}'!='' Set To Dictionary ${body} q=${q} + ${expand_values_length}= Get Length ${expandValues} + IF ${expand_values_length}>0 + Set To Dictionary ${body} expandValues=${expandValues} + END + ${json_keys_length}= Get Length ${jsonKeys} + IF ${json_keys_length}>0 + Set To Dictionary ${body} jsonKeys=${jsonKeys} + END ${response}= POST ... url=${final_url}/${ENTITY_OPERATIONS_QUERY_ENDPOINT_PATH}