Skip to content

Commit

Permalink
Fixed two erroneous type values in the response payload body (EntityT…
Browse files Browse the repository at this point in the history
…ypeInformation => EntityTypeInfo and EntityAttributeList => AttributeList)
  • Loading branch information
kzangeli committed Aug 30, 2023
1 parent b5381f1 commit 58810e2
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 74 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Fixed issues:
* #1419 - Fixed a bug in the cleanup of the "URL being downloaded list" - not being cleaned up in case of an error
* #280 - Added extensive logging for downloading of contexts
* #280 - Fixed two erroneous type values in the response payload body (EntityTypeInformation => EntityTypeInfo and EntityAttributeList => AttributeList)
6 changes: 3 additions & 3 deletions src/lib/orionld/db/dbEntityAttributesGet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ static KjNode* getEntityAttributesResponse(KjNode* sortedArrayP)
{
char entityAttributesId[128];

strncpy(entityAttributesId, "urn:ngsi-ld:EntityAttributeList:", sizeof(entityAttributesId) - 1);
uuidGenerate(&entityAttributesId[32], sizeof(entityAttributesId) - 32, false);
strncpy(entityAttributesId, "urn:ngsi-ld:AttributeList:", sizeof(entityAttributesId) - 1);
uuidGenerate(&entityAttributesId[26], sizeof(entityAttributesId) - 26, false);

KjNode* attributeNodeResponseP = kjObject(orionldState.kjsonP, NULL);
KjNode* idNodeP = kjString(orionldState.kjsonP, "id", entityAttributesId);
KjNode* typeNodeP = kjString(orionldState.kjsonP, "type", "EntityAttributeList");
KjNode* typeNodeP = kjString(orionldState.kjsonP, "type", "AttributeList");

kjChildAdd(attributeNodeResponseP, idNodeP);
kjChildAdd(attributeNodeResponseP, typeNodeP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool kjAttributesWithTypeExtract(KjNode* kjTree, KjNode* entityP)
// Example broker response payload body for GET /types/{typeName}:
// {
// "id": <FQN of the type>,
// "type": "EntityTypeInformation",
// "type": "EntityTypeInfo",
// "typeName": <shortname>, // Mandatory! (will try to change that - only if shortName found)
// "entityCount": 27, // Number of entities with this type
// "attributeDetails": [ // Array of Attribute - See GET /attributes?details=true
Expand Down
4 changes: 2 additions & 2 deletions src/lib/orionld/serviceRoutines/orionldGetEntityType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ bool orionldGetEntityType(void)
// The output object looks like this:
// {
// "id": <FQN of the type>,
// "type": "EntityTypeInformation",
// "type": "EntityTypeInfo",
// "typeName": <shortname>, // Mandatory! (will try to change that - only if shortName found)
// "entityCount": 27, // Number of entities with this type
// "attributeDetails": [ // Array of Attribute - See GET /attributes?details=true
Expand All @@ -197,7 +197,7 @@ bool orionldGetEntityType(void)
orionldState.responseTree = kjObject(orionldState.kjsonP, NULL);

KjNode* idNodeP = kjString(orionldState.kjsonP, "id", typeExpanded);
KjNode* typeNodeP = kjString(orionldState.kjsonP, "type", "EntityTypeInformation");
KjNode* typeNodeP = kjString(orionldState.kjsonP, "type", "EntityTypeInfo");
KjNode* typeNameNodeP = kjString(orionldState.kjsonP, "typeName", typeAlias);
KjNode* entityCountNodeP = kjInteger(orionldState.kjsonP, "entityCount", entities);
KjNode* attributeDetailsNodeP = kjArray(orionldState.kjsonP, "attributeDetails");
Expand Down
48 changes: 24 additions & 24 deletions test/functionalTest/cases/0000_ngsild/ngsild_entity_attributes.test
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ echo
01. GET Entity Attributes - see empty array
===========================================
HTTP/1.1 200 OK
Content-Length: 139
Content-Length: 127
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)

{
"id": "urn:ngsi-ld:EntityAttributeList:REGEX(.*)",
"type": "EntityAttributeList",
"id": "urn:ngsi-ld:AttributeList:REGEX(.*)",
"type": "AttributeList",
"attributeList": []
}

Expand All @@ -261,7 +261,7 @@ Location: /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E0
03. GET Entity Attributes - see three attributes
================================================
HTTP/1.1 200 OK
Content-Length: 139
Content-Length: 127
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
Expand All @@ -272,8 +272,8 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
"P2",
"R1"
],
"id": "urn:ngsi-ld:EntityAttributeList:REGEX(.*)",
"type": "EntityAttributeList"
"id": "urn:ngsi-ld:AttributeList:REGEX(.*)",
"type": "AttributeList"
}


Expand All @@ -289,7 +289,7 @@ Location: /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E1
05. GET Entity Attributes - see four attributes (P1, P2, P3, and R1)
====================================================================
HTTP/1.1 200 OK
Content-Length: 144
Content-Length: 132
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
Expand All @@ -301,8 +301,8 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
"P3",
"R1"
],
"id": "urn:ngsi-ld:EntityAttributeList:REGEX(.*)",
"type": "EntityAttributeList"
"id": "urn:ngsi-ld:AttributeList:REGEX(.*)",
"type": "AttributeList"
}


Expand All @@ -318,7 +318,7 @@ Location: /ngsi-ld/v1/csourceRegistrations/urn:ngsi-ld:reg:1
07. GET Entity Attributes - see four attributes (P1, P2, P3, and R1)
====================================================================
HTTP/1.1 200 OK
Content-Length: 144
Content-Length: 132
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
Expand All @@ -330,8 +330,8 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
"P3",
"R1"
],
"id": "urn:ngsi-ld:EntityAttributeList:REGEX(.*)",
"type": "EntityAttributeList"
"id": "urn:ngsi-ld:AttributeList:REGEX(.*)",
"type": "AttributeList"
}


Expand All @@ -347,7 +347,7 @@ Location: /ngsi-ld/v1/csourceRegistrations/urn:ngsi-ld:reg:2
09. GET Entity Attributes - see six attributes (P1-P4, and R1-R2)
=================================================================
HTTP/1.1 200 OK
Content-Length: 154
Content-Length: 142
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
Expand All @@ -361,8 +361,8 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
"R1",
"R2"
],
"id": "urn:ngsi-ld:EntityAttributeList:REGEX(.*)",
"type": "EntityAttributeList"
"id": "urn:ngsi-ld:AttributeList:REGEX(.*)",
"type": "AttributeList"
}


Expand All @@ -378,7 +378,7 @@ Location: /ngsi-ld/v1/csourceRegistrations/urn:ngsi-ld:reg:3
11. GET Entity Attributes - see ten attributes (P1-P5, and R1-R5)
=================================================================
HTTP/1.1 200 OK
Content-Length: 174
Content-Length: 162
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
Expand All @@ -396,8 +396,8 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
"R4",
"R5"
],
"id": "urn:ngsi-ld:EntityAttributeList:REGEX(.*)",
"type": "EntityAttributeList"
"id": "urn:ngsi-ld:AttributeList:REGEX(.*)",
"type": "AttributeList"
}


Expand All @@ -420,7 +420,7 @@ Date: REGEX(.*)
13. GET Entity Attributes - see only P4 and R2 from R2
======================================================
HTTP/1.1 200 OK
Content-Length: 134
Content-Length: 122
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
Expand All @@ -430,15 +430,15 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
"P4",
"R2"
],
"id": "urn:ngsi-ld:EntityAttributeList:REGEX(.*)",
"type": "EntityAttributeList"
"id": "urn:ngsi-ld:AttributeList:REGEX(.*)",
"type": "AttributeList"
}


14. Same same, but Accept: application/ld+json
==============================================
HTTP/1.1 200 OK
Content-Length: 212
Content-Length: 200
Content-Type: application/ld+json
Date: REGEX(.*)

Expand All @@ -448,8 +448,8 @@ Date: REGEX(.*)
"P4",
"R2"
],
"id": "urn:ngsi-ld:EntityAttributeList:REGEX(.*)",
"type": "EntityAttributeList"
"id": "urn:ngsi-ld:AttributeList:REGEX(.*)",
"type": "AttributeList"
}


Expand Down
20 changes: 10 additions & 10 deletions test/functionalTest/cases/0000_ngsild/ngsild_entity_type.test
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Location: /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E3
04. GET Entity Type T1 - see T1, count 1, and attrs P1 and R1
=============================================================
HTTP/1.1 200 OK
Content-Length: 398
Content-Length: 391
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
Expand All @@ -230,7 +230,7 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
],
"entityCount": 1,
"id": "https://uri.etsi.org/ngsi-ld/default-context/T1",
"type": "EntityTypeInformation",
"type": "EntityTypeInfo",
"typeName": "T1"
}

Expand All @@ -247,7 +247,7 @@ Location: /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E5
06. GET Entity Type T1 - see T1, count 2, and attrs P1, P2, R1, and R2
======================================================================
HTTP/1.1 200 OK
Content-Length: 656
Content-Length: 649
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
Expand Down Expand Up @@ -289,7 +289,7 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
],
"entityCount": 2,
"id": "https://uri.etsi.org/ngsi-ld/default-context/T1",
"type": "EntityTypeInformation",
"type": "EntityTypeInfo",
"typeName": "T1"
}

Expand All @@ -306,7 +306,7 @@ Location: /ngsi-ld/v1/entities/urn:ngsi-ld:entities:E7
08. GET Entity Type T1 - see T1, count 3, and attrs P1, P2, R1, and R2
======================================================================
HTTP/1.1 200 OK
Content-Length: 708
Content-Length: 701
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
Expand Down Expand Up @@ -352,15 +352,15 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
],
"entityCount": 3,
"id": "https://uri.etsi.org/ngsi-ld/default-context/T1",
"type": "EntityTypeInformation",
"type": "EntityTypeInfo",
"typeName": "T1"
}


09. Same same, but Accept: application/ld+json
==============================================
HTTP/1.1 200 OK
Content-Length: 786
Content-Length: 779
Content-Type: application/ld+json
Date: REGEX(.*)

Expand Down Expand Up @@ -406,15 +406,15 @@ Date: REGEX(.*)
],
"entityCount": 3,
"id": "https://uri.etsi.org/ngsi-ld/default-context/T1",
"type": "EntityTypeInformation",
"type": "EntityTypeInfo",
"typeName": "T1"
}


10. Same same, but type in URL as long name
===========================================
HTTP/1.1 200 OK
Content-Length: 786
Content-Length: 779
Content-Type: application/ld+json
Date: REGEX(.*)

Expand Down Expand Up @@ -460,7 +460,7 @@ Date: REGEX(.*)
],
"entityCount": 3,
"id": "https://uri.etsi.org/ngsi-ld/default-context/T1",
"type": "EntityTypeInformation",
"type": "EntityTypeInfo",
"typeName": "T1"
}

Expand Down
Loading

0 comments on commit 58810e2

Please sign in to comment.