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);
}
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);
}
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);
}
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);
}
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;
}
Aggregations