FIWARE / context.Orion-LD

Context Broker and CEF building block for context data management which supports both the NGSI-LD and the NGSI-v2 APIs
https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.06.01_60/gs_CIM009v010601p.pdf
GNU Affero General Public License v3.0
50 stars 41 forks source link

Problems with the resolution of property names with context #1444

Open flopezag opened 11 months ago

flopezag commented 11 months ago

TP.NGSI-LD.ContextInformation.Consumption.Discovery.RetrieveAvailableEntityTypes.022_01 :: Check that you can retrieve a list of NGSI-LD entity types

Orion-LD version: 1.5.0-PRE-1443

022_01_01 WithoutJsonLdContext

Create Entity Selecting Content Type

Request ->

{
    "method": "POST",
    "url": "http://localhost:1026/ngsi-ld/v1/entities/",
    "headers": {
        "User-Agent": "python-requests/2.31.0",
        "Accept-Encoding": "gzip, deflate",
        "Accept": "*/*",
        "Connection": "keep-alive",
        "Content-Type": "application/json",
        "Link": "<https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"",
        "Content-Length": "345"
    },
    "body": {
        "id": "urn:ngsi-ld:Building:8711417551484105",
        "type": "Building",
        "name": {
            "type": "Property",
            "value": "Eiffel Tower"
        },
        "subCategory": {
            "type": "Property",
            "value": "tourism"
        },
        "airQualityLevel": {
            "type": "Property",
            "value": 4,
            "unitCode": "C62",
            "observedAt": "2020-09-09T16:40:00.000Z"
        },
        "almostFull": {
            "type": "Property",
            "value": false
        }
    }
}

Response ->

{
    "url": "http://localhost:1026/ngsi-ld/v1/entities/",
    "headers": {
        "Date": "Wed, 13 Sep 2023 10:50:35 GMT",
        "Location": "/ngsi-ld/v1/entities/urn:ngsi-ld:Building:8711417551484105",
        "Content-Length": "0"
    },
    "status_code": 201,
    "reason": "Created",
    "body": null
}

Create Entity Selecting Content Type

Request ->

{
    "method": "POST",
    "url": "http://localhost:1026/ngsi-ld/v1/entities/",
    "headers": {
        "User-Agent": "python-requests/2.31.0",
        "Accept-Encoding": "gzip, deflate",
        "Accept": "*/*",
        "Connection": "keep-alive",
        "Content-Type": "application/json",
        "Link": "<https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"",
        "Content-Length": "249"
    },
    "body": {
        "id": "urn:ngsi-ld:Vehicle:7057999912179892",
        "type": "Vehicle",
        "brandName": {
            "type": "Property",
            "value": "Mercedes"
        },
        "isParked": {
            "type": "Relationship",
            "object": "urn:ngsi-ld:OffStreetParking:Downtown1",
            "observedAt": "2017-07-29T12:00:04Z"
        }
    }
}

Response ->

{
    "url": "http://localhost:1026/ngsi-ld/v1/entities/",
    "headers": {
        "Date": "Wed, 13 Sep 2023 10:50:35 GMT",
        "Location": "/ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:7057999912179892",
        "Content-Length": "0"
    },
    "status_code": 201,
    "reason": "Created",
    "body": null
}

Retrieve Entity Types

Request ->

{
    "method": "GET",
    "url": "http://localhost:1026/ngsi-ld/v1/types/",
    "headers": {
        "User-Agent": "python-requests/2.31.0",
        "Accept-Encoding": "gzip, deflate",
        "Accept": "*/*",
        "Connection": "keep-alive"
    },
    "body": null
}

Response ->

{
    "url": "http://localhost:1026/ngsi-ld/v1/types/",
    "headers": {
        "Date": "Wed, 13 Sep 2023 10:50:35 GMT",
        "Link": "<https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
        "Content-Type": "application/json",
        "Content-Length": "294"
    },
    "status_code": 200,
    "reason": "OK",
    "body": {
        "id": "urn:ngsi-ld:EntityTypeList:5e365ef2-5223-11ee-bbf3-0242ac120106",
        "type": "EntityTypeList",
        "typeList": [
            "https://ngsi-ld-test-suite/context#Building",
            "https://ngsi-ld-test-suite/context#Vehicle",
            "https://uri.fiware.org/ns/dataModels#Building",
            "https://uri.fiware.org/ns/dataModels#Person"
        ]
    }
}

Dictionary comparison failed with ->

{
-   'id': 'urn:ngsi-ld:EntityTypeList:randomUUID',
+   'id': 'urn:ngsi-ld:EntityTypeList:5e365ef2-5223-11ee-bbf3-0242ac120106',
   'type': 'EntityTypeList',
   'typeList': [
     'https://ngsi-ld-test-suite/context#Building',
     'https://ngsi-ld-test-suite/context#Vehicle',
+     'https://uri.fiware.org/ns/dataModels#Building',
+     'https://uri.fiware.org/ns/dataModels#Person',
   ],
 }

Length is 1
Item root['typeList'][2] added to iterable.
Item root['typeList'][3] added to iterable.

Delete Entity by Id Returning Response

Request ->

{
    "method": "DELETE",
    "url": "http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:8711417551484105",
    "headers": {
        "User-Agent": "python-requests/2.31.0",
        "Accept-Encoding": "gzip, deflate",
        "Accept": "*/*",
        "Connection": "keep-alive",
        "Content-Length": "0"
    },
    "body": null
}

Response ->

{
    "url": "http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:8711417551484105",
    "headers": {
        "Date": "Wed, 13 Sep 2023 10:50:35 GMT"
    },
    "status_code": 204,
    "reason": "No Content",
    "body": null
}

Delete Entity by Id Returning Response Request ->

{
    "method": "DELETE",
    "url": "http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:7057999912179892",
    "headers": {
        "User-Agent": "python-requests/2.31.0",
        "Accept-Encoding": "gzip, deflate",
        "Accept": "*/*",
        "Connection": "keep-alive",
        "Content-Length": "0"
    },
    "body": null
}

Response ->

{
    "url": "http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:7057999912179892",
    "headers": {
        "Date": "Wed, 13 Sep 2023 10:50:35 GMT"
    },
    "status_code": 204,
    "reason": "No Content",
    "body": null
}

022_01_02 WithJsonLdContext

Create Entity Selecting Content Type Request ->

{
    "method": "POST",
    "url": "http://localhost:1026/ngsi-ld/v1/entities/",
    "headers": {
        "User-Agent": "python-requests/2.31.0",
        "Accept-Encoding": "gzip, deflate",
        "Accept": "*/*",
        "Connection": "keep-alive",
        "Content-Type": "application/json",
        "Link": "<https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"",
        "Content-Length": "345"
    },
    "body": {
        "id": "urn:ngsi-ld:Building:9557902680765269",
        "type": "Building",
        "name": {
            "type": "Property",
            "value": "Eiffel Tower"
        },
        "subCategory": {
            "type": "Property",
            "value": "tourism"
        },
        "airQualityLevel": {
            "type": "Property",
            "value": 4,
            "unitCode": "C62",
            "observedAt": "2020-09-09T16:40:00.000Z"
        },
        "almostFull": {
            "type": "Property",
            "value": false
        }
    }
}

Response ->

{
    "url": "http://localhost:1026/ngsi-ld/v1/entities/",
    "headers": {
        "Date": "Wed, 13 Sep 2023 10:50:35 GMT",
        "Location": "/ngsi-ld/v1/entities/urn:ngsi-ld:Building:9557902680765269",
        "Content-Length": "0"
    },
    "status_code": 201,
    "reason": "Created",
    "body": null
}

Create Entity Selecting Content Type Request ->

{
    "method": "POST",
    "url": "http://localhost:1026/ngsi-ld/v1/entities/",
    "headers": {
        "User-Agent": "python-requests/2.31.0",
        "Accept-Encoding": "gzip, deflate",
        "Accept": "*/*",
        "Connection": "keep-alive",
        "Content-Type": "application/json",
        "Link": "<https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"",
        "Content-Length": "249"
    },
    "body": {
        "id": "urn:ngsi-ld:Vehicle:2271121070552242",
        "type": "Vehicle",
        "brandName": {
            "type": "Property",
            "value": "Mercedes"
        },
        "isParked": {
            "type": "Relationship",
            "object": "urn:ngsi-ld:OffStreetParking:Downtown1",
            "observedAt": "2017-07-29T12:00:04Z"
        }
    }
}

Response ->

{
    "url": "http://localhost:1026/ngsi-ld/v1/entities/",
    "headers": {
        "Date": "Wed, 13 Sep 2023 10:50:35 GMT",
        "Location": "/ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:2271121070552242",
        "Content-Length": "0"
    },
    "status_code": 201,
    "reason": "Created",
    "body": null
}

Retrieve Entity Types Request ->

{
    "method": "GET",
    "url": "http://localhost:1026/ngsi-ld/v1/types/",
    "headers": {
        "User-Agent": "python-requests/2.31.0",
        "Accept-Encoding": "gzip, deflate",
        "Accept": "*/*",
        "Connection": "keep-alive",
        "Link": "<https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\""
    },
    "body": null
}

Response ->

{
    "url": "http://localhost:1026/ngsi-ld/v1/types/",
    "headers": {
        "Date": "Wed, 13 Sep 2023 10:50:35 GMT",
        "Link": "<https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
        "Content-Type": "application/json",
        "Content-Length": "224"
    },
    "status_code": 200,
    "reason": "OK",
    "body": {
        "id": "urn:ngsi-ld:EntityTypeList:5e4107bc-5223-11ee-8a57-0242ac120106",
        "type": "EntityTypeList",
        "typeList": [
            "Building",
            "Vehicle",
            "https://uri.fiware.org/ns/dataModels#Building",
            "https://uri.fiware.org/ns/dataModels#Person"
        ]
    }
}

Dictionary comparison failed with ->

 {
-   'id': 'urn:ngsi-ld:EntityTypeList:randomUUID',
+   'id': 'urn:ngsi-ld:EntityTypeList:5e4107bc-5223-11ee-8a57-0242ac120106',
   'type': 'EntityTypeList',
   'typeList': [
     'Building',
     'Vehicle',
+     'https://uri.fiware.org/ns/dataModels#Building',
+     'https://uri.fiware.org/ns/dataModels#Person',
   ],
 }

Length is 1
Item root['typeList'][2] added to iterable.
Item root['typeList'][3] added to iterable.

Delete Entity by Id Returning Response Request ->

{
    "method": "DELETE",
    "url": "http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:9557902680765269",
    "headers": {
        "User-Agent": "python-requests/2.31.0",
        "Accept-Encoding": "gzip, deflate",
        "Accept": "*/*",
        "Connection": "keep-alive",
        "Content-Length": "0"
    },
    "body": null
}

Response ->

{
    "url": "http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:9557902680765269",
    "headers": {
        "Date": "Wed, 13 Sep 2023 10:50:35 GMT"
    },
    "status_code": 204,
    "reason": "No Content",
    "body": null
}

Delete Entity by Id Returning Response Request ->

{
    "method": "DELETE",
    "url": "http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:2271121070552242",
    "headers": {
        "User-Agent": "python-requests/2.31.0",
        "Accept-Encoding": "gzip, deflate",
        "Accept": "*/*",
        "Connection": "keep-alive",
        "Content-Length": "0"
    },
    "body": null
}
Response ->
{
    "url": "http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:2271121070552242",
    "headers": {
        "Date": "Wed, 13 Sep 2023 10:50:35 GMT"
    },
    "status_code": 204,
    "reason": "No Content",
    "body": null
}
kzangeli commented 11 months ago

So, two errors here, as far as I can see:

  1. If you don't give an @context, you will not get shortnames (for attributes expanded using a non-core context)
  2. That "randomUUID" ...
    .. Seems like two bugs in the test suite, nothing got the broker.