2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Modifications Copyright (C) 2019 IBM
10 * =============================================================================
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 * ============LICENSE_END=========================================================
25 package org.onap.appc.adapter.iaas.provider.operation.impl;
27 import static org.mockito.Mockito.inOrder;
28 import org.junit.Assert;
29 import org.junit.Test;
30 import org.mockito.InOrder;
31 import org.onap.appc.exceptions.APPCException;
32 import org.onap.appc.exceptions.UnknownProviderException;
34 import com.att.cdp.exceptions.ZoneException;
35 import com.att.cdp.zones.model.Server;
36 import com.att.cdp.zones.model.Server.Status;
38 public class TestRestartServer {
41 public void restartServerSuspended() throws ZoneException {
42 MockGenerator mg = new MockGenerator(Status.SUSPENDED);
43 Server server = mg.getServer();
44 RestartServer rbs = new RestartServer();
45 rbs.setProviderCache(mg.getProviderCacheMap());
47 rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext());
48 } catch (APPCException e) {
49 Assert.fail("Exception during RestartServer.executeProviderOperation");
51 InOrder inOrderTest = inOrder(server);
52 inOrderTest.verify(server).resume();
56 public void restartServerRunning() throws ZoneException, UnknownProviderException {
57 MockGenerator mg = new MockGenerator(Status.RUNNING);
58 Server server = mg.getServer();
59 RestartServer rbs = new RestartServer();
60 rbs.setProviderCache(mg.getProviderCacheMap());
61 rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext());
63 InOrder inOrderTest = inOrder(server);
64 inOrderTest.verify(server).stop();
65 inOrderTest.verify(server).start();
69 public void pauseServerRunning() throws ZoneException, UnknownProviderException {
70 MockGenerator mg = new MockGenerator(Status.READY);
71 Server server = mg.getServer();
72 RestartServer rbs = new RestartServer();
73 rbs.setProviderCache(mg.getProviderCacheMap());
74 rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext());
76 InOrder inOrderTest = inOrder(server);
77 inOrderTest.verify(server).start();
81 public void pauseServerError() throws ZoneException, UnknownProviderException {
82 MockGenerator mg = new MockGenerator(Status.ERROR);
83 Server server = mg.getServer();
84 RestartServer rbs = new RestartServer();
85 rbs.setProviderCache(mg.getProviderCacheMap());
86 rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext());