Commit 11da221b authored by Houcem Kacem's avatar Houcem Kacem
Browse files

Merge branch 'feature/add-tps-for-query-context-source-registrations' into 'develop'

feat: add tps for query context source registrations

See merge request !34
parents 0047a1e0 381225ce
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can query context source registrations if at least one of list of Entity Types or list of Attribute names is present
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

Test Template  Query Context Source Registration
Suite Setup      Setup Initial Context Source Registrations
Suite Teardown      Delete Created Context Source Registrations

*** Variable ***
${context_source_registration_id_prefix}=  urn:ngsi-ld:ContextSourceRegistration:
${first_context_source_registration_payload_file_path}=   csourceRegistrations/context-source-registration-sample.jsonld
${second_context_source_registration_payload_file_path}=   csourceRegistrations/context-source-registration-detailed-information-sample.jsonld

*** Test Cases ***                       QUERY_PARAM_NAME   QUERY_PARAM_VALUE     EXPECTATION_FILE_PATH                                                                         EXPECTED_CONTEXT_SOURCE_REGISTRATION_IDS
With list of entity types                type               Building              csourceRegistrations/expectations/context-source-registrations-037-01-expectation.json        ${first_context_source_registration_id}     ${second_context_source_registration_id}
With list of attribute names             attrs              name                  csourceRegistrations/expectations/context-source-registrations-037-01-expectation.json        ${second_context_source_registration_id}

*** Keywords ***
Query Context Source Registration
    [Arguments]  ${query_param_name}     ${query_param_value}    ${expectation_file_path}   @{expected_context_source_registration_ids}
    [Documentation]  Check that you can query context source registrations if at least one of list of Entity Types or list of Attribute names is present
    [Tags]  mandatory

    Query Context Source Registrations      context=${ngsild_test_suite_context}    ${query_param_name}=${query_param_value}

    Check Response Status Code Set To  200
    Check Response Body Containing List Containing Context Source Registrations elements     ${expectation_file_path}   ${expected_context_source_registration_ids}

Setup Initial Context Source Registrations
    ${first_context_source_registration_id}=     Generate Random Entity Id    ${context_source_registration_id_prefix}
    ${second_context_source_registration_id}=     Generate Random Entity Id    ${context_source_registration_id_prefix}
    ${first_context_source_registration_payload}=  Load Test Sample    ${first_context_source_registration_payload_file_path}    ${first_context_source_registration_id}
    ${second_context_source_registration_payload}=  Load Test Sample    ${second_context_source_registration_payload_file_path}    ${second_context_source_registration_id}

    Create Context Source Registration  ${first_context_source_registration_payload}
    Create Context Source Registration  ${second_context_source_registration_payload}

    Set Suite Variable  ${first_context_source_registration_id}
    Set Suite Variable  ${second_context_source_registration_id}

Delete Created Context Source Registrations
    Delete Context Source Registration     ${first_context_source_registration_id}
    Delete Context Source Registration     ${second_context_source_registration_id}
+16 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot query context source registrations, if neither Entity types nor Attribute names are provided, an error of type
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

*** Test Case ***
Query Context Source Registrations Without Entity Types and Attribute Names
    [Documentation]  Check that you cannot query context source registrations, if neither Entity types nor Attribute names are provided, an error of type
    [Tags]  mandatory

    Query Context Source Registrations      context=${ngsild_test_suite_context}

    Check Response Status Code Set To  400
    Check Response Body Containing ProblemDetails Element Containing Type Element set to      ${response}     ${ERROR_TYPE_BAD_REQUEST_DATA}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response}
+25 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot query context source registrations, if the list of Entity identifiers includes a URI which it is not valid, or the query, geo-query or temporal query are not syntactically valid
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

Test Template  Query Context Source Registration With Invalid Query Param

*** Test Cases ***                      QUERY_PARAM_NAME   QUERY_PARAM_VALUE
Invalid URI                             id                 invalidUri
Invalid Query                           q                  invalidQuery
Invalid GeoQuery                        georel             within
Invalid Temporal Query                  timerel            before

*** Keywords ***
Query Context Source Registration With Invalid Query Param
    [Arguments]  ${query_param_name}     ${query_param_value}
    [Documentation]  Check that you cannot query context source registrations, if the list of Entity identifiers includes a URI which it is not valid, or the query, geo-query or temporal query are not syntactically valid
    [Tags]  mandatory

    Query Context Source Registrations      context=${ngsild_test_suite_context}    ${query_param_name}=${query_param_value}

    Check Response Status Code Set To  400
    Check Response Body Containing ProblemDetails Element Containing Type Element set to      ${response}     ${ERROR_TYPE_BAD_REQUEST_DATA}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response}
+36 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can query context source registrations. If a JSON-LD context is not provided, then all the query terms shall be resolved against the default JSON-LD @context
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

Suite Setup      Setup Initial Context Source Registration
Suite Teardown      Delete Created Context Source Registration

*** Variable ***
${context_source_registration_id_prefix}=  urn:ngsi-ld:ContextSourceRegistration:
${context_source_registration_payload_file_path}=   csourceRegistrations/context-source-registration-sample.jsonld
${expectation_file_path}=   csourceRegistrations/expectations/context-source-registrations-037-04-expectation.json

*** Test Case ***
Query Context Source Registrations Without Context
    [Documentation]  Check that you can query context source registrations. If a JSON-LD context is not provided, then all the query terms shall be resolved against the default JSON-LD @context
    [Tags]  mandatory

    Query Context Source Registrations  id=${context_source_registration_id}

    @{expected_context_source_registration_ids}=  Create List   ${context_source_registration_id}
    Check Response Status Code Set To  200
    Check Response Body Containing List Containing Context Source Registrations elements     ${expectation_file_path}   ${expected_context_source_registration_ids}

*** Keywords ***
Setup Initial Context Source Registration
    ${context_source_registration_id}=     Generate Random Entity Id    ${context_source_registration_id_prefix}
    ${context_source_registration_payload}=  Load Test Sample    ${context_source_registration_payload_file_path}    ${context_source_registration_id}

    Create Context Source Registration  ${context_source_registration_payload}

    Set Suite Variable  ${context_source_registration_id}

Delete Created Context Source Registration
    Delete Context Source Registration     ${context_source_registration_id}
+33 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can query context source registrations matching EntityInfo of RegistrationInfo
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

Test Template  Query Context Source Registration Matching EntityInfo of RegistrationInfo

*** Variable ***
${context_source_registration_id_prefix}=  urn:ngsi-ld:ContextSourceRegistration:

*** Test Cases ***                                          REGISTRATION_FILE_PATH                                                                              EXPECTATION_FILE_PATH
Registration With EntityInfo Matching The Query             csourceRegistrations/context-source-registration-sample.jsonld                                      csourceRegistrations/expectations/context-source-registrations-037-05-01-expectation.json
Registration Without EntityInfo                             csourceRegistrations/context-source-registration-with-only-properties-information-sample.jsonld     csourceRegistrations/expectations/context-source-registrations-037-05-02-expectation.json

*** Keywords ***
Query Context Source Registration Matching EntityInfo of RegistrationInfo
    [Arguments]  ${registration_file_path}     ${expectation_file_path}
    [Documentation]  Check that you can query context source registrations matching EntityInfo of RegistrationInfo
    [Tags]  mandatory

    ${context_source_registration_id}=     Generate Random Entity Id    ${context_source_registration_id_prefix}
    ${context_source_registration_payload}=  Load Test Sample    ${registration_file_path}    ${context_source_registration_id}
    Create Context Source Registration  ${context_source_registration_payload}
    Set Suite Variable  ${context_source_registration_id}

    Query Context Source Registrations      context=${ngsild_test_suite_context}    type=Building   attrs=name

    @{expected_context_source_registration_ids}=  Create List   ${context_source_registration_id}
    Check Response Status Code Set To  200
    Check Response Body Containing List Containing Context Source Registrations elements     ${expectation_file_path}   ${expected_context_source_registration_ids}

    [Teardown]  Delete Context Source Registration     ${context_source_registration_id}
 No newline at end of file
Loading