diff options
author | seanbeirne <sean.beirne@est.tech> | 2024-11-20 11:00:49 +0000 |
---|---|---|
committer | seanbeirne <sean.beirne@est.tech> | 2024-11-20 11:01:55 +0000 |
commit | 9060818e7974ca09a06b715533161876b94fde84 (patch) | |
tree | b0844b358694e6fc4ae3c4c59afcb820ffe10fd7 /cps-ncmp-service/src/test | |
parent | d8af6808847b8fbd044077e7c4688ca869b70169 (diff) |
Update error response for ncmp endpoints
Issue-ID: CPS-2386
Change-Id: I0d1f09cff202e055be255b365fc2271a5ee43b37
Signed-off-by: seanbeirne <sean.beirne@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/test')
5 files changed, 14 insertions, 13 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationServicePropertyHandlerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationServicePropertyHandlerSpec.groovy index 1beab20def..6213258303 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationServicePropertyHandlerSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationServicePropertyHandlerSpec.groovy @@ -162,9 +162,9 @@ class CmHandleRegistrationServicePropertyHandlerSpec extends Specification { } where: scenario | cmHandleId | exception || expectedError | expectedErrorText - 'Cm Handle does not exist' | 'cmHandleId' | new DataNodeNotFoundException(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR) || CM_HANDLES_NOT_FOUND | 'cm handle id(s) not found' + 'Cm Handle does not exist' | 'cmHandleId' | new DataNodeNotFoundException(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR) || CM_HANDLES_NOT_FOUND | 'cm handle reference(s) not found' 'Unknown' | 'cmHandleId' | new RuntimeException('Failed') || UNKNOWN_ERROR | 'Failed' - 'Invalid cm handle id' | 'cmHandleId with spaces' | new DataValidationException('Name Validation Error.', cmHandleId + 'contains an invalid character') || CM_HANDLE_INVALID_ID | 'cm-handle has an invalid character(s) in id' + 'Invalid cm handle id' | 'cmHandleId with spaces' | new DataValidationException('Name Validation Error.', cmHandleId + 'contains an invalid character') || CM_HANDLE_INVALID_ID | 'cm handle reference has an invalid character(s) in id' } def 'Multiple update operations in a single request'() { @@ -193,7 +193,7 @@ class CmHandleRegistrationServicePropertyHandlerSpec extends Specification { assert it.status == Status.FAILURE assert it.cmHandle == cmHandleId assert it.ncmpResponseStatus == CM_HANDLES_NOT_FOUND - assert it.errorText == 'cm handle id(s) not found' + assert it.errorText == 'cm handle reference(s) not found' } then: 'the replace list method is called twice' 2 * mockInventoryPersistence.replaceListContent(cmHandleXpath, _) diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationServiceSpec.groovy index 70e26d993c..a69721b6aa 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationServiceSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationServiceSpec.groovy @@ -399,10 +399,10 @@ class CmHandleRegistrationServiceSpec extends Specification { and: 'the cm handle state is not updated to "DELETED"' 0 * mockLcmEventsCmHandleStateHandler.updateCmHandleStateBatch(_, CmHandleState.DELETED) where: - scenario | cmHandleId | deleteListElementException || expectedError | expectedErrorText - 'cm-handle does not exist' | 'cmhandle' | new DataNodeNotFoundException('', '', '') || CM_HANDLES_NOT_FOUND | 'cm handle id(s) not found' - 'cm-handle has invalid name' | 'cm handle with space' | new DataValidationException('', '') || CM_HANDLE_INVALID_ID | 'cm-handle has an invalid character(s) in id' - 'an unexpected exception' | 'cmhandle' | new RuntimeException('Failed') || UNKNOWN_ERROR | 'Failed' + scenario | deleteListElementException || expectedError | expectedErrorText + 'cm-handle does not exist' | new DataNodeNotFoundException('', '', '') || CM_HANDLES_NOT_FOUND | 'cm handle reference(s) not found' + 'cm-handle has invalid name' | new DataValidationException('', '') || CM_HANDLE_INVALID_ID | 'cm handle reference has an invalid character(s) in id' + 'an unexpected exception' | new RuntimeException('Failed') || UNKNOWN_ERROR | 'Failed' } def 'Set Cm Handle Data Sync Enabled Flag where data sync flag is #scenario'() { diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy index 00f092ff75..4d8855c4b2 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy @@ -27,12 +27,12 @@ import org.onap.cps.api.CpsAnchorService import org.onap.cps.api.CpsDataService import org.onap.cps.api.CpsModuleService import org.onap.cps.impl.utils.CpsValidator +import org.onap.cps.ncmp.api.exceptions.CmHandleNotFoundException import org.onap.cps.ncmp.api.inventory.models.CompositeState import org.onap.cps.ncmp.impl.inventory.models.CmHandleState import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle import org.onap.cps.spi.CascadeDeleteAllowed import org.onap.cps.spi.FetchDescendantsOption -import org.onap.cps.spi.exceptions.DataNodeNotFoundException import org.onap.cps.spi.model.DataNode import org.onap.cps.spi.model.ModuleDefinition import org.onap.cps.spi.model.ModuleReference @@ -327,8 +327,9 @@ class InventoryPersistenceImplSpec extends Specification { when: 'getting the cm handle data node' objectUnderTest.getCmHandleDataNodeByAlternateId('alternate id') then: 'no data found exception thrown' - def thrownException = thrown(DataNodeNotFoundException) - assert thrownException.getMessage().contains('DataNode not found') + def thrownException = thrown(CmHandleNotFoundException) + assert thrownException.getMessage().contains('Cm handle not found') + assert thrownException.getDetails().contains('No cm handles found with reference alternate id') } def 'Get multiple cm handle data nodes by alternate ids, passing empty collection'() { diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/utils/AlternateIdMatcherSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/utils/AlternateIdMatcherSpec.groovy index bd1faa2705..0a58039d8a 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/utils/AlternateIdMatcherSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/utils/AlternateIdMatcherSpec.groovy @@ -20,9 +20,9 @@ package org.onap.cps.ncmp.impl.utils +import org.onap.cps.ncmp.api.exceptions.CmHandleNotFoundException import org.onap.cps.ncmp.exceptions.NoAlternateIdMatchFoundException import org.onap.cps.ncmp.impl.inventory.InventoryPersistence -import org.onap.cps.spi.exceptions.DataNodeNotFoundException import org.onap.cps.spi.model.DataNode import spock.lang.Specification @@ -35,7 +35,7 @@ class AlternateIdMatcherSpec extends Specification { given: 'cm handle in the registry with alternate id /a/b' mockInventoryPersistence.getCmHandleDataNodeByAlternateId('/a/b') >> new DataNode() and: 'no other cm handle' - mockInventoryPersistence.getCmHandleDataNodeByAlternateId(_) >> { throw new DataNodeNotFoundException('', '') } + mockInventoryPersistence.getCmHandleDataNodeByAlternateId(_) >> { throw new CmHandleNotFoundException('') } } def 'Finding longest alternate id matches.'() { diff --git a/cps-ncmp-service/src/test/resources/dataOperationResponseEvent.json b/cps-ncmp-service/src/test/resources/dataOperationResponseEvent.json index 611d47d1a3..827250f5fd 100644 --- a/cps-ncmp-service/src/test/resources/dataOperationResponseEvent.json +++ b/cps-ncmp-service/src/test/resources/dataOperationResponseEvent.json @@ -1 +1 @@ -[{"operationId":"operational-14","ids":["unknown-cm-handle"],"resourceIdentifier":"some resource identifier","options":"some option","statusCode":"100","statusMessage":"cm handle id(s) not found"},{"operationId":"operational-14","ids":["non-ready-cm-handle"],"resourceIdentifier":"some resource identifier","options":"some option","statusCode":"101","statusMessage":"cm handle(s) not ready"},{"operationId":"running-12","ids":["non-ready-cm-handle"],"resourceIdentifier":"some resource identifier","options":"some option","statusCode":"101","statusMessage":"cm handle(s) not ready"}]
\ No newline at end of file +[{"operationId":"operational-14","ids":["unknown-cm-handle"],"resourceIdentifier":"some resource identifier","options":"some option","statusCode":"100","statusMessage":"cm handle reference(s) not found"},{"operationId":"operational-14","ids":["non-ready-cm-handle"],"resourceIdentifier":"some resource identifier","options":"some option","statusCode":"101","statusMessage":"cm handle(s) not ready"},{"operationId":"running-12","ids":["non-ready-cm-handle"],"resourceIdentifier":"some resource identifier","options":"some option","statusCode":"101","statusMessage":"cm handle(s) not ready"}]
\ No newline at end of file |