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 43 forks source link

012_01 - Check that you can perform a partial update on an entity attribute (012_01_01 Check that you can partially update an attribute) #1510

Closed lafrigolet closed 11 months ago

lafrigolet commented 11 months ago

TP.NGSI-LD.ContextInformation.Provision.EntityAttributes.PartialAttributeUpdate.012_01 :: 012_01_01 Check that you can partially update an attribute

Context Broker Information:

Version: develop commit 238ac6c353325f8d486ef79ea137df20df12f277 Launch command: orionld -fg

012_01_01 Check that you can partially update an attribute

Value of root['speed'][1] changed from {'type': 'Property', 'value': 54.5, 'source': {'type': 'Property', 'value': 'GPS'}, 'datasetId': 'urn:ngsi-ld:Property:gpsBxyz123-speed'} to {'type': 'Property', 'value': 54.5, 'https://ngsi-ld-test-suite/context#source': {'type': 'Property', 'value': 'GPS'}, 'datasetId': 'urn:ngsi-ld:Property:gpsBxyz123-speed'}. Value of root['speed'][0] changed from {'type': 'Property', 'value': 55, 'source': {'type': 'Property', 'value': 'Speedometer'}, 'datasetId': 'urn:ngsi-ld:Property:speedometer'} to {'type': 'Property', 'value': 55, 'https://ngsi-ld-test-suite/context#source': {'type': 'Property', 'value': 'Speedometer'}, 'datasetId': 'urn:ngsi-ld:Property:speedometer'}.

Test Request/Response Flow

Create Entity Selecting Content Type

Request:

POST http://127.0.0.1:1026/ngsi-ld/v1/entities/
Host: 127.0.0.1:1026
User-Agent: python-requests/2.31.0
Accept-Encoding: gzip, deflate, br, zstd
Accept: */*
Connection: keep-alive
Content-Type: application/ld+json
Content-Length: 757

{"id": "urn:ngsi-ld:Vehicle:5492168330192197", "type": "Vehicle", "brandName": {"type": "Property", "value": "Mercedes"}, "isParked": {"type": "Relationship", "object": "urn:ngsi-ld:OffStreetParking:Downtown1", "observedAt": "2017-07-29T12:00:04Z", "providedBy": {"type": "Relationship", "object": "urn:ngsi-ld:Person:Bob"}}, "speed": [{"type": "Property", "value": 55, "source": {"type": "Property", "value": "Speedometer"}, "datasetId": "urn:ngsi-ld:Property:speedometer"}, {"type": "Property", "value": 54.5, "source": {"type": "Property", "value": "GPS"}, "datasetId": "urn:ngsi-ld:Property:gpsBxyz123-speed"}], "@context": ["https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"]}

Response:

HTTP/1.1 201 Created
Date: Mon, 18 Dec 2023 13:49:34 GMT
Location: /ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:5492168330192197
Content-Length: 0

### Partial Update Entity Attributes
#### Request:
PATCH http://127.0.0.1:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:5492168330192197/attrs/isParked
Host: 127.0.0.1:1026
User-Agent: python-requests/2.31.0
Accept-Encoding: gzip, deflate, br, zstd
Accept: */*
Connection: keep-alive
Content-Type: application/ld+json
Content-Length: 222

{"providedBy": {"type": "Relationship", "object": "urn:ngsi-ld:Person:JohnDoe"}, "@context": ["https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"]}

Response:

HTTP/1.1 204 No Content
Date: Mon, 18 Dec 2023 13:49:34 GMT

Retrieve Entity by Id

Request:

GET http://127.0.0.1:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:5492168330192197
Host: 127.0.0.1:1026
User-Agent: python-requests/2.31.0
Accept-Encoding: gzip, deflate, br, zstd
Accept: application/ld+json
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"

Response:

HTTP/1.1 200 OK
Date: Mon, 18 Dec 2023 13:49:34 GMT
Content-Type: application/ld+json
Content-Length: 788

{"@context":"https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld","id":"urn:ngsi-ld:Vehicle:5492168330192197","type":"Vehicle","speed":[{"type":"Property","value":55,"https://ngsi-ld-test-suite/context#source":{"type":"Property","value":"Speedometer"},"datasetId":"urn:ngsi-ld:Property:speedometer"},{"type":"Property","value":54.5,"https://ngsi-ld-test-suite/context#source":{"type":"Property","value":"GPS"},"datasetId":"urn:ngsi-ld:Property:gpsBxyz123-speed"}],"brandName":{"type":"Property","value":"Mercedes"},"isParked":{"object":"urn:ngsi-ld:OffStreetParking:Downtown1","type":"Relationship","providedBy":{"type":"Relationship","object":"urn:ngsi-ld:Person:JohnDoe"},"observedAt":"2017-07-29T12:00:04.000Z"}}

Delete Entity by Id

Request:

DELETE http://127.0.0.1:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:5492168330192197
Host: 127.0.0.1:1026
User-Agent: python-requests/2.31.0
Accept-Encoding: gzip, deflate, br, zstd
Accept: */*
Connection: keep-alive
Content-Length: 0

Response:

HTTP/1.1 204 No Content
Date: Mon, 18 Dec 2023 13:49:34 GMT