Commit a02f7c21 authored by Benedetta Arena's avatar Benedetta Arena
Browse files

feat: add new test for query entities via POST with three brokers

parent 6d61cbc1
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that the entities found in b2 and b3 can be queried from b1.Verify that the broker b2 mirrors the information stored in the b1 broker and broker b3 contains some exclusive data.

Documentation       Verify that the entities found in b2 and b3 can be queried from b1 via HTTP GET.
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource
@@ -39,8 +38,7 @@ IOP_CNF_01_01 Create Entity In B1 And Query Entity In All Brokers

    ${response}=    Query Entities    entity_types=OffstreetParking    broker_url=${b3_url}
    @{second_expected_payload}=    Set Variable    ${response.json()}
    ${entity_ids}=    Create List    ${entity_id}
    Check Response Body Containing Entities URIS set to    ${entity_ids}    ${response.json()}
    Check Response Body Containing Entities URIS set to    ${entity_id}    ${response.json()}

    Should Be Equal    ${payload}\[OffstreetParking1]    ${first_expected_payload}\[OffstreetParking1]
    Should Contain    ${payload}\[OffstreetParking2]    ${first_expected_payload}\[OffstreetParking2][totalSpotsNumber]
+101 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that the entities found in b2 and b3 can be queried from b1 via HTTP POST.

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Test Setup          Setup Initial Context Source Registrations
Test Teardown       Delete Entities and Delete Registrations

*** Variables ***
${first_entity_payload_filename}                  interoperability/offstreet-parking1-full.jsonld
${second_entity_payload_filename}                 interoperability/offstreet-parking2-full.jsonld
${third_entity_payload_filename}                  interoperability/offstreet-parking2-no-location-and-totalspotsnumber.jsonld
${inclusive_registration_payload_file_path}       csourceRegistrations/interoperability/context-source-registration-inclusive-2.jsonld
${exclusive_registration_payload_file_path}       csourceRegistrations/interoperability/context-source-registration-exclusive-2.jsonld
${b1_url}                                         
${b2_url}                                         
${b3_url}                                         

*** Test Cases ***
IOP_CNF_01_01 Create Entity In B1 And Query Entity In All Brokers
    [Documentation]    Check that entities can be queried from all brokers.
    [Tags]    6_3    I6_3_1_2    inclusive    exclusive    interoperability
    
    @{entities}=    Create List    ${entity_id}    ${second_entity_id}
    ${response}=    Query Entities Via POST   entities=${entities}    broker_url=${b1_url}
    Check Response Status Code    200    ${response.status_code}
    @{payload}=    Set Variable   ${response.json()}
    Should Contain    ${payload}\[OffstreetParking1]    availableSpotsNumber
    Should Contain    ${payload}\[OffstreetParking1]    totalSpotsNumber

    ${response}=    Query Entities Via POST   entities=${entities}    broker_url=${b2_url}
    @{first_expected_payload}=    Set Variable    ${response.json()}
    Check Response Body Containing Entities URIS set to    ${entities}    ${response.json()}

    ${response}=    Query Entities Via POST   entities=${entity_id}    broker_url=${b3_url}
    @{second_expected_payload}=    Set Variable    ${response.json()}
    Check Response Body Containing Entities URIS set to    ${entity_id}    ${response.json()}

    Should Be Equal    ${payload}\[OffstreetParking1]    ${first_expected_payload}\[OffstreetParking1]
    Should Contain    ${payload}\[OffstreetParking2]    ${first_expected_payload}\[OffstreetParking2][totalSpotsNumber]
    Should Contain    ${payload}\[OffstreetParking2]    ${second_expected_payload}\[OffstreetParking2][location]

*** Keywords ***
Setup Initial Context Source Registrations

    ${entity_id}=    Generate Random Parking Entity Id
    Set Suite Variable    ${entity_id}
    ${second_entity_id}=    Generate Random Parking Entity Id
    Set Suite Variable    ${second_entity_id}
    ${response}=    Create Entity    ${first_entity_payload_filename}    ${entity_id}    broker_url=${b2_url}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Create Entity    ${third_entity_payload_filename}    ${second_entity_id}    broker_url=${b2_url}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Create Entity    ${second_entity_payload_filename}    ${entity_id}    broker_url=${b3_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id1}=     Generate Random CSR Id
    Set Suite Variable    ${registration_id1}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id1}
    ...    ${inclusive_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    broker_url=${b2_url}
    ...    mode=inclusive
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id2}=     Generate Random CSR Id
    Set Suite Variable    ${registration_id2}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id2}
    ...    ${inclusive_registration_payload_file_path}
    ...    entity_id=${second_entity_id}
    ...    broker_url=${b2_url}
    ...    mode=inclusive
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id3}=     Generate Random CSR Id
    Set Suite Variable    ${registration_id3}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id3}
    ...    ${exclusive_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    broker_url=${b3_url}
    ...    mode=exclusive
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}

Delete Entities And Delete Registrations
    Delete Context Source Registration    ${registration_id1}    broker_url=${b1_url}
    Delete Context Source Registration    ${registration_id2}    broker_url=${b1_url}
    Delete Context Source Registration    ${registration_id3}    broker_url=${b1_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b2_url}
    Delete Entity by Id    ${second_entity_id}    broker_url=${b2_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b3_url}
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
@@ -116,6 +116,8 @@ Query Entities Via POST
    ...    ${context}=${EMPTY}
    ...    ${attrs}=${EMPTY}
    ...    ${geometry_property}=${EMPTY}
    ...    ${broker_url}=${EMPTY}
    ${final_url}=    Set Variable If    '${broker_url}'!=''    ${broker_url}    ${url}
    &{headers}=    Create Dictionary
    Set To Dictionary    ${headers}    Content-Type    ${content_type}
    Set To Dictionary    ${headers}    Accept    ${accept}
@@ -137,7 +139,7 @@ Query Entities Via POST
        Set To Dictionary    ${body}    geometryProperty=${geometry_property}
    END
    ${response}=    POST
    ...    url=${url}/${ENTITY_OPERATIONS_QUERY_ENDPOINT_PATH}
    ...    url=${final_url}/${ENTITY_OPERATIONS_QUERY_ENDPOINT_PATH}
    ...    json=${body}
    ...    headers=${headers}
    ...    expected_status=any