aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy
diff options
context:
space:
mode:
authorseanbeirne <sean.beirne@est.tech>2024-11-04 16:36:10 +0000
committerseanbeirne <sean.beirne@est.tech>2024-11-18 10:43:36 +0000
commit7e6fee9321e4f13cc4a0d81f83fc3693309cb5d7 (patch)
treef1a87adf60644eb4eb991274a6f6d44df3457e12 /cps-ncmp-service/src/test/groovy
parent37962e3faca4f2306546c4f70d480b0c323d2c68 (diff)
Update error response for ncmp endpoints
Issue-ID: CPS-2386 Change-Id: Ib4f37858f5f107e350a13e4bf7ed93493864ce60 Signed-off-by: seanbeirne <sean.beirne@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/test/groovy')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationServicePropertyHandlerSpec.groovy6
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationServiceSpec.groovy8
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy7
3 files changed, 11 insertions, 10 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..ce4a449b21 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
@@ -28,11 +28,11 @@ 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.inventory.models.CompositeState
+import org.onap.cps.ncmp.api.exceptions.CmHandleNotFoundException
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'() {