Commit 8628e242 authored by Benedetta Arena's avatar Benedetta Arena
Browse files

feat: add new test case for entity creation in brokers

parent c4ad0fea
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -22,10 +22,9 @@ ${b3_url}
*** Test Cases ***
IOP_CNF_01_01 Create Entity In B1 And Retrieve Entity In All Brokers
    [Documentation]    Check that entities are created in b1 and b2 but not in b3.
    [Tags]    6_1    I6_1_1_1    Inclusive    Exclusive    Interoperability
    [Tags]    6_1    I6_1_1_1    inclusive    exclusive    interoperability
    
    ${expected_payload}=    Load Entity    ${entity_payload_filename}    ${entity_id}

    ${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}
    Should Be Equal    ${response.json()}    ${expected_payload}
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ ${b3_url}
*** Test Cases ***
IOP_CNF_01_02 Create Entity In B1 And Retrieve Entity In All Brokers
    [Documentation]    Check that, in b1 and b2, the entity does not contain the attribute location, said attribute will be contained in b3 thanks to an exclusive registration.
    [Tags]    6_1    I6_1_1_2    Inclusive    Exclusive    Interoperability
    [Tags]    6_1    I6_1_1_2    inclusive    exclusive    interoperability

    ${response}=    Retrieve Entity by Id    ${entity_id}    context=${ngsild_test_suite_context}    broker_url=${b1_url}    local=true
    Check Response Status Code    200    ${response.status_code}
+1 −3
Original line number Diff line number Diff line
@@ -23,9 +23,7 @@ ${b4_url}
*** Test Cases ***
IOP_CNF_02_01 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.
    [Tags]    6_1    I6_1_2_1    Inclusive    Redirect    Interoperability
    
    ${expected_payload}=    Load Entity    ${entity_payload_filename}    ${entity_id}
    [Tags]    6_1    I6_1_2_1    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}
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ ${b4_url}
*** Test Cases ***
IOP_CNF_02_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.
    [Tags]    6_1    I6_1_2_2    Inclusive    Redirect    Interoperability
    [Tags]    6_1    I6_1_2_2    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}
+91 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that the entity was created in b3 and b4, but it is not created in b2

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_inclusive_registration_payload_file_path}       csourceRegistrations/interoperability/context-source-registration-inclusive-1.jsonld
${second_inclusive_registration_payload_file_path}      csourceRegistrations/interoperability/context-source-registration-inclusive-2.jsonld
${b1_url}                                         
${b2_url}                                         
${b3_url}
${b4_url}                                         

*** Test Cases ***
IOP_CNF_03_01 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.
    [Tags]    6_1    I6_1_3_1    auxiliary    inclusive    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    200    ${response.status_code}
    Should Contain    ${response.json()}    availableSpotsNumber
    Should Contain    ${response.json()}    totalSpotsNumber

*** 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_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_id3}=     Generate Random CSR Id
    Set Suite Variable    ${registration_id3}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id3}
    ...    ${second_inclusive_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    broker_url=${b4_url}
    ...    mode=inclusive
    ${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=${b1_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b2_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b3_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b4_url}
 No newline at end of file