Added test case for Rebuild Server 09/79209/3
authorLathishbabu Ganesan <lathishbabu.ganesan@ericsson.com>
Tue, 26 Feb 2019 17:15:09 +0000 (12:15 -0500)
committerTakamune Cho <takamune.cho@att.com>
Thu, 28 Feb 2019 14:42:26 +0000 (14:42 +0000)
Issue-ID: APPC-1502
Change-Id: Idff986e1727e13c5a402184b416365328418c7ab
Signed-off-by: Lathishbabu Ganesan <lathishbabu.ganesan@ericsson.com>
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestRebuildServer.java

index 8b426b9..0a34d55 100644 (file)
@@ -6,6 +6,8 @@
  * ================================================================================
  * Copyright (C) 2017 Amdocs
  * =============================================================================
+ * Modifications Copyright (C) 2019 Ericsson
+ * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -25,6 +27,7 @@ package org.onap.appc.adapter.iaas.provider.operation.impl;
 import org.junit.Assert;
 import org.junit.Test;
 import static org.mockito.Mockito.verify;
+import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.inOrder;
 import org.mockito.InOrder;
 import com.att.cdp.zones.model.Server;
@@ -32,6 +35,7 @@ import com.att.cdp.zones.model.Server.Status;
 import com.att.cdp.exceptions.ZoneException;
 import org.onap.appc.adapter.iaas.provider.operation.impl.RebuildServer;
 import org.onap.appc.exceptions.APPCException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.onap.appc.configuration.Configuration;
 import org.onap.appc.configuration.ConfigurationFactory;
 
@@ -127,5 +131,27 @@ public class TestRebuildServer {
         inOrderTest.verify(server).rebuild("linuxBase");
         inOrderTest.verify(server).start();
     }
+    
+    @Test
+    public void rebuildServerException() throws ZoneException, APPCException {
+        MockGenerator mg = new MockGenerator(null);
+        RebuildServer rbs = new RebuildServer();
+        rbs.setProviderCache(mg.getProviderCacheMap());
+        rbs.setRebuildSleepTime(0);
+        SvcLogicContext context = new SvcLogicContext();
+        rbs.executeProviderOperation(mg.getParams(), context);
+        assertEquals("ERROR", context.getAttribute("REBUILD_STATUS"));
+    }
+    
+    @Test
+    public void rebuildServerDeleted() throws ZoneException, APPCException {
+        MockGenerator mg = new MockGenerator(Status.DELETED);
+        RebuildServer rbs = new RebuildServer();
+        rbs.setProviderCache(mg.getProviderCacheMap());
+        rbs.setRebuildSleepTime(0);
+        SvcLogicContext context = new SvcLogicContext();
+        rbs.executeProviderOperation(mg.getParams(), context);
+        assertEquals("ERROR", context.getAttribute("REBUILD_STATUS"));
+    }
 
 }
\ No newline at end of file