Commit ab84fa80 authored by Andrea Il Grande's avatar Andrea Il Grande
Browse files

added new test cases with local flag

parent c68d8614
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that when an entity creation request is made to the Context Broker with the local parameter, the request is not forwarded to the Context Source, and the entity is created only on the Context Broker


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

Suite Setup         Setup Entity Id And Registration And Start Context Source Mock Server
Test Teardown       Delete Created Entity And Registration And Stop Context Source Mock Server


*** Variables ***
${entity_id_prefix}                     urn:ngsi-ld:Vehicle:
${entity_payload_filename}              vehicle-simple-attributes.jsonld
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld

*** Test Cases ***
D001_04_inc Create Entity With Local Flag
    [Documentation]    Verify that, when one has an inclusive registration on a Context Broker, one is able to create an entity with local flag and the operation should not be forwarded to the Context Source
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    additive-inclusive    4_3_6_2    5_6_1    6_3_18
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}    local=true
    Check Response Status Code    201    ${response.status_code}

    Wait For No Request

*** Keywords ***
Setup Entity Id And Registration And Start Context Source Mock Server
    ${entity_id}=    Generate Random Entity Id    ${entity_id_prefix}
    Set Suite Variable    ${entity_id}

    ${registration_id}=    Generate Random Entity Id    ${registration_id_prefix}
    Set Suite Variable    ${registration_id}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ...    entity_id=${entity_id}
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response.status_code}

    Start Context Source Mock Server

Delete Created Entity And Registration And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Entity By Id    ${entity_id}
    Stop Context Source Mock Server
 No newline at end of file
+49 −0
Original line number Diff line number Diff line
*** Settings ***

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

Suite Setup         Create Entity And Registration On The Context Broker And Start Context Source Mock Server
Suite Teardown      Delete Created Entity And Registration And Stop Context Source Mock Server


*** Variables ***
${entity_id_prefix}                     urn:ngsi-ld:Vehicle:
${entity_payload_filename}              vehicle-simple-attributes.jsonld
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld

*** Test Cases ***
D002_03_inc Delete Entity With Local Flag
    [Documentation]    Verify that, when one has an inclusive registration on a Context Broker, one is able to delete an entity with local flag and the operation should not be forwarded to the Context Source
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    additive-inclusive    4_3_6_2    5_6_6    6_3_18
    ${response}=    Delete Entity by Id    ${entity_id}    local=true
    Check Response Status Code    204    ${response.status_code}

    Wait For No Request

*** Keywords ***
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
    ${entity_id}=    Generate Random Entity Id    ${entity_id_prefix}
    Set Suite Variable    ${entity_id}
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id}=    Generate Random Entity Id    ${registration_id_prefix}
    Set Suite Variable    ${registration_id}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ...    entity_id=${entity_id}
    ${response1}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response1.status_code}
    Start Context Source Mock Server

Delete Created Entity And Registration And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Entity By Id    ${entity_id}
    Stop Context Source Mock Server
 No newline at end of file
+8 −2
Original line number Diff line number Diff line
@@ -151,13 +151,16 @@ Batch Upsert Entities
    RETURN    ${response}

Create Entity
    [Arguments]    ${filename}    ${entity_id}
    [Arguments]    ${filename}    ${entity_id}    ${local}=${EMPTY}
    &{params}=    Create Dictionary
    IF    '${local}'!=''    Set To Dictionary    ${params}    local=${local}
    ${entity_payload}=    Load JSON From File    ${EXECDIR}/data/entities/${filename}
    ${entity}=    Update Value To JSON    ${entity_payload}    $..id    ${entity_id}
    &{headers}=    Create Dictionary    Content-Type=application/ld+json
    ${response}=    POST
    ...    url=${url}/${ENTITIES_ENDPOINT_PATH}
    ...    json=${entity}
    ...    params=${params}
    ...    headers=${headers}
    ...    expected_status=any
    Output    ${response}    Create Entity
@@ -238,9 +241,12 @@ Delete Entity Attributes
    RETURN    ${response}

Delete Entity by Id
    [Arguments]    ${id}
    [Arguments]    ${id}    ${local}=${EMPTY}
    &{params}=    Create Dictionary
    IF    '${local}'!=''    Set To Dictionary    ${params}    local=${local}
    ${response}=    DELETE
    ...    url=${url}/${ENTITIES_ENDPOINT_PATH}${id}
    ...    params=${params}
    ...    expected_status=any
    IF    ${delete_temporal_on_core_delete}
        Delete Temporal Representation Of Entity    ${id}