Commit c1c0ebfc authored by Marco Cavalli's avatar Marco Cavalli
Browse files

fix tests to match D6 steps (added intermediate steps)

parent 3deddfae
Loading
Loading
Loading
Loading
+77 −35
Original line number Diff line number Diff line
*** Settings ***
Documentation       Three brokers are set up A, B and C. A has two registrations, one inclusive for the entities in B and one exclusive for the entity in C.
...                 Check that the OffStreetParking:1 entity in A is the same as the one in B. Check that the OffStreetParking:2 entity in A has the same totalSpotsNumber attribute as the one found in B. Check that the OffStreetParking:2 entity in A has the same location attribute as the one in C.
Documentation       Three brokers are set up b1, b2 and b3. b1 has two registrations, one inclusive for the entities in b2 and one exclusive for the entity in b3.
...                 Check that OffStreetParking:1 in b1 contains availableSpotsNumber and totalSpotsNumber from b2. Check that OffStreetParking:2 in b1 contains availableSpotsNumber from b2 and location from b3.

Resource            ${EXECDIR}/resources/IOPUtils/InteroperabilityUtils.resource

@@ -12,19 +12,17 @@ Test Teardown Delete Entities and Delete Registrations
${first_entity_payload_filename}                interoperability/full-version-of-offstreetparking1.jsonld
${second_entity_payload_filename}               interoperability/full-version-of-offstreetparking2.jsonld
${third_entity_payload_filename}                interoperability/offstreetparking2-without-location-and-totalspotsnumber.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
${first_expected_payload_file_path}             interoperability/query-entity-IOP-003-01-01-first.json
${second_expected_payload_file_path}            interoperability/query-entity-IOP-003-01-01-second.json
${broker_A_url}                                 ${EMPTY}
${broker_B_url}                                 ${EMPTY}
${broker_C_url}                                 ${EMPTY}
${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}                                       ${EMPTY}
${b2_url}                                       ${EMPTY}
${b3_url}                                       ${EMPTY}


*** Test Cases ***
IOP_003_01_01 Query Entities Of Type OffstreetParking Via GET
    [Documentation]    Pre-conditions: no user context. Data only on leaves. B contains OffStreetParking:1 and OffStreetParking:2 without location and totalSpotsNumber. C contains OffStreetParking:2.
    ...    Registrations established: Inclusive in A to B. Exclusive in A to C.
    [Documentation]    Pre-conditions: no user context. Data only on leaves. b2 contains OffStreetParking:1 and OffStreetParking:2 without location and totalSpotsNumber. b3 contains OffStreetParking:2.
    ...    Registrations established: Inclusive in b1 to b2. Exclusive in b1 to b3.
    [Tags]
    ...    since_v1.6.1
    ...    iop
@@ -36,25 +34,69 @@ IOP_003_01_01 Query Entities Of Type OffstreetParking Via GET
    ...    5_7_2
    ...    6_4_3_1

    # Client queries all entities with type OffStreetParking in A. Agent checks for a successful response that contains the attributes availableSpotsNumber and totalSpotsNumber from OffStreetParking:1 and the attributes availableSpotsNumber and totalSpotsNumber and location from OffStreetParking:2.
    ${response_a}=    Query Entities
    # Client sends an HTTP GET request to b1 to retrieve all Entities with type OffstreetParking
    ${response_b1}=    Query Entities
    ...    entity_types=OffStreetParking
    ...    broker_url=${broker_A_url}
    ...    broker_url=${b1_url}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response_a.status_code}

    ${entity_ids}=    Create List    ${first_entity_id}    ${second_entity_id}
    Check Response Body Containing Entities URIS set to    ${entity_ids}    ${response_a.json()}

    # Agent checks that OffStreetParking:1 in A is the same as the one in B and that OffStreetParking:2 in A contains the attributes of both OffStreetParking:2 in B and C.
    Check Response Body Containing Entity element by id
    ...    ${first_expected_payload_file_path}
    ...    ${first_entity_id}
    ...    ${response_a.json()}
    Check Response Body Containing Entity element by id
    ...    ${second_expected_payload_file_path}
    ...    ${second_entity_id}
    ...    ${response_a.json()}
    # Agent checks that a success response has been returned and that the following Entities were returned:
    # OffstreetParking:1 with the attributes availableSpotsNumber and totalSpotsNumber
    # OffstreetParking:2 with the attributes availableSpotsNumber and location
    Check Response Status Code    200    ${response_b1.status_code}
    ${expected_b1_ids}=    Create List    ${first_entity_id}    ${second_entity_id}
    Check Response Body Containing Entities URIS set to    ${expected_b1_ids}    ${response_b1.json()}
    ${first_entity_b1}=    Get Value From JSON    ${response_b1.json()}    $[?(@.id=='${first_entity_id}')]
    ${second_entity_b1}=    Get Value From JSON    ${response_b1.json()}    $[?(@.id=='${second_entity_id}')]

    # Client sends an HTTP GET request to b2 to retrieve all Entities with type OffstreetParking
    ${response_b2}=    Query Entities
    ...    entity_types=OffStreetParking
    ...    broker_url=${b2_url}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response_b2.status_code}
    ${expected_b2_ids}=    Create List    ${first_entity_id}    ${second_entity_id}
    Check Response Body Containing Entities URIS set to    ${expected_b2_ids}    ${response_b2.json()}
    ${first_entity_b2}=    Get Value From JSON    ${response_b2.json()}    $[?(@.id=='${first_entity_id}')]
    ${second_entity_b2}=    Get Value From JSON    ${response_b2.json()}    $[?(@.id=='${second_entity_id}')]

    # Client sends an HTTP GET request to b3 to retrieve all Entities with type OffstreetParking
    ${response_b3}=    Query Entities
    ...    entity_types=OffStreetParking
    ...    broker_url=${b3_url}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response_b3.status_code}
    ${expected_b3_ids}=    Create List    ${second_entity_id}
    Check Response Body Containing Entities URIS set to    ${expected_b3_ids}    ${response_b3.json()}
    ${second_entity_b3}=    Get Value From JSON    ${response_b3.json()}    $[?(@.id=='${second_entity_id}')]

    # Agent checks that b2 returns OffstreetParking:1 and OffstreetParking:2 and b3 returns OffstreetParking:2
    ${expected_first_b2}=    Load Entity    ${first_entity_payload_filename}    ${first_entity_id}
    Remove From Dictionary    ${expected_first_b2}    @context
    Check Resource Set To    ${expected_first_b2}    ${first_entity_b2}[0]
    ${expected_second_b2}=    Load Entity    ${third_entity_payload_filename}    ${second_entity_id}
    Remove From Dictionary    ${expected_second_b2}    @context
    Check Resource Set To    ${expected_second_b2}    ${second_entity_b2}[0]
    ${expected_second_b3}=    Load Entity    ${second_entity_payload_filename}    ${second_entity_id}
    Remove From Dictionary    ${expected_second_b3}    @context
    Check Resource Set To    ${expected_second_b3}    ${second_entity_b3}[0]

    # Agent checks that OffstreetParking:1 returned in step (2) matches b2 and OffstreetParking:2 combines b2 and b3
    ${expected_first_b1}=    Load Entity    ${first_entity_payload_filename}    ${first_entity_id}
    Keep In Dictionary    ${expected_first_b1}    id    type    availableSpotsNumber    totalSpotsNumber
    Set To Dictionary
    ...    ${expected_first_b1}
    ...    availableSpotsNumber=${first_entity_b2}[0][availableSpotsNumber]
    ...    totalSpotsNumber=${first_entity_b2}[0][totalSpotsNumber]
    Check Resource Set To    ${expected_first_b1}    ${first_entity_b1}[0]

    ${expected_second_b1}=    Load Entity    ${third_entity_payload_filename}    ${second_entity_id}
    Keep In Dictionary    ${expected_second_b1}    id    type    availableSpotsNumber
    Set To Dictionary
    ...    ${expected_second_b1}
    ...    availableSpotsNumber=${second_entity_b2}[0][availableSpotsNumber]
    ...    location=${second_entity_b3}[0][location]
    Check Resource Set To    ${expected_second_b1}    ${second_entity_b1}[0]


*** Keywords ***
@@ -65,39 +107,39 @@ Setup Initial Context Source Registrations
    ${response}=    Create Entity
    ...    ${first_entity_payload_filename}
    ...    ${first_entity_id}
    ...    broker_url=${broker_B_url}
    ...    broker_url=${b2_url}
    Check Response Status Code    201    ${response.status_code}

    ${response}=    Create Entity
    ...    ${third_entity_payload_filename}
    ...    ${second_entity_id}
    ...    broker_url=${broker_B_url}
    ...    broker_url=${b2_url}
    Check Response Status Code    201    ${response.status_code}

    ${response}=    Create Entity
    ...    ${second_entity_payload_filename}
    ...    ${second_entity_id}
    ...    broker_url=${broker_C_url}
    ...    broker_url=${b3_url}
    Check Response Status Code    201    ${response.status_code}

    @{first_set}=    Create List
    ...    ${EMPTY}
    ...    ${inclusive_registration_payload_file_path}
    ...    inclusive
    ...    ${broker_B_url}
    ...    ${broker_A_url}
    ...    ${b2_url}
    ...    ${b1_url}

    @{second_set}=    Create List
    ...    ${second_entity_id}
    ...    ${exclusive_registration_payload_file_path}
    ...    exclusive
    ...    ${broker_C_url}
    ...    ${broker_A_url}
    ...    ${b3_url}
    ...    ${b1_url}

    @{first_configuration}=    Create List    ${first_set}    ${second_set}
    Compose IOP Configuration    ${first_configuration}

Delete Entities And Delete Registrations
    @{broker_count}=    Create List    ${broker_A_url}    ${broker_B_url}    ${broker_C_url}
    @{broker_count}=    Create List    ${b1_url}    ${b2_url}    ${b3_url}
    @{entities_to_delete}=    Create List    ${first_entity_id}    ${second_entity_id}
    Delete Registrations And Entities    ${broker_count}    ${entities_to_delete}
+77 −35
Original line number Diff line number Diff line
*** Settings ***
Documentation       Three brokers are set up A, B and C. A has two registrations, one inclusive for the entities in B and one exclusive for the entity in C.
...                 Check that the OffStreetParking:1 entity in A is the same as the one in B. Check that the OffStreetParking:2 entity in A has the same totalSpotsNumber attribute as the one found in B. Check that the OffStreetParking:2 entity in A has the same location attribute as the one in C.
Documentation       Three brokers are set up b1, b2 and b3. b1 has two registrations, one inclusive for the entities in b2 and one exclusive for the entity in b3.
...                 Check that OffStreetParking:1 in b1 contains availableSpotsNumber and totalSpotsNumber from b2. Check that OffStreetParking:2 in b1 contains availableSpotsNumber from b2 and location from b3.

Resource            ${EXECDIR}/resources/IOPUtils/InteroperabilityUtils.resource

@@ -12,19 +12,17 @@ Test Teardown Delete Entities and Delete Registrations
${first_entity_payload_filename}                interoperability/full-version-of-offstreetparking1.jsonld
${second_entity_payload_filename}               interoperability/full-version-of-offstreetparking2.jsonld
${third_entity_payload_filename}                interoperability/offstreetparking2-without-location-and-totalspotsnumber.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
${first_expected_payload_file_path}             interoperability/query-entity-IOP-003-01-01-first.json
${second_expected_payload_file_path}            interoperability/query-entity-IOP-003-01-01-second.json
${broker_A_url}                                 ${EMPTY}
${broker_B_url}                                 ${EMPTY}
${broker_C_url}                                 ${EMPTY}
${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}                                       ${EMPTY}
${b2_url}                                       ${EMPTY}
${b3_url}                                       ${EMPTY}


*** Test Cases ***
IOP_003_01_02 Query Entities Of Type OffstreetParking Via POST
    [Documentation]    Pre-conditions: no user context. Data only on leaves. B contains OffStreetParking:1 and OffStreetParking:2 without location. C contains OffStreetParking:2.
    ...    Registrations established: Inclusive in A to B. Exclusive in A to C.
    [Documentation]    Pre-conditions: no user context. Data only on leaves. b2 contains OffStreetParking:1 and OffStreetParking:2 without location and totalSpotsNumber. b3 contains OffStreetParking:2.
    ...    Registrations established: Inclusive in b1 to b2. Exclusive in b1 to b3.
    [Tags]
    ...    since_v1.6.1
    ...    iop
@@ -36,27 +34,71 @@ IOP_003_01_02 Query Entities Of Type OffstreetParking Via POST
    ...    5_7_2
    ...    6_23_2_1

    # Client queries all entities with type OffStreetParking in A and agent checks for a successful response. It should contain the attributes availableSpotsNumber and totalSpotsNumber from OffStreetParking:1 and the attributes availableSpotsNumber and location from OffStreetParking:2.
    # Client sends an HTTP POST request to b1 to retrieve all Entities with type OffstreetParking
    &{entity_selector}=    Create Dictionary    type=OffStreetParking
    @{entities}=    Create List    ${entity_selector}
    ${response_a}=    Query Entities Via POST
    ${response_b1}=    Query Entities Via POST
    ...    entities=${entities}
    ...    broker_url=${broker_A_url}
    ...    broker_url=${b1_url}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response_a.status_code}

    ${entity_ids}=    Create List    ${first_entity_id}    ${second_entity_id}
    Check Response Body Containing Entities URIS set to    ${entity_ids}    ${response_a.json()}

    # Agent checks that OffstreetParking:1 in A is the same as the one in B and that OffstreetParking:2 in A contains the attributes of both OffstreetParking:2 in B and C.
    Check Response Body Containing Entity element by id
    ...    ${first_expected_payload_file_path}
    ...    ${first_entity_id}
    ...    ${response_a.json()}
    Check Response Body Containing Entity element by id
    ...    ${second_expected_payload_file_path}
    ...    ${second_entity_id}
    ...    ${response_a.json()}
    # Agent checks that a success response has been returned and that the following Entities were returned:
    # OffstreetParking:1 with the attributes availableSpotsNumber and totalSpotsNumber
    # OffstreetParking:2 with the attributes availableSpotsNumber and location
    Check Response Status Code    200    ${response_b1.status_code}
    ${expected_b1_ids}=    Create List    ${first_entity_id}    ${second_entity_id}
    Check Response Body Containing Entities URIS set to    ${expected_b1_ids}    ${response_b1.json()}
    ${first_entity_b1}=    Get Value From JSON    ${response_b1.json()}    $[?(@.id=='${first_entity_id}')]
    ${second_entity_b1}=    Get Value From JSON    ${response_b1.json()}    $[?(@.id=='${second_entity_id}')]

    # Client sends an HTTP POST request to b2 to retrieve all Entities with type OffstreetParking
    ${response_b2}=    Query Entities Via POST
    ...    entities=${entities}
    ...    broker_url=${b2_url}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response_b2.status_code}
    ${expected_b2_ids}=    Create List    ${first_entity_id}    ${second_entity_id}
    Check Response Body Containing Entities URIS set to    ${expected_b2_ids}    ${response_b2.json()}
    ${first_entity_b2}=    Get Value From JSON    ${response_b2.json()}    $[?(@.id=='${first_entity_id}')]
    ${second_entity_b2}=    Get Value From JSON    ${response_b2.json()}    $[?(@.id=='${second_entity_id}')]

    # Client sends an HTTP POST request to b3 to retrieve all Entities with type OffstreetParking
    ${response_b3}=    Query Entities Via POST
    ...    entities=${entities}
    ...    broker_url=${b3_url}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response_b3.status_code}
    ${expected_b3_ids}=    Create List    ${second_entity_id}
    Check Response Body Containing Entities URIS set to    ${expected_b3_ids}    ${response_b3.json()}
    ${second_entity_b3}=    Get Value From JSON    ${response_b3.json()}    $[?(@.id=='${second_entity_id}')]

    # Agent checks that b2 returns OffstreetParking:1 and OffstreetParking:2 and b3 returns OffstreetParking:2
    ${expected_first_b2}=    Load Entity    ${first_entity_payload_filename}    ${first_entity_id}
    Remove From Dictionary    ${expected_first_b2}    @context
    Check Resource Set To    ${expected_first_b2}    ${first_entity_b2}[0]
    ${expected_second_b2}=    Load Entity    ${third_entity_payload_filename}    ${second_entity_id}
    Remove From Dictionary    ${expected_second_b2}    @context
    Check Resource Set To    ${expected_second_b2}    ${second_entity_b2}[0]
    ${expected_second_b3}=    Load Entity    ${second_entity_payload_filename}    ${second_entity_id}
    Remove From Dictionary    ${expected_second_b3}    @context
    Check Resource Set To    ${expected_second_b3}    ${second_entity_b3}[0]

    # Agent checks that OffstreetParking:1 returned in step (2) matches b2 and OffstreetParking:2 combines b2 and b3
    ${expected_first_b1}=    Load Entity    ${first_entity_payload_filename}    ${first_entity_id}
    Keep In Dictionary    ${expected_first_b1}    id    type    availableSpotsNumber    totalSpotsNumber
    Set To Dictionary
    ...    ${expected_first_b1}
    ...    availableSpotsNumber=${first_entity_b2}[0][availableSpotsNumber]
    ...    totalSpotsNumber=${first_entity_b2}[0][totalSpotsNumber]
    Check Resource Set To    ${expected_first_b1}    ${first_entity_b1}[0]

    ${expected_second_b1}=    Load Entity    ${third_entity_payload_filename}    ${second_entity_id}
    Keep In Dictionary    ${expected_second_b1}    id    type    availableSpotsNumber
    Set To Dictionary
    ...    ${expected_second_b1}
    ...    availableSpotsNumber=${second_entity_b2}[0][availableSpotsNumber]
    ...    location=${second_entity_b3}[0][location]
    Check Resource Set To    ${expected_second_b1}    ${second_entity_b1}[0]


*** Keywords ***
@@ -67,39 +109,39 @@ Setup Initial Context Source Registrations
    ${response}=    Create Entity
    ...    ${first_entity_payload_filename}
    ...    ${first_entity_id}
    ...    broker_url=${broker_B_url}
    ...    broker_url=${b2_url}
    Check Response Status Code    201    ${response.status_code}

    ${response}=    Create Entity
    ...    ${third_entity_payload_filename}
    ...    ${second_entity_id}
    ...    broker_url=${broker_B_url}
    ...    broker_url=${b2_url}
    Check Response Status Code    201    ${response.status_code}

    ${response}=    Create Entity
    ...    ${second_entity_payload_filename}
    ...    ${second_entity_id}
    ...    broker_url=${broker_C_url}
    ...    broker_url=${b3_url}
    Check Response Status Code    201    ${response.status_code}

    @{first_set}=    Create List
    ...    ${EMPTY}
    ...    ${inclusive_registration_payload_file_path}
    ...    inclusive
    ...    ${broker_B_url}
    ...    ${broker_A_url}
    ...    ${b2_url}
    ...    ${b1_url}

    @{second_set}=    Create List
    ...    ${EMPTY}
    ...    ${exclusive_registration_payload_file_path}
    ...    exclusive
    ...    ${broker_C_url}
    ...    ${broker_A_url}
    ...    ${b3_url}
    ...    ${b1_url}

    @{first_configuration}=    Create List    ${first_set}    ${second_set}
    Compose IOP Configuration    ${first_configuration}

Delete Entities And Delete Registrations
    @{broker_count}=    Create List    ${broker_A_url}    ${broker_B_url}    ${broker_C_url}
    @{broker_count}=    Create List    ${b1_url}    ${b2_url}    ${b3_url}
    @{entities_to_delete}=    Create List    ${first_entity_id}    ${second_entity_id}
    Delete Registrations And Entities    ${broker_count}    ${entities_to_delete}
+95 −39

File changed.

Preview size limit exceeded, changes collapsed.

+85 −42

File changed.

Preview size limit exceeded, changes collapsed.

+78 −38

File changed.

Preview size limit exceeded, changes collapsed.

Loading