diff options
author | kjaniak <kornel.janiak@nokia.com> | 2018-01-31 14:35:09 +0100 |
---|---|---|
committer | Takamune Cho <tc012c@att.com> | 2018-02-02 15:08:58 +0000 |
commit | 72931ce2fe5005f7855f1e2ce35fc67d6b10f4dc (patch) | |
tree | 896bcbb70eec28b3b4c24b96aa91ad5e8832500b /appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org | |
parent | 36ca66b20d827cac5a6a2199e31369f6ad9e6a9c (diff) |
Extraction of nested try catch in migrateServer
Try catch block placed in new private method conductServerMigration, UT for class added.
Issue-ID: APPC-557
Change-Id: I7f968dbc87ee3be4125da6a8a3e201af99aa420e
Signed-off-by: kjaniak <kornel.janiak@nokia.com>
Diffstat (limited to 'appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org')
-rw-r--r-- | appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestMigrateServer.java | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestMigrateServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestMigrateServer.java index e6d9f21a6..f1682c22d 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestMigrateServer.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestMigrateServer.java @@ -23,21 +23,27 @@ */ package org.onap.appc.adapter.iaas.provider.operation.impl; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.anyInt; +import com.att.cdp.zones.model.ModelObject; import org.junit.Assert; import org.junit.Test; import org.mockito.Matchers; +import org.onap.appc.adapter.iaas.ProviderAdapter; import org.onap.appc.exceptions.APPCException; import com.att.cdp.exceptions.ZoneException; import com.att.cdp.zones.model.Server; import com.att.cdp.zones.model.Server.Status; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; + +import java.util.Map; +import java.util.Optional; + +import static java.util.Optional.of; +import static org.mockito.Mockito.*; public class TestMigrateServer { @Test - public void migrateServerSuspended() throws ZoneException { + public void should_migrateSuspendedServer() throws ZoneException { MockGenerator mg = new MockGenerator(Status.SUSPENDED); Server server = mg.getServer(); MigrateServer rbs = new MigrateServer(); @@ -50,4 +56,27 @@ public class TestMigrateServer { verify(mg.getComputeService()).migrateServer(MockGenerator.SERVER_ID); verify(server, atLeastOnce()).waitForStateChange(anyInt(), anyInt(), Matchers.anyVararg()); } + + @Test + public void should_returnNullAsServer(){ + + // given + Map<String, String> params = mock(Map.class); + SvcLogicContext svcLogicContext = mock(SvcLogicContext.class); + MockGenerator mockGenerator = new MockGenerator(Status.READY); + MigrateServer migrateServer = new MigrateServer(); + migrateServer.setProviderCache(mockGenerator.getProviderCacheMap()); + ModelObject modelObject = new Server(); + + // when + when(params.get(ProviderAdapter.PROPERTY_INSTANCE_URL)).thenReturn(null); + try { + modelObject = migrateServer.executeProviderOperation(params,svcLogicContext); + } catch (APPCException e) { + Assert.fail("Exception during MigrateServer.executeProviderOperation"); + } + + // then + Assert.assertNull(modelObject); + } }
\ No newline at end of file |