Commit 7ca914ce authored by Benedetta Arena's avatar Benedetta Arena
Browse files

feat: add test for creation of entity with five brokers

parent b50bbf7f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that the partial entity is created in b3 and b4, but it is not created in b2
Documentation       Verify that the partial entity is created in b1 and b3, but it is not created in b2 and b4

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
@@ -23,7 +23,7 @@ ${b4_url}

*** Test Cases ***
IOP_CNF_03_02 Create Entity In B1 And Retrieve Entity In All Brokers
    [Documentation]    Check that entities are created in the brokers, b1 and b2 should contain most entity attributes, 3b and b4 should only contain the location attribute.
    [Documentation]    Check that entities are created in the b1 and b3 brokers. The b2 and b4 should not contain the entity
    [Tags]    6_1    I6_1_3_2    auxiliary    inclusive    interoperability

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b1_url}    context=${ngsild_test_suite_context}
+117 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that the entity is created in b1 and b3. The entity should not be created in b2, b4 and b5. 

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 ***
${entity_payload_filename}                             interoperability/offstreet-parking1-full.jsonld
${auxiliary_registration_payload_file_path}            csourceRegistrations/interoperability/context-source-registration-auxiliary-2.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
${inclusive_registration_payload_file_path}            csourceRegistrations/interoperability/context-source-registration-inclusive-1.jsonld
${exclusive_registration_payload_file_path}            csourceRegistrations/interoperability/context-source-registration-exclusive-1.jsonld
${b1_url}                                         
${b2_url}                                         
${b3_url}
${b4_url}
${b5_url}                                         

*** Test Cases ***
IOP_CNF_04_01 Create Entity In B1 And Retrieve Entity In All Brokers
    [Documentation]    Check that entities are created in the b1 and b3 brokers. The b2, b4 and b5 should not contain the entity
    [Tags]    6_1    I6_1_4_1    auxiliary    inclusive    redirect    interoperability

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b1_url}    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b2_url}    context=${ngsild_test_suite_context}
    Check Response Status Code    404    ${response.status_code}

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b3_url}    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b4_url}    context=${ngsild_test_suite_context}
    Check Response Status Code    404    ${response.status_code}

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b5_url}    context=${ngsild_test_suite_context}
    Check Response Status Code    404    ${response.status_code}

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

    ${entity_id}=    Generate Random Parking Entity Id
    Set Suite Variable    ${entity_id}
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}    broker_url=${b1_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}
    ...    broker_url=${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}
    ...    broker_url=${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}
    ...    broker_url=${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}
    ...    broker_url=${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}
    ...    ${exclusive_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    broker_url=${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 Entity By Id    ${entity_id}    broker_url=${b1_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b3_url}
 No newline at end of file