From 58810e232a2a0cd31bf70c35ef0cf38db9b66e0b Mon Sep 17 00:00:00 2001 From: Ken Zangelin Date: Wed, 30 Aug 2023 16:32:37 +0200 Subject: [PATCH] Fixed two erroneous type values in the response payload body (EntityTypeInformation => EntityTypeInfo and EntityAttributeList => AttributeList) --- CHANGES_NEXT_RELEASE | 1 + src/lib/orionld/db/dbEntityAttributesGet.cpp | 6 +-- .../mongoCppLegacyEntityTypeGet.cpp | 2 +- .../serviceRoutines/orionldGetEntityType.cpp | 4 +- .../0000_ngsild/ngsild_entity_attributes.test | 48 +++++++++---------- .../cases/0000_ngsild/ngsild_entity_type.test | 20 ++++---- .../ngsild_new_entity_attributes.test | 48 +++++++++---------- .../0000_ngsild/ngsild_new_entity_type.test | 20 ++++---- 8 files changed, 75 insertions(+), 74 deletions(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 39765eb16c..2638836662 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -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) diff --git a/src/lib/orionld/db/dbEntityAttributesGet.cpp b/src/lib/orionld/db/dbEntityAttributesGet.cpp index 9766ee71c9..5306c5c794 100644 --- a/src/lib/orionld/db/dbEntityAttributesGet.cpp +++ b/src/lib/orionld/db/dbEntityAttributesGet.cpp @@ -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); diff --git a/src/lib/orionld/mongoCppLegacy/mongoCppLegacyEntityTypeGet.cpp b/src/lib/orionld/mongoCppLegacy/mongoCppLegacyEntityTypeGet.cpp index ee13585be7..05311a58c4 100644 --- a/src/lib/orionld/mongoCppLegacy/mongoCppLegacyEntityTypeGet.cpp +++ b/src/lib/orionld/mongoCppLegacy/mongoCppLegacyEntityTypeGet.cpp @@ -114,7 +114,7 @@ bool kjAttributesWithTypeExtract(KjNode* kjTree, KjNode* entityP) // Example broker response payload body for GET /types/{typeName}: // { // "id": , -// "type": "EntityTypeInformation", +// "type": "EntityTypeInfo", // "typeName": , // 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 diff --git a/src/lib/orionld/serviceRoutines/orionldGetEntityType.cpp b/src/lib/orionld/serviceRoutines/orionldGetEntityType.cpp index 1fc71f6508..d6498ebc0c 100644 --- a/src/lib/orionld/serviceRoutines/orionldGetEntityType.cpp +++ b/src/lib/orionld/serviceRoutines/orionldGetEntityType.cpp @@ -178,7 +178,7 @@ bool orionldGetEntityType(void) // The output object looks like this: // { // "id": , - // "type": "EntityTypeInformation", + // "type": "EntityTypeInfo", // "typeName": , // 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 @@ -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"); diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_entity_attributes.test b/test/functionalTest/cases/0000_ngsild/ngsild_entity_attributes.test index edf127dfae..62e79ba9f2 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_entity_attributes.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_entity_attributes.test @@ -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: