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
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 {
>> { 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',
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'
}
- 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')]
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,
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',