summaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test')
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestMigrateServer.java37
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