feat: add TCs for advanced NGSI-LD Query Language features

Merge request reports

Loading
+68 −0
Changes for TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_07.robot: 68 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** 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    core_10_4_3
    name=="Eiffel Tower"    1
019_02_07_02 QueryOnNameEqualityAndBoolean
    [Tags]    e-query    core_10_4_3
    name=="Pisa Tower";almostFull==false    1
019_02_07_03 QueryOnNameEqualityOrBoolean
    [Tags]    e-query    core_10_4_3
    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}
+66 −0
Changes for TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_08.robot: 66 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** 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 QueryOnJsonPropertyIdEqual
    [Tags]    e-query    core_10_4_3    core_5_2_6_4_10    since_v1.8.1
    jsonProperty[id]=="some-id"    jsonProperty    1
019_02_08_02 QueryOnJsonPropertyTypeEqual
    [Tags]    e-query    core_10_4_3    core_5_2_6_4_10    since_v1.8.1
    jsonProperty[type]=="some-type"    jsonProperty    2
019_02_08_03 QueryOnJsonPropertyIdNoMatch
    [Tags]    e-query    core_10_4_3    core_5_2_6_4_10    since_v1.8.1
    jsonProperty[id]=="wrong-id"    jsonProperty    0
019_02_08_04 QueryOnJsonPropertyIdUnequal
    [Tags]    e-query    core_10_4_3    core_5_2_6_4_10    since_v1.8.1
    jsonProperty[id]!="wrong-id"    jsonProperty    2
019_02_08_05 QueryOnJsonPropertyUnmatchedJsonKeys
    [Tags]    e-query    core_10_4_3    core_5_2_6_4_10    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}

    ${response}=    Query Entities Via POST
    ...    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}
+83 −0
Changes for TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_09.robot: 83 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** 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    core_10_4_3    core_5_2_6_4_7    since_v1.7.1
    vocabProperty=="monument"    vocabProperty    2
019_02_09_02 QueryWithExpandValuesEqualSightseeing
    [Tags]    e-query    core_10_4_3    core_5_2_6_4_7    since_v1.7.1
    vocabProperty=="sightseeing"    vocabProperty    1
019_02_09_03 QueryWithExpandValuesUnequalMonument
    [Tags]    e-query    core_10_4_3    core_5_2_6_4_7    since_v1.7.1
    vocabProperty!="monument"    vocabProperty    0
019_02_09_04 QueryWithUriMonument
    [Tags]    e-query    core_10_4_3    core_5_2_6_4_7    since_v1.7.1
    vocabProperty=="${MONUMENT_URI}"    ${EMPTY}    2
019_02_09_05 QueryWithUriSightseeing
    [Tags]    e-query    core_10_4_3    core_5_2_6_4_7    since_v1.7.1
    vocabProperty=="${SIGHTSEEING_URI}"    ${EMPTY}    1
019_02_09_06 QueryWithExpandValuesValueListEqual
    [Tags]    e-query    core_10_4_3    core_5_2_6_4_7    since_v1.7.1
    vocabProperty=="monument","sightseeing"    vocabProperty    2
019_02_09_07 QueryWithExpandValuesValueListUnequal
    [Tags]    e-query    core_10_4_3    core_5_2_6_4_7    since_v1.7.1
    vocabProperty!="monument","sightseeing"    vocabProperty    0
019_02_09_08 QueryWithUriValueList
    [Tags]    e-query    core_10_4_3    core_5_2_6_4_7    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}

    ${response}=    Query Entities Via POST
    ...    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}
+49 −0
Changes for TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_06.robot: 49 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** 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    core_10_4_3
    attr==
019_03_06_02 QueryWithUnclosedBracket
    [Tags]    e-query    core_10_4_3
    attr[
019_03_06_03 QueryWithInvalidSingleExclamationOperator
    [Tags]    e-query    core_10_4_3
    attr!value
019_03_06_04 QueryStartingWithLogicalOperator
    [Tags]    e-query    core_10_4_3
    ;attr=="value"
019_03_06_05 QueryWithConsecutiveLogicalOperators
    [Tags]    e-query    core_10_4_3
    attr=="value";;attr2=="value2"
019_03_06_06 QueryWithInvertedRegexOperator
    [Tags]    e-query    core_10_4_3
    attr=~"value*"
019_03_06_07 QueryWithUnknownOperator
    [Tags]    e-query    core_10_4_3
    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()}
+36 −3
Changes for TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_09.robot: 36 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -40,13 +40,46 @@ ${entity_type}= https://ngsi-ld-test-suite/context#Building
    airQualityLevel>=4;airQualityLevel<7    2
019_09_08 QueryOnLocatedInExisting
    [Tags]    e-query    core_10_4_3
    locatedIn==urn:ngsi-ld:City:Pisa    1
    locatedIn=="urn:ngsi-ld:City:Pisa"    1
019_09_09 QueryOnLocatedInNonExisting
    [Tags]    e-query    core_10_4_3
    locatedIn==urn:ngsi-ld:City:Paris    0
    locatedIn=="urn:ngsi-ld:City:Paris"    0
019_09_10 QueryOnLocatedInTwoCities
    [Tags]    e-query    core_10_4_3
    locatedIn==urn:ngsi-ld:City:Pisa|locatedIn==urn:ngsi-ld:City:Paris    1
    locatedIn=="urn:ngsi-ld:City:Pisa"|locatedIn=="urn:ngsi-ld:City:Paris"    1
019_09_11 QueryOnNameUnequal
    [Tags]    e-query    core_10_4_3
    name!="Eiffel Tower"    2
019_09_12 QueryOnAirQualityLevelUnequal
    [Tags]    e-query    core_10_4_3
    airQualityLevel!=4    2
019_09_13 QueryOnExistenceOfAttribute
    [Tags]    e-query    core_10_4_3
    locatedIn    1
019_09_14 QueryOnSubAttributeObservedAt
    [Tags]    e-query    core_10_4_3
    airQualityLevel.observedAt>=2021-01-01T00:00:00Z    1
019_09_15 QueryOnAirQualityLevelValueListEqual
    [Tags]    e-query    core_10_4_3
    airQualityLevel==4,6    2
019_09_16 QueryOnAirQualityLevelValueListUnequal
    [Tags]    e-query    core_10_4_3
    airQualityLevel!=4,6    1
019_09_17 QueryOnAirQualityLevelRangeEqual
    [Tags]    e-query    core_10_4_3
    airQualityLevel==5..7    2
019_09_18 QueryOnAirQualityLevelRangeUnequal
    [Tags]    e-query    core_10_4_3
    airQualityLevel!=5..7    1
019_09_19 QueryOnNameMatchPattern
    [Tags]    e-query    core_10_4_3
    name~=Eiffel.*    1
019_09_20 QueryOnNameMatchPatternAllTowers
    [Tags]    e-query    core_10_4_3
    name~=.*Tower    3
019_09_21 QueryOnNameNotMatchPattern
    [Tags]    e-query    core_10_4_3
    name!~=Pisa.*    1


*** Keywords ***
Loading
Loading