Commit 236b02cf authored by Houcem Kacem's avatar Houcem Kacem
Browse files

feat: allow entities creation with a dynamic id

parent d4d05a01
Loading
Loading
Loading
Loading
+25 −16
Original line number Diff line number Diff line
@@ -3,64 +3,73 @@ Documentation Check that you can create a batch of entities
Variables   ../../../../../../resources/variables.py
Resource    ../../../../../../resources/ApiUtils.resource
Resource    ../../../../../../resources/AssertionUtils.resource
Resource    ../../../../../../resources/JsonUtils.resource
Library     REST    ${url}
Library     JSONLibrary
Library     String

*** Variable ***
${batch_endpoint}=    entityOperations/create
${endpoint}=    entities
${building_id_prefix}=  urn:ngsi-ld:Building:

*** Test Case ***
Create batch of minimal entities
    [Documentation]  Check that you can create a batch of minimal entities
    [Tags]  critical

    ${first_minimal_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-minimal.jsonld
    ${second_minimal_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-minimal-2.jsonld
    @{entities_to_be_created}=  Create List   ${first_minimal_entity}     ${second_minimal_entity}
    ${first_entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${second_entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${first_entity}=    Load Entity    building-minimal-sample.jsonld      ${first_entity_id}
    ${second_entity}=    Load Entity    building-minimal-sample.jsonld      ${second_entity_id}
    @{entities_to_be_created}=  Create List   ${first_entity}     ${second_entity}

    Batch Create Entities   @{entities_to_be_created}

    @{expected_entities_ids}=  Create List   urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9     urn:ngsi-ld:Building:56hy789-eft6-9987-be54-adr45nf567ddz
    @{expected_entities_ids}=  Create List   ${first_entity_id}     ${second_entity_id}
    Check Response Status Code Set To  201
    Check Response Body Set To  @{expected_entities_ids}

    #TODO call Batch Delete Entities
    Delete Entity by Id  urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9
    Delete Entity by Id  urn:ngsi-ld:Building:56hy789-eft6-9987-be54-adr45nf567ddz
    Delete Entity by Id  ${first_entity_id}
    Delete Entity by Id  ${second_entity_id}

Create batch of entities having only simple properties
    [Documentation]  Check that you can create a batch of entities having only simple properties
    [Tags]  critical

    ${first_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-simple-attributes.jsonld
    ${second_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-simple-attributes-2.jsonld
    ${first_entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${second_entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${first_entity}=    Load Entity    building-simple-attributes-sample.jsonld      ${first_entity_id}
    ${second_entity}=    Load Entity    building-simple-attributes-sample.jsonld      ${second_entity_id}
    @{entities_to_be_created}=  Create List   ${first_entity}     ${second_entity}

    Batch Create Entities   @{entities_to_be_created}

    @{expected_entities_ids}=  Create List   urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9     urn:ngsi-ld:Building:56hy789-eft6-9987-be54-adr45nf567ddz
    @{expected_entities_ids}=  Create List   ${first_entity_id}     ${second_entity_id}
    Check Response Status Code Set To  201
    Check Response Body Set To  @{expected_entities_ids}

    #TODO call Batch Delete Entities
    Delete Entity by Id  urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9
    Delete Entity by Id  urn:ngsi-ld:Building:56hy789-eft6-9987-be54-adr45nf567ddz
    Delete Entity by Id  ${first_entity_id}
    Delete Entity by Id  ${second_entity_id}

Create batch of entities having multiple attributes
    [Documentation]  Check that you can create a batch of entities having multiple attributes
    [Tags]  critical

    ${first_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-relationship-of-property.jsonld
    ${second_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-relationship-of-property-2.jsonld
    ${first_entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${second_entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${first_entity}=    Load Entity    building-relationship-of-property-sample.jsonld      ${first_entity_id}
    ${second_entity}=    Load Entity    building-relationship-of-property-sample.jsonld      ${second_entity_id}
    @{entities_to_be_created}=  Create List   ${first_entity}     ${second_entity}

    Batch Create Entities   @{entities_to_be_created}

    @{expected_entities_ids}=  Create List   urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9     urn:ngsi-ld:Building:56hy789-eft6-9987-be54-adr45nf567ddz
    @{expected_entities_ids}=  Create List   ${first_entity_id}     ${second_entity_id}
    Check Response Status Code Set To  201
    Check Response Body Set To  @{expected_entities_ids}

    #TODO call Batch Delete Entities
    Delete Entity by Id  urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9
    Delete Entity by Id  urn:ngsi-ld:Building:56hy789-eft6-9987-be54-adr45nf567ddz
    Delete Entity by Id  ${first_entity_id}
    Delete Entity by Id  ${second_entity_id}
+13 −8
Original line number Diff line number Diff line
@@ -3,32 +3,37 @@ Documentation Check that you can create a batch of entities where some will su
Variables   ../../../../../../resources/variables.py
Resource    ../../../../../../resources/ApiUtils.resource
Resource    ../../../../../../resources/AssertionUtils.resource
Resource    ../../../../../../resources/JsonUtils.resource
Library     REST    ${url}
Library     JSONLibrary
Library     String

Suite Setup      Create Entity  building-minimal-3.jsonld
Suite Setup      Create Entity  building-minimal-sample.jsonld     urn:ngsi-ld:Building:92f041b428b9

*** Variable ***
${batch_endpoint}=    entityOperations/create
${endpoint}=    entities
${building_id_prefix}=  urn:ngsi-ld:Building:

*** Test Case ***
Create batch of valid and invalid entities
    [Documentation]  Check that you can create a batch of valid and invalid entities
    [Tags]  critical

    ${first_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-minimal.jsonld
    ${second_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-minimal-2.jsonld
    ${already_existing_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-minimal-3.jsonld
    ${first_entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${second_entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${first_entity}=    Load Entity    building-minimal-sample.jsonld      ${first_entity_id}
    ${second_entity}=    Load Entity    building-minimal-sample.jsonld      ${second_entity_id}
    ${already_existing_entity}=    Load Entity    building-minimal-sample.jsonld      urn:ngsi-ld:Building:92f041b428b9
    @{entities_to_be_created}=  Create List   ${first_entity}     ${second_entity}     ${already_existing_entity}

    Batch Create Entities   @{entities_to_be_created}

    @{expected_entities_ids}=  Create List   urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9     urn:ngsi-ld:Building:56hy789-eft6-9987-be54-adr45nf567ddz
    @{expected_entities_ids}=  Create List   ${first_entity_id}     ${second_entity_id}
    Check Response Status Code Set To  207
    Check Response Body Set To  @{expected_entities_ids}

    #TODO call Batch Delete Entities
    Delete Entity by Id  urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9
    Delete Entity by Id  urn:ngsi-ld:Building:56hy789-eft6-9987-be54-adr45nf567ddz
    Delete Entity by Id  urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-345789442
 No newline at end of file
    Delete Entity by Id  ${first_entity_id}
    Delete Entity by Id  ${second_entity_id}
    Delete Entity by Id  urn:ngsi-ld:Building:92f041b428b9
 No newline at end of file
+0 −8
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:Building:56hy789-eft6-9987-be54-adr45nf567ddz",
    "type": "Building",
    "@context": [
        "https://fiware.github.io/data-models/context.jsonld",
        "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"
    ]
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-345789442",
    "id": "urn:ngsi-ld:Building:randomUUID",
    "type": "Building",
    "@context": [
        "https://fiware.github.io/data-models/context.jsonld",
+1 −1
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:Building:56hy789-eft6-9987-be54-adr45nf567ddz",
    "id": "urn:ngsi-ld:Building:randomUUID",
    "type": "Building",
    "name": {
        "type": "Property",
Loading