aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service/src/test/groovy')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy34
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueriesImplSpec.groovy4
2 files changed, 36 insertions, 2 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
index c87efce04..5588ec781 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
@@ -72,7 +72,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
def objectUnderTest = getObjectUnderTest()
def 'DMI Registration: Create, Update, Delete & Upgrade operations are processed in the right order'() {
- given: 'a registration with operations of all three types'
+ given: 'a registration with operations of all types'
def dmiRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server')
dmiRegistration.setCreatedCmHandles([new NcmpServiceCmHandle(cmHandleId: 'cmhandle-1', publicProperties: ['publicProp1': 'value'], dmiProperties: [:])])
dmiRegistration.setUpdatedCmHandles([new NcmpServiceCmHandle(cmHandleId: 'cmhandle-2', publicProperties: ['publicProp1': 'value'], dmiProperties: [:])])
@@ -96,6 +96,38 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
1 * objectUnderTest.parseAndProcessUpgradedCmHandlesInRegistration(*_)
}
+ def 'DMI Registration upgrade operation with upgrade node state #scenario'() {
+ given: 'a registration with upgrade operation'
+ def dmiRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server')
+ dmiRegistration.setUpgradedCmHandles(new UpgradedCmHandles(cmHandles: ['cmhandle-3'], moduleSetTag: 'some-module-set-tag'))
+ and: 'exception while checking cm handle state'
+ mockCmHandleQueries.cmHandleHasState('cmhandle-3', CmHandleState.READY) >> isReady
+ when: 'registration is processed'
+ def result = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiRegistration)
+ then: 'upgrade operation contains expected error code'
+ assert result.upgradedCmHandles.status[0] == expectedResponseStatus
+ where: 'the following parameters are used'
+ scenario | isReady || expectedResponseStatus
+ 'READY' | true || Status.SUCCESS
+ 'Not READY' | false || Status.FAILURE
+ }
+
+ def 'DMI Registration upgrade with exception #scenario'() {
+ given: 'a registration with upgrade operation'
+ def dmiRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server')
+ dmiRegistration.setUpgradedCmHandles(new UpgradedCmHandles(cmHandles: ['cmhandle-3'], moduleSetTag: 'some-module-set-tag'))
+ and: 'exception while checking cm handle state'
+ mockCmHandleQueries.cmHandleHasState('cmhandle-3', CmHandleState.READY) >> { throw exception }
+ when: 'registration is processed'
+ def result = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiRegistration)
+ then: 'upgrade operation contains expected error code'
+ assert result.upgradedCmHandles.ncmpResponseStatus.code[0] == expectedErrorCode
+ where: 'the following parameters are used'
+ scenario | exception || expectedErrorCode
+ 'data node not found' | new DataNodeNotFoundException('some-dataspace-name', 'some-anchor-name') || '100'
+ 'cm handle is invalid' | new DataValidationException('some error message', 'some error details') || '110'
+ }
+
def 'DMI Registration: Response from all operations types are in response'() {
given: 'a registration with operations of all three types'
def dmiRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server')
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueriesImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueriesImplSpec.groovy
index 78b09e6a1..1da3a55a5 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueriesImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueriesImplSpec.groovy
@@ -22,6 +22,7 @@
package org.onap.cps.ncmp.api.impl.inventory
import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevel
+import org.onap.cps.spi.utils.CpsValidator
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DMI_REGISTRY_ANCHOR
@@ -40,9 +41,10 @@ import spock.lang.Specification
class CmHandleQueriesImplSpec extends Specification {
def cpsDataPersistenceService = Mock(CpsDataPersistenceService)
+ def mockCpsValidator = Mock(CpsValidator)
def trustLevelPerCmHandle = [ 'my completed cm handle': TrustLevel.COMPLETE, 'my untrusted cm handle': TrustLevel.NONE ]
- def objectUnderTest = new CmHandleQueriesImpl(cpsDataPersistenceService, trustLevelPerCmHandle)
+ def objectUnderTest = new CmHandleQueriesImpl(cpsDataPersistenceService, trustLevelPerCmHandle, mockCpsValidator)
@Shared
def static sampleDataNodes = [new DataNode()]