Commit a50ef884 authored by lopesg's avatar lopesg
Browse files

added common behaviours test

parent bb89d20b
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Verify throwing 503 – LDContextNotAvaliable error if remote JSON-LD @context cannot be retrieved 
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

Test Template  Get Entity With Invalid/Missing Id

*** Variable ***
${expected_status_code}=  503

*** Test Cases ***                              ENDPOINT                                                              FILENAME_PATH
043_01_endpoint /entities/                      ${ENTITIES_ENDPOINT_PATH}                                             entities/building-minimal-without-context-sample.jsonld
#043_02_endpoint /csourceRegistrations/          ${CONTEXT_SOURCE_REGISTRATION_ENDPOINT_PATH}                          csourceRegistrations/context-source-registration-without-context-sample.jsonld                         
#043_03_endpoint /subscriptions/                 ${SUBSCRIPTION_ENDPOINT_PATH}                                         csourceSubscriptions/subscription-without-context-sample.jsonld
#043_04_endpoint /csourceSubscriptions/          ${CONTEXT_SOURCE_REGISTRATION_SUBSCRIPTION_ENDPOINT_PATH}             csourceSubscriptions/subscription-without-context-sample.jsonld
#043_05_endpoint /temporal/entities/             ${TEMPORAL_ENTITIES_ENDPOINT_PATH}                                    temporalEntities/bus-temporal-representation-without-context-sample.jsonld

*** Keywords ***                               
Get Entity With Invalid/Missing Id
    [Arguments]  ${endpoint}     ${filename_path}
    [Documentation]  Verify throwing 503 – LDContextNotAvaliable error if remote JSON-LD @context cannot be retrieved 
    [Tags]  mandatory

    ${response}=    Create Request By Selecting Endpoint    ${endpoint}    ${filename_path}
    Check Response Status Code  ${expected_status_code}    ${response['status']}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to      ${response}     ${ERROR_TYPE_LD_CONTEXT_NOT_AVAILABLE}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response}
 No newline at end of file
+14 −0
Original line number Diff line number Diff line
{
   "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID",
   "type":"ContextSourceRegistration",
   "information":[
      {
         "entities":[
            {
               "type":"Building"
            }
         ]
      }
   ],
   "endpoint":"http://my.csource.org:1026"
}
 No newline at end of file
+16 −0
Original line number Diff line number Diff line
{
   "id":"urn:ngsi-ld:Subscription:randomUUID",
   "type":"Subscription",
   "entities":[
      {
         "type":"Building"
      }
   ],
   "notification":{
      "format":"keyValues",
      "endpoint":{
         "uri":"http://my.endpoint.org/notify",
         "accept":"application/json"
      }
   }
}
 No newline at end of file
+48 −0
Original line number Diff line number Diff line
{
   "id":"urn:ngsi-ld:Bus:randomUUID",
   "type":"Bus",
   "brandName":[
      {
         "type":"Property",
         "value":"Mercedes"
      }
   ],
   "speed":[
      {
         "type":"Property",
         "value":45,
         "observedAt":"2020-08-01T12:03:00Z"
      },
      {
         "type":"Property",
         "value":25,
         "observedAt":"2020-08-01T12:05:00Z"
      },
      {
         "type":"Property",
         "value":67,
         "observedAt":"2020-08-01T12:07:00Z"
      }
   ],
   "fuelLevel":[
      {
         "type":"Property",
         "value":210,
         "observedAt":"2020-08-01T12:03:00Z"
      },
      {
         "type":"Property",
         "value":145,
         "observedAt":"2020-08-01T13:05:00Z"
      },
      {
         "type":"Property",
         "value":124,
         "observedAt":"2020-08-01T14:07:00Z"
      }
   ],
   "@context":[
      "https://raw.githubusercontent.com/easy-global-market/ngsild-api-data-models/feature/add-json-ld-context-for-ngsi-ld-test-suite/ngsi-ld-test-suite/ngsi-ld-test-suite-context.jsonld",
      "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"
   ]
}
 No newline at end of file
+10 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ ${ENTITY_OPERATIONS_QUERY_ENDPOINT_PATH} entityOperations/query
${TEMPORAL_ENTITIES_ENDPOINT_PATH}       temporal/entities
${TEMPORAL_ENTITY_OPERATIONS_ENDPOINT_PATH}       temporal/entityOperations
${CONTEXT_SOURCE_REGISTRATION_ENDPOINT_PATH}       csourceRegistrations
${SUBSCRIPTION_ENDPOINT_PATH}       subscriptions/
${CONTEXT_SOURCE_REGISTRATION_SUBSCRIPTION_ENDPOINT_PATH}       csourceSubscriptions

${CONTENT_TYPE_JSON}            application/json
@@ -26,6 +27,7 @@ ${ERROR_TYPE_BAD_REQUEST_DATA} http://uri.etsi.org/ngsi-ld/errors/BadReques
${ERROR_TYPE_INVALID_REQUEST}      http://uri.etsi.org/ngsi-ld/errors/InvalidRequest
${ERROR_TYPE_RESOURCE_NOT_FOUND}      http://uri.etsi.org/ngsi-ld/errors/ResourceNotFound
${ERROR_TYPE_ALREADY_EXISTS}      http://uri.etsi.org/ngsi-ld/errors/AlreadyExists
${ERROR_TYPE_LD_CONTEXT_NOT_AVAILABLE}     http://uri.etsi.org/ngsi-ld/errors/LDContextNotAvailable

${response}

@@ -219,6 +221,14 @@ Delete Context Source Registration
    Output  response
    [return]  ${response}

Create Request By Selecting Endpoint
    [Arguments]  ${endpoint}     ${filename_path}
    ${entity_payload}=    Load Json From File    ${EXECDIR}/data/${filename_path}
    ${entity}=    Update Value To Json    ${entity_payload}     $..id   ${entity_id}
    &{headers}=  Create Dictionary  Content-Type=application/ld+json
    ${response}=  POST  ${endpoint}  body=${entity}  headers=${headers}
    Output  response

Create Entity
    [Arguments]  ${filename}    ${entity_id}
    ${entity_payload}=    Load Json From File    ${EXECDIR}/data/entities/${filename}