Commit f07c2a32 authored by Patricia dos Santos Oliveira's avatar Patricia dos Santos Oliveira
Browse files

Merge branch 'feature/get-entities' into 'develop'

Feature/get entities

See merge request !11
parents 4e1a37e3 189a5680
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can get an entity by id
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

*** Variable ***
${building_id_prefix}=  urn:ngsi-ld:Building:
${filename}=  building-simple-attributes-sample.jsonld
${expectation_filename}=  building-simple-attributes-sample-expectation.jsonld

*** Test Cases ***                               
001_01_Get an entity by id
    [Documentation]  Check that you can get an entity by id
    [Tags]  mandatory

    ${entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${request}    ${response}=    Create Entity Selecting Content Type  ${filename}     ${entity_id}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code  201    ${response['status']}

    ${response}=    Query Entity    ${entity_id}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code  200    ${response['status']}
    Check Response Body Containing Entity element    ${expectation_filename}    ${entity_id}    ${response['body']}

    [Teardown]  Delete Entity by Id Returning Response   ${entity_id}
 No newline at end of file
+28 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can query some attributes from an entity
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

*** Variable ***
${building_id_prefix}=  urn:ngsi-ld:Building:
${filename}=  building-simple-attributes-sample.jsonld
${expectation_filename}=  building-simple-attributes-sample-expectation-query-attributes.jsonld
${attribute_airqualitylevel}=  https://uri.fiware.org/ns/data-models#airQualityLevel
${attribute_subcategory}=  https://uri.fiware.org/ns/data-models#subCategory

*** Test Cases ***                               
001_02_Query some attributes from an entity
    [Documentation]  Check that you can query some attributes from an entity
    [Tags]  mandatory

    ${entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${request}    ${response}=    Create Entity Selecting Content Type  ${filename}     ${entity_id}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code  201    ${response['status']}

    ${attributes_to_be_retrieved}=  Create List      ${attribute_airqualitylevel}  ${attribute_subcategory}
    ${response}=    Query Entity    ${entity_id}    ${CONTENT_TYPE_LD_JSON}    attrs=${attributes_to_be_retrieved}
    Check Response Status Code  200    ${response['status']}
    Check Response Body Containing Entity element    ${expectation_filename}    ${entity_id}    ${response['body']}

    [Teardown]  Delete Entity by Id Returning Response   ${entity_id}
 No newline at end of file
+26 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can query the geometry property from an entity
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

*** Variable ***
${building_id_prefix}=  urn:ngsi-ld:Building:
${filename}=  building-location-attribute-sample.jsonld
${expectation_filename}=  building-location-attribute-sample-expectation-query-geoproperty.jsonld
${geometry_property}=  location

*** Test Cases ***                               
001_03_Query the geometry property from an entity
    [Documentation]  Check that you can query the geometry property from an entity
    [Tags]  mandatory

    ${entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${request}    ${response}=    Create Entity Selecting Content Type  ${filename}     ${entity_id}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code  201    ${response['status']}

    ${response}=    Query Entity    ${entity_id}    ${CONTENT_TYPE_LD_JSON}    geoproperty=${geometry_property}
    Check Response Status Code  200    ${response['status']}
    Check Response Body Containing Entity element    ${expectation_filename}    ${entity_id}    ${response['body']}

    [Teardown]  Delete Entity by Id Returning Response   ${entity_id}
 No newline at end of file
+21 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot get an entity with invalid/missing id
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource

Test Template  Get Entity With Invalid/Missing Id

*** Test Cases ***                                                  ENTITY_ID                     EXPECTED_STATUS_CODE       PROBLEM_TYPE                      
002_01_Get an entity if the Entity Id is not present                ${EMPTY}                      400                        ${ERROR_TYPE_BAD_REQUEST_DATA}
002_02_Get an entity if the Entity Id is not a valid URI            thisisaninvaliduri            400                        ${ERROR_TYPE_BAD_REQUEST_DATA}

*** Keywords ***                               
Get Entity With Invalid/Missing Id
    [Arguments]  ${entity_id}    ${expected_status_code}    ${problem_type}
    [Documentation]  Check that you cannot get an entity with invalid/missing id
    [Tags]  mandatory    failing

    ${response}=    Query Entity    ${entity_id}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code  ${expected_status_code}    ${response['status']}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to      ${response}     ${problem_type}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response}
 No newline at end of file
+19 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot get an entity if the entity id is not known to the system
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

*** Variable ***
${building_id_prefix}=  urn:ngsi-ld:Building:

*** Test Cases ***                                                 
003_01_Get an entity if the Entity Id is not known to the system           
    [Documentation]  Check that you cannot get an entity if the entity id or attributes are not known to the system
    [Tags]  mandatory    failing

    ${entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${response}=    Query Entity    ${entity_id}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code  404    ${response['status']}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to      ${response}     ${ERROR_TYPE_RESOURCE_NOT_FOUND}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response}
 No newline at end of file
Loading