2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.so.bpmn.infrastructure.appc.tasks;
22 import static org.junit.Assert.assertEquals;
23 import static org.mockito.Mockito.doNothing;
24 import static org.mockito.Mockito.doReturn;
25 import static org.mockito.Mockito.times;
26 import static org.mockito.Mockito.verify;
28 import java.util.HashMap;
29 import java.util.Optional;
30 import java.util.UUID;
32 import org.junit.Before;
33 import org.junit.Test;
34 import org.onap.appc.client.lcm.model.Action;
35 import org.onap.so.BaseIntegrationTest;
36 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
37 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
38 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
39 import org.onap.so.db.catalog.beans.ControllerSelectionReference;
40 import org.springframework.beans.factory.annotation.Autowired;
42 public class AppcRunTasksITTest extends BaseIntegrationTest {
45 private AppcRunTasks appcRunTasks;
47 private GenericVnf genericVnf;
48 private RequestContext requestContext;
49 private String msoRequestId;
52 public void before() {
53 genericVnf = setGenericVnf();
54 msoRequestId = UUID.randomUUID().toString();
55 requestContext = setRequestContext();
56 requestContext.setMsoRequestId(msoRequestId);
57 gBBInput.setRequestContext(requestContext);
61 public void preProcessActivityTest() throws Exception {
62 appcRunTasks.preProcessActivity(execution);
63 assertEquals(execution.getVariable("actionQuiesceTraffic"), Action.QuiesceTraffic);
64 assertEquals(execution.getVariable("rollbackQuiesceTraffic"), false);
68 public void runAppcCommandTest() throws Exception {
69 Action action = Action.QuiesceTraffic;
70 ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
71 controllerSelectionReference.setControllerName("testName");
72 controllerSelectionReference.setActionCategory(action.toString());
73 controllerSelectionReference.setVnfType("testVnfType");
75 doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.QuiesceTraffic.toString());
77 execution.setVariable("aicIdentity", "testAicIdentity");
79 String vnfId = genericVnf.getVnfId();
80 genericVnf.setIpv4OamAddress("testOamIpAddress");
81 String payload = "{\"testName\":\"testValue\",}";
82 RequestParameters requestParameters = new RequestParameters();
83 requestParameters.setPayload(payload);
84 gBBInput.getRequestContext().setRequestParameters(requestParameters);
86 String controllerType = "testName";
87 HashMap<String, String> payloadInfo = new HashMap<String, String>();
88 payloadInfo.put("vnfName", "testVnfName1");
89 payloadInfo.put("aicIdentity", "testAicIdentity");
90 payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
91 payloadInfo.put("vserverIdList", null);
92 payloadInfo.put("vfModuleId", null);
93 payloadInfo.put("identityUrl", null);
94 payloadInfo.put("vmIdList", null);
96 doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
98 appcRunTasks.runAppcCommand(execution, action);
99 verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);