added atleat one assert statement in test case
[appc.git] / appc-adapters / appc-iaas-adapter / appc-iaas-adapter-bundle / src / test / java / org / onap / appc / adapter / iaas / provider / operation / impl / TestRestartServer.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
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
14  *
15  *      http://www.apache.org/licenses/LICENSE-2.0
16  *
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.
22  *
23  * ============LICENSE_END=========================================================
24  */
25 package org.onap.appc.adapter.iaas.provider.operation.impl;
26
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;
34
35 import com.att.cdp.exceptions.ZoneException;
36 import com.att.cdp.zones.model.Server;
37 import com.att.cdp.zones.model.Server.Status;
38
39 public class TestRestartServer {
40
41     @Test
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());
47         try {
48             rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext());
49         } catch (APPCException e) {
50             Assert.fail("Exception during RestartServer.executeProviderOperation");
51         }
52         InOrder inOrderTest = inOrder(server);
53         inOrderTest.verify(server).resume();
54     }
55
56     @Test
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());
63         
64         InOrder inOrderTest = inOrder(server);
65         inOrderTest.verify(server).stop();
66         inOrderTest.verify(server).start();
67     }
68     
69     @Test
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());
76         
77         InOrder inOrderTest = inOrder(server);
78         inOrderTest.verify(server).start();
79     }
80     
81     @Test
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());
88         assertNotNull(mg);
89             
90     }
91 }