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

feat: add new test with query via post

parent 6847146c
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ Setup Initial Context Source Registrations
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id1}
    ...    ${auxiliary_registration_payload_file_path}
    ...    entity_id_pattern=
    ...    entity_id=${entity_id}
    ...    endpoint=${b2_url}
    ...    mode=auxiliary
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b1_url}
@@ -143,7 +143,7 @@ Delete Entities And Delete Registrations
    Delete Context Source Registration    ${registration_id4}    broker_url=${b1_url}
    Delete Context Source Registration    ${registration_id5}    broker_url=${b3_url}
    Delete Context Source Registration    ${registration_id6}    broker_url=${b3_url}
    Delete Entity by Id    ${parking_entity_id1}    broker_url=${b4_url}
    Delete Entity By Id    ${parking_entity_id2}    broker_url=${b4_url}
    Delete Entity by Id    ${parking_entity_id1}    broker_url=${b5_url}
    Delete Entity By Id    ${parking_entity_id2}    broker_url=${b5_url}
 No newline at end of file
    Delete Entity by Id    ${entity_id}    broker_url=${b4_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b4_url}
    Delete Entity by Id    ${entity_id}    broker_url=${b5_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b5_url}
 No newline at end of file
+149 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that the entities found in b4 and b5 can be queried correctly via 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_parking_location_name_payload_filename}       interoperability/offstreet-parking1-location-and-name.jsonld
${second_parking_location_name_payload_filename}      interoperability/offstreet-parking2-location-and-name.jsonld
${first_full_parking_payload_filename}                interoperability/offstreet-parking1-full.jsonld
${second_full_parking_payload_filename}               interoperability/offstreet-parking2-full.jsonld
${auxiliary_registration_payload_file_path}           csourceRegistrations/interoperability/context-source-registration-auxiliary-2.jsonld
${inclusive_registration_payload_file_path}           csourceRegistrations/interoperability/context-source-registration-inclusive-1.jsonld
${first_exclusive_registration_payload_file_path}     csourceRegistrations/interoperability/context-source-registration-exclusive-2.jsonld
${second_exclusive_registration_payload_file_path}    csourceRegistrations/interoperability/context-source-registration-exclusive-3.jsonld
${first_redirect_registration_payload_file_path}      csourceRegistrations/interoperability/context-source-registration-redirect-1.jsonld
${second_redirect_registration_payload_file_path}     csourceRegistrations/interoperability/context-source-registration-redirect-2.jsonld
${b1_url}                                         
${b2_url}                                         
${b3_url}
${b4_url}
${b5_url}

*** Test Cases ***
IOP_CNF_04_02 Create Entities In Remote Brokers And Query Said Entities
    [Documentation]    Check that entities can be queried from all brokers.
    [Tags]    6_3    I6_3_4_2    inclusive    auxiliary    redirect    exclusive    interoperability

    ${response}=    Query Entities Via POST   entity_types=OffstreetParking    broker_url=${b1_url}
    Check Response Status Code    200    ${response.status_code}

    &{payload}=    Evaluate    {i['id']: i for i in ${response.json()}}
    ${first_parking_payload}=    Get From Dictionary    ${payload}    OffstreetParking:1
    ${second_parking_payload}=    Get From Dictionary    ${payload}    OffstreetParking:2
    Should Contain    ${first_parking_payload}    location
    Should Contain    ${second_parking_payload}    availableSpotsNumber
    Should Contain    ${second_parking_payload}    totalSpotsNumber
    Should Contain    ${second_parking_payload}    location

    ${response}=    Query Entities    entity_types=OffstreetParking    broker_url=${b4_url}
    ${payload}=    Evaluate    {i['id']: i for i in ${response.json()}}
    ${expected_entity1}=    Get From Dictionary    ${payload}    OffstreetParking:2
    ${response}=    Query Entities    entity_types=OffstreetParking    broker_url=${b5_url}
    ${payload}=    Evaluate    {i['id']: i for i in ${response.json()}}
    ${expected_entity2}=    Get From Dictionary    ${payload}    OffstreetParking:1
    ${expected_entity3}=    Get From Dictionary    ${payload}    OffstreetParking:2

    Should Be Equal    ${first_parking_payload}[location]    ${expected_entity2}[location]
    Should Be Equal    ${second_parking_payload}[availableSpotsNumber]    ${expected_entity1}[availableSpotsNumber]
    Should Be Equal    ${second_parking_payload}[totalSpotsNumber]    ${expected_entity1}[totalSpotsNumber]
    Should Be Equal    ${second_parking_payload}[location]    ${expected_entity3}[location]

*** Keywords ***
Setup Initial Context Source Registrations
    ${entity_id}=    Generate Random Parking Entity Id
    Set Suite Variable    ${entity_id}

    ${response}=    Create Entity    ${first_parking_location_name_payload_filename}    ${entity_id}    broker_url=${b4_url}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Create Entity    ${second_full_parking_payload_filename}    ${entity_id}    broker_url=${b4_url}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Create Entity    ${first_full_parking_payload_filename}    ${entity_id}    broker_url=${b5_url}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Create Entity    ${second_parking_location_name_payload_filename}    ${entity_id}    broker_url=${b5_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}
    ...    ${auxiliary_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    endpoint=${b2_url}
    ...    mode=auxiliary
    ${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}
    ...    ${first_redirect_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    endpoint=${b4_url}
    ...    mode=redirect
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b2_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}
    ...    ${second_redirect_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    endpoint=${b5_url}
    ...    mode=redirect
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b2_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id4}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id4}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id4}
    ...    ${inclusive_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    endpoint=${b3_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_id5}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id5}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id5}
    ...    ${first_exclusive_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    endpoint=${b5_url}
    ...    mode=exclusive
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b3_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id6}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id6}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id6}
    ...    ${second_exclusive_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    endpoint=${b5_url}
    ...    mode=exclusive
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b3_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=${b2_url}
    Delete Context Source Registration    ${registration_id3}    broker_url=${b2_url}
    Delete Context Source Registration    ${registration_id4}    broker_url=${b1_url}
    Delete Context Source Registration    ${registration_id5}    broker_url=${b3_url}
    Delete Context Source Registration    ${registration_id6}    broker_url=${b3_url}
    Delete Entity by Id    ${entity_id}    broker_url=${b4_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b4_url}
    Delete Entity by Id    ${entity_id}    broker_url=${b5_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b5_url}
 No newline at end of file