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 static org.junit.Assert.assertNotNull;
30 import org.junit.Test;
31 import org.mockito.InOrder;
32 import org.onap.appc.exceptions.APPCException;
33 import org.onap.appc.exceptions.UnknownProviderException;
35 import com.att.cdp.exceptions.ZoneException;
36 import com.att.cdp.zones.model.Server;
37 import com.att.cdp.zones.model.Server.Status;
39 public class TestRestartServer {
42 public void restartServerSuspended() throws ZoneException {
43 MockGenerator mg = new MockGenerator(Status.SUSPENDED);
44 Server server = mg.getServer();
45 RestartServer rbs = new RestartServer();
46 rbs.setProviderCache(mg.getProviderCacheMap());
48 rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext());
49 } catch (APPCException e) {
50 Assert.fail("Exception during RestartServer.executeProviderOperation");
52 InOrder inOrderTest = inOrder(server);
53 inOrderTest.verify(server).resume();
57 public void restartServerRunning() throws ZoneException, UnknownProviderException {
58 MockGenerator mg = new MockGenerator(Status.RUNNING);
59 Server server = mg.getServer();
60 RestartServer rbs = new RestartServer();
61 rbs.setProviderCache(mg.getProviderCacheMap());
62 rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext());
64 InOrder inOrderTest = inOrder(server);
65 inOrderTest.verify(server).stop();
66 inOrderTest.verify(server).start();
70 public void pauseServerRunning() throws ZoneException, UnknownProviderException {
71 MockGenerator mg = new MockGenerator(Status.READY);
72 Server server = mg.getServer();
73 RestartServer rbs = new RestartServer();
74 rbs.setProviderCache(mg.getProviderCacheMap());
75 rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext());
77 InOrder inOrderTest = inOrder(server);
78 inOrderTest.verify(server).start();
82 public void pauseServerError() throws ZoneException, UnknownProviderException {
83 MockGenerator mg = new MockGenerator(Status.ERROR);
84 Server server = mg.getServer();
85 RestartServer rbs = new RestartServer();
86 rbs.setProviderCache(mg.getProviderCacheMap());
87 rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext());