Search in sources :

Example 11 with Action

use of org.onap.appc.client.lcm.model.Action in project so by onap.

the class ConfigurationScaleOutTest method callAppcClientTest.

@Test
public void callAppcClientTest() throws Exception {
    Action action = Action.ConfigScaleOut;
    String vnfId = genericVnf.getVnfId();
    String controllerType = "testType";
    String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\"," + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\"" + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
    HashMap<String, String> payloadInfo = new HashMap<String, String>();
    payloadInfo.put("vnfName", "testVnfName");
    payloadInfo.put("vfModuleId", "testVfModuleId");
    execution.setVariable("action", Action.ConfigScaleOut.toString());
    execution.setVariable("msoRequestId", msoRequestId);
    execution.setVariable("controllerType", controllerType);
    execution.setVariable("vnfId", "testVnfId1");
    execution.setVariable("vnfName", "testVnfName");
    execution.setVariable("vfModuleId", "testVfModuleId");
    execution.setVariable("payload", payload);
    doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
    configurationScaleOut.callAppcClient(execution);
    verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
}
Also used : Action(org.onap.appc.client.lcm.model.Action) HashMap(java.util.HashMap) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 12 with Action

use of org.onap.appc.client.lcm.model.Action in project so by onap.

the class AppcRunTasksIT method runAppcCommandTest.

@Test
public void runAppcCommandTest() throws Exception {
    Action action = Action.QuiesceTraffic;
    ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
    controllerSelectionReference.setControllerName("testName");
    controllerSelectionReference.setActionCategory(action.toString());
    controllerSelectionReference.setVnfType("testVnfType");
    doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.QuiesceTraffic.toString());
    execution.setVariable("aicIdentity", "testAicIdentity");
    String vnfId = genericVnf.getVnfId();
    genericVnf.setIpv4OamAddress("testOamIpAddress");
    String payload = "{\"testName\":\"testValue\",}";
    RequestParameters requestParameters = new RequestParameters();
    requestParameters.setPayload(payload);
    gBBInput.getRequestContext().setRequestParameters(requestParameters);
    String controllerType = "testName";
    HashMap<String, String> payloadInfo = new HashMap<String, String>();
    payloadInfo.put("vnfName", "testVnfName1");
    payloadInfo.put("aicIdentity", "testAicIdentity");
    payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
    payloadInfo.put("vserverIdList", null);
    payloadInfo.put("vfModuleId", null);
    payloadInfo.put("identityUrl", null);
    payloadInfo.put("vmIdList", null);
    doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
    appcRunTasks.runAppcCommand(execution, action);
    verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
}
Also used : Action(org.onap.appc.client.lcm.model.Action) ControllerSelectionReference(org.onap.so.db.catalog.beans.ControllerSelectionReference) HashMap(java.util.HashMap) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters) Test(org.junit.Test) BaseIntegrationTest(org.onap.so.BaseIntegrationTest)

Example 13 with Action

use of org.onap.appc.client.lcm.model.Action in project so by onap.

the class GenericVnfHealthCheckTest method callAppcClientExceptionTest.

@Test
public void callAppcClientExceptionTest() {
    expectedException.expect(BpmnError.class);
    Action action = Action.HealthCheck;
    String vnfId = genericVnf.getVnfId();
    String payload = "{\"testName\":\"testValue\",}";
    String controllerType = "testType";
    HashMap<String, String> payloadInfo = new HashMap<>();
    payloadInfo.put("vnfName", "testVnfName");
    payloadInfo.put("vfModuleId", "testVfModuleId");
    payloadInfo.put("oamIpAddress", "testOamIpAddress");
    payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
    execution.setVariable("action", Action.HealthCheck.toString());
    execution.setVariable("msoRequestId", msoRequestId);
    execution.setVariable("controllerType", controllerType);
    execution.setVariable("vnfId", "testVnfId1");
    execution.setVariable("vnfName", "testVnfName");
    execution.setVariable("vfModuleId", "testVfModuleId");
    execution.setVariable("oamIpAddress", "testOamIpAddress");
    execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
    execution.setVariable("payload", payload);
    doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed"));
    doThrow(new RuntimeException("APPC Client Failed")).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
    genericVnfHealthCheck.callAppcClient(execution);
    verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
}
Also used : Action(org.onap.appc.client.lcm.model.Action) ApplicationControllerAction(org.onap.so.client.appc.ApplicationControllerAction) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) HashMap(java.util.HashMap) BpmnError(org.camunda.bpm.engine.delegate.BpmnError) Test(org.junit.Test)

Example 14 with Action

use of org.onap.appc.client.lcm.model.Action in project so by onap.

the class GenericVnfHealthCheckTest method callAppcClientTest.

@Test
public void callAppcClientTest() {
    Action action = Action.HealthCheck;
    String vnfId = genericVnf.getVnfId();
    String payload = "{\"testName\":\"testValue\",}";
    String controllerType = "testType";
    HashMap<String, String> payloadInfo = new HashMap<>();
    payloadInfo.put("vnfName", "testVnfName");
    payloadInfo.put("vfModuleId", "testVfModuleId");
    payloadInfo.put("oamIpAddress", "testOamIpAddress");
    payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
    execution.setVariable("action", Action.HealthCheck.toString());
    execution.setVariable("msoRequestId", msoRequestId);
    execution.setVariable("controllerType", controllerType);
    execution.setVariable("vnfId", "testVnfId1");
    execution.setVariable("vnfName", "testVnfName");
    execution.setVariable("vfModuleId", "testVfModuleId");
    execution.setVariable("oamIpAddress", "testOamIpAddress");
    execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
    execution.setVariable("payload", payload);
    doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
    genericVnfHealthCheck.callAppcClient(execution);
    verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
}
Also used : Action(org.onap.appc.client.lcm.model.Action) ApplicationControllerAction(org.onap.so.client.appc.ApplicationControllerAction) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 15 with Action

use of org.onap.appc.client.lcm.model.Action in project so by onap.

the class ApplicationControllerClient method createRequest.

public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId, String requestorId) {
    Object requestObject = appCSupport.getInput(action.name());
    try {
        CommonHeader commonHeader = buildCommonHeader(requestId, requestorId);
        requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject, commonHeader);
        requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action);
        requestObject.getClass().getDeclaredMethod("setActionIdentifiers", ActionIdentifiers.class).invoke(requestObject, identifier);
        if (payload != null) {
            logger.info("payload in RunCommand: " + payload.getValue());
            requestObject.getClass().getDeclaredMethod("setPayload", Payload.class).invoke(requestObject, payload);
        }
    } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
        logger.error("Error building Appc request", e);
    }
    return requestObject;
}
Also used : CommonHeader(org.onap.appc.client.lcm.model.CommonHeader) Action(org.onap.appc.client.lcm.model.Action) Payload(org.onap.appc.client.lcm.model.Payload) ActionIdentifiers(org.onap.appc.client.lcm.model.ActionIdentifiers) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

Action (org.onap.appc.client.lcm.model.Action)25 HashMap (java.util.HashMap)23 Test (org.junit.Test)20 BaseTest (org.onap.so.BaseTest)14 Status (org.onap.appc.client.lcm.model.Status)10 ApplicationControllerAction (org.onap.so.client.appc.ApplicationControllerAction)5 JSONObject (org.json.JSONObject)4 ArrayList (java.util.ArrayList)3 BpmnError (org.camunda.bpm.engine.delegate.BpmnError)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ActionIdentifiers (org.onap.appc.client.lcm.model.ActionIdentifiers)2 CommonHeader (org.onap.appc.client.lcm.model.CommonHeader)2 Payload (org.onap.appc.client.lcm.model.Payload)2 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)2 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)2 ControllerSelectionReference (org.onap.so.db.catalog.beans.ControllerSelectionReference)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Ignore (org.junit.Ignore)1 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)1