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) {
Object requestObject = appCSupport.getInput(action.name());
try {
CommonHeader commonHeader = buildCommonHeader(requestId);
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) {
requestObject.getClass().getDeclaredMethod("setPayload", Payload.class).invoke(requestObject, payload);
}
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
logger.error("Error building Appc request", e);
}
return requestObject;
}
use of org.onap.appc.client.lcm.model.Action in project so by onap.
the class GenericVnfHealthCheckTest method callAppcClientTimeOutExceptionTest.
@Test
// The runAppCCommand method in not capable of throwing this exception
@Ignore
public void callAppcClientTimeOutExceptionTest() {
expectedException.expect(java.util.concurrent.TimeoutException.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(java.util.concurrent.TimeoutException.class).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 ConfigurationScaleOutTest method callAppcClientExceptionTest.
@Test
public void callAppcClientExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
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);
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);
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 ApplicationControllerActionTest method runAppCCommand_Snapshot_vmIdList_Empty_Test.
@Test
public void runAppCCommand_Snapshot_vmIdList_Empty_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
Action action = Action.Snapshot;
String msoRequestId = "testMsoRequestId";
String vnfId = "testVnfId";
Optional<String> payload = Optional.empty();
HashMap<String, String> payloadInfo = new HashMap<String, String>();
payloadInfo.put("identityUrl", "testIdentityUrl");
String controllerType = "testControllerType";
Status status = new Status();
Optional<String> otherPayloadVm = PayloadClient.snapshotFormat("", "identityUrl");
doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, null, otherPayloadVm, controllerType);
appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
verify(client, times(0)).vnfCommand(action, msoRequestId, vnfId, null, otherPayloadVm, controllerType);
}
use of org.onap.appc.client.lcm.model.Action in project so by onap.
the class ApplicationControllerActionTest method runAppCCommand_HealthCheck_Test.
@Test
public void runAppCCommand_HealthCheck_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
// Prepare method
Action action = Action.HealthCheck;
String msoRequestId = "testMsoRequestId";
String vnfId = "testVnfId";
Optional<String> payload = Optional.empty();
Optional<String> vserverId = Optional.empty();
HashMap<String, String> payloadInfo = new HashMap<String, String>();
payloadInfo.put("vnfName", "testVnfName");
payloadInfo.put("vnfHostIpAddress", "testVnfHostIpAddress");
String controllerType = "testControllerType";
// Prepare mocks
Status status = new Status();
Optional<String> otherPayload = PayloadClient.healthCheckFormat(payloadInfo.get("vnfName"), payloadInfo.get("vnfHostIpAddress"));
doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
// Run method
appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
// Verify call
verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
}
Aggregations