2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
24 package org.onap.appc.adapter.iaas.provider.operation.impl;
26 import static org.mockito.Mockito.doReturn;
27 import static org.mockito.Mockito.mock;
28 import static org.mockito.Mockito.verify;
29 import java.util.LinkedList;
30 import java.util.List;
31 import org.junit.Assert;
32 import org.junit.Test;
33 import org.onap.appc.Constants;
34 import org.onap.appc.adapter.iaas.ProviderAdapter;
35 import org.onap.appc.configuration.Configuration;
36 import org.onap.appc.configuration.ConfigurationFactory;
37 import org.onap.appc.exceptions.APPCException;
38 import com.att.cdp.exceptions.ZoneException;
39 import com.att.cdp.zones.StackService;
40 import com.att.cdp.zones.model.Server;
41 import com.att.cdp.zones.model.Stack;
42 import com.att.cdp.zones.model.Server.Status;
44 public class TestTerminateStack {
47 public void terminateStack() throws ZoneException {
48 MockGenerator mg = new MockGenerator(Status.SUSPENDED);
49 Server server = mg.getServer();
50 StackService stackService = mock(StackService.class);
51 Stack stack1 = mock(Stack.class);
52 doReturn("stack1").when(stack1).getId();
53 doReturn("stack1").when(stack1).getName();
54 com.att.cdp.zones.model.Stack.Status stackStatus =
55 com.att.cdp.zones.model.Stack.Status.DELETED;
56 doReturn(stackStatus).when(stack1).getStatus();
57 doReturn(mg.getContext()).when(stack1).getContext();
58 List<Stack> stackList = new LinkedList<Stack>();
59 stackList.add(stack1);
60 doReturn(stackList).when(stackService).getStacks();
61 doReturn(stack1).when(stackService).getStack("stack1", "stack1");
62 doReturn(stackService).when(mg.getContext()).getStackService();
63 mg.getParams().put(ProviderAdapter.PROPERTY_STACK_ID, "stack1");
65 TerminateStack rbs = new TerminateStack();
66 rbs.setProviderCache(mg.getProviderCacheMap());
68 rbs.executeProviderOperation(mg.getParams(), mg.getSvcLogicContext());
69 } catch (APPCException e) {
70 Assert.fail("Exception during TerminateStack.executeProviderOperation");
72 verify(stackService).deleteStack(stack1);