CPS Validator Changes
[cps.git] / cps-ncmp-service / src / test / groovy / org / onap / cps / ncmp / api / impl / NetworkCmProxyDataServiceImplSpec.groovy
index 91eb218..58ca06b 100644 (file)
@@ -33,10 +33,12 @@ import org.onap.cps.ncmp.api.inventory.InventoryPersistence
 import org.onap.cps.ncmp.api.inventory.LockReasonCategory
 import org.onap.cps.ncmp.api.inventory.DataStoreSyncState
 import org.onap.cps.ncmp.api.models.CmHandleQueryApiParameters
+import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse
 import org.onap.cps.ncmp.api.models.ConditionApiProperties
 import org.onap.cps.ncmp.api.models.DmiPluginRegistration
 import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle
 import org.onap.cps.spi.exceptions.CpsException
+import org.onap.cps.spi.exceptions.DataNodeNotFoundException
 import org.onap.cps.spi.exceptions.DataValidationException
 import org.onap.cps.spi.model.CmHandleQueryServiceParameters
 import spock.lang.Shared
@@ -55,6 +57,10 @@ import static org.onap.cps.ncmp.api.impl.operations.DmiOperations.DataStoreEnum.
 import static org.onap.cps.ncmp.api.impl.operations.DmiOperations.DataStoreEnum.PASSTHROUGH_RUNNING
 import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.CREATE
 import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.UPDATE
+import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.CM_HANDLE_DOES_NOT_EXIST
+import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.CM_HANDLE_INVALID_ID
+import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.UNKNOWN_ERROR
+
 
 class NetworkCmProxyDataServiceImplSpec extends Specification {
 
@@ -105,17 +111,6 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
                 >> { new ResponseEntity<>(HttpStatus.CREATED) }
     }
 
-    def 'Write resource data for pass-through running from DMI using an invalid id.'() {
-        when: 'write resource data is called'
-            objectUnderTest.writeResourceDataPassThroughRunningForCmHandle('invalid cm handle name',
-                'testResourceId', CREATE,
-                '{some-json}', 'application/json')
-        then: 'exception is thrown'
-            thrown(DataValidationException.class)
-        and: 'DMI is not invoked'
-            0 * mockDmiDataOperations.writeResourceDataPassThroughRunningFromDmi(_, _, _, _, _)
-    }
-
     def 'Get resource data for pass-through operational from DMI.'() {
         given: 'get data node is called'
             mockCpsDataService.getDataNode('NCMP-Admin', 'ncmp-dmi-registry',
@@ -166,15 +161,6 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
             1 * mockInventoryPersistence.getYangResourcesModuleReferences('some-cm-handle')
     }
 
-    def 'Getting Yang Resources with an invalid #scenario.'() {
-        when: 'yang resources is called'
-            objectUnderTest.getYangResourcesModuleReferences('invalid cm handle with spaces')
-        then: 'a data validation exception is thrown'
-            thrown(DataValidationException)
-        and: 'CPS module services is not invoked'
-            0 * mockInventoryPersistence.getYangResourcesModuleReferences(*_)
-    }
-
     def 'Get a cm handle.'() {
         given: 'the system returns a yang modelled cm handle'
             def dmiServiceName = 'some service name'
@@ -203,15 +189,6 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
 
     }
 
-    def 'Get a cm handle with an invalid id.'() {
-        when: 'getting cm handle details for a given cm handle id with an invalid name'
-            objectUnderTest.getNcmpServiceCmHandle('invalid cm handle with spaces')
-        then: 'an exception is thrown'
-            thrown(DataValidationException)
-        and: 'the yang model cm handle retriever is not invoked'
-            0 * mockInventoryPersistence.getYangModelCmHandle(*_)
-    }
-
     def 'Get cm handle public properties'() {
         given: 'a yang modelled cm handle'
             def dmiProperties = [new YangModelCmHandle.Property('prop', 'some DMI property')]
@@ -225,15 +202,6 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
             result == [ 'public prop' : 'some public prop' ]
     }
 
-    def 'Get cm handle public properties with an invalid id.'() {
-        when: 'getting cm handle public properties for a given cm handle id with an invalid name'
-            objectUnderTest.getCmHandlePublicProperties('invalid cm handle with spaces')
-        then: 'an exception is thrown'
-            thrown(DataValidationException)
-        and: 'the yang model cm handle retriever is not invoked'
-            0 * mockInventoryPersistence.getYangModelCmHandle(*_)
-    }
-
     def 'Get cm handle composite state'() {
         given: 'a yang modelled cm handle'
             def compositeState = new CompositeState(cmHandleState: CmHandleState.ADVISED,
@@ -252,15 +220,6 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
             result == compositeState
     }
 
-    def 'Get cm handle composite state with an invalid id.'() {
-        when: 'getting cm handle composite state for a given cm handle id with an invalid name'
-            objectUnderTest.getCmHandleCompositeState('invalid cm handle with spaces')
-        then: 'an exception is thrown'
-            thrown(DataValidationException)
-        and: 'the yang model cm handle retriever is not invoked'
-            0 * mockInventoryPersistence.getYangModelCmHandle(_)
-    }
-
     def 'Update resource data for pass-through running from dmi using POST #scenario DMI properties.'() {
         given: 'cpsDataService returns valid datanode'
             mockCpsDataService.getDataNode('NCMP-Admin', 'ncmp-dmi-registry',