From b5a393e2a1032f3132582426e8875de99e559061 Mon Sep 17 00:00:00 2001 From: Lathishbabu Ganesan Date: Tue, 26 Feb 2019 12:15:09 -0500 Subject: Added test case for Rebuild Server Issue-ID: APPC-1502 Change-Id: Idff986e1727e13c5a402184b416365328418c7ab Signed-off-by: Lathishbabu Ganesan --- .../provider/operation/impl/TestRebuildServer.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle') diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestRebuildServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestRebuildServer.java index 8b426b9e5..0a34d556a 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestRebuildServer.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/provider/operation/impl/TestRebuildServer.java @@ -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 -- cgit 1.2.3-korg