package org.onap.appc.adapter.iaas.provider.operation.impl; import static org.mockito.Mockito.inOrder; import org.junit.Assert; import org.junit.Test; import org.mockito.InOrder; 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; public class TestRestartServer { @Test public void restartServerSuspended() throws ZoneException { MockGenerator mg = new MockGenerator(Status.SUSPENDED); Server server = mg.getServer(); RestartServer rbs = new RestartServer(); rbs.setProviderCache(mg.getProviderCacheMap()); try { rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext()); } catch (APPCException e) { Assert.fail("Exception during RestartServer.executeProviderOperation"); } InOrder inOrderTest = inOrder(server); inOrderTest.verify(server).resume(); } @Test public void restartServerRunning() throws ZoneException { MockGenerator mg = new MockGenerator(Status.RUNNING); Server server = mg.getServer(); RestartServer rbs = new RestartServer(); rbs.setProviderCache(mg.getProviderCacheMap()); try { rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext()); } catch (APPCException e) { Assert.fail("Exception during RestartServer.executeProviderOperation"); } InOrder inOrderTest = inOrder(server); inOrderTest.verify(server).stop(); inOrderTest.verify(server).start(); } }