diff options
author | Lathishbabu Ganesan <lathishbabu.ganesan@ericsson.com> | 2019-02-26 09:13:30 -0500 |
---|---|---|
committer | Takamune Cho <takamune.cho@att.com> | 2019-02-26 17:44:11 +0000 |
commit | d6f7963013c9b16552509eb53381baef73740f8f (patch) | |
tree | ac795bcee0b2ca1a45900bad43581f0d3d98667f /appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle | |
parent | 8d0dfd93683134a3bd9cef8cf7c97f4c0d8e0386 (diff) |
Added test case for Attach volume class
Issue-ID: APPC-1467
Change-Id: Ifc902979c955df03ab847b4dd770bf737ff69eb9
Signed-off-by: Lathishbabu Ganesan <lathishbabu.ganesan@ericsson.com>
Diffstat (limited to 'appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle')
-rw-r--r-- | appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServerTest.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServerTest.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServerTest.java index 4ccbffd0d..6a88be96d 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServerTest.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServerTest.java @@ -1,4 +1,4 @@ -/* +/*- * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ @@ -21,13 +21,16 @@ package org.onap.appc.adapter.iaas.provider.operation.impl; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.List; import org.junit.Test; import org.onap.appc.exceptions.APPCException; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import com.att.cdp.exceptions.ZoneException; import com.att.cdp.zones.VolumeService; import com.att.cdp.zones.model.ModelObject; @@ -35,7 +38,6 @@ import com.att.cdp.zones.model.Server; import com.att.cdp.zones.model.Server.Status; import com.att.cdp.zones.model.Volume; - public class AttachVolumeServerTest { @Test @@ -52,4 +54,18 @@ public class AttachVolumeServerTest { assertTrue(rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext()) instanceof ModelObject); } + @Test + public void attachVolumeTestException() throws ZoneException, APPCException { + SvcLogicContext context = new SvcLogicContext(); + MockGenerator mg = new MockGenerator(Status.RUNNING); + Server server = mg.getServer(); + VolumeService volumeService = mock(VolumeService.class); + when(volumeService.getVolumes()).thenThrow(new ZoneException("Zone Exception")); + doReturn(mg.getContext()).when(server).getContext(); + doReturn(volumeService).when(mg.getContext()).getVolumeService(); + AttachVolumeServer attachVolumeServer = new AttachVolumeServer(); + attachVolumeServer.setProviderCache(mg.getProviderCacheMap()); + attachVolumeServer.executeProviderOperation(mg.getParams(), context); + assertEquals("FAILURE", context.getAttribute("VOLUME_STATUS")); + } } |