Search in sources :

Example 6 with Action

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

the class ApplicationControllerActionTest method runAppCCommand_ConfigModify__PayloadPresent_Test.

@Test
public void runAppCCommand_ConfigModify__PayloadPresent_Test() throws ApplicationControllerOrchestratorException {
    // Prepare method
    Action action = Action.ConfigModify;
    String msoRequestId = "testMsoRequestId";
    String vnfId = "testVnfId";
    Optional<String> payload = Optional.of("testPayload");
    Optional<String> vserverId = Optional.empty();
    HashMap<String, String> payloadInfo = new HashMap<String, String>();
    String controllerType = "testControllerType";
    // Prepare mocks
    Status status = new Status();
    doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, payload, controllerType);
    // Run method
    appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
    // Verify call
    verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, payload, controllerType);
}
Also used : Status(org.onap.appc.client.lcm.model.Status) Action(org.onap.appc.client.lcm.model.Action) HashMap(java.util.HashMap) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 7 with Action

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

the class ApplicationControllerActionTest method runAppCCommand_InvalidAppCAction_Test.

@Test
public void runAppCCommand_InvalidAppCAction_Test() throws ApplicationControllerOrchestratorException {
    // Prepare method
    Action action = Action.ActionStatus;
    String msoRequestId = "testMsoRequestId";
    String vnfId = "testVnfId";
    Optional<String> payload = Optional.empty();
    HashMap<String, String> payloadInfo = new HashMap<String, String>();
    String controllerType = "testControllerType";
    // Run method
    appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
    // Verify non call
    verify(client, times(0)).vnfCommand(any(), any(), any(), any(), any(), any());
// TODO For original author/architect: it appears that whoever coded this wanted the error message to be "Unable
// to idenify Action request for AppCClient" and this is not the case because of the
// ApplicationControllerSupport.getCategoryOf(appCStatus) call with a null appCStatus, so this may be something
// worth looking into
}
Also used : Action(org.onap.appc.client.lcm.model.Action) HashMap(java.util.HashMap) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 8 with Action

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

the class ApplicationControllerActionTest method runAppCCommand_Snapshot_vmId_null_Test.

@Test
public void runAppCCommand_Snapshot_vmId_null_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");
    JSONObject vmIdListJson = new JSONObject();
    payloadInfo.put("vmIdList", vmIdListJson.toString());
    String controllerType = "testControllerType";
    Status status = new Status();
    Optional<String> otherPayloadVm = PayloadClient.snapshotFormat("", payloadInfo.get("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);
}
Also used : Status(org.onap.appc.client.lcm.model.Status) Action(org.onap.appc.client.lcm.model.Action) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 9 with Action

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

the class ApplicationControllerActionTest method runAppCCommand_Snapshot_vserverId_null_Test.

@Test
public void runAppCCommand_Snapshot_vserverId_null_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");
    ArrayList<String> vmIdList = new ArrayList<String>();
    String vmId = "testlink:testVmId1";
    vmIdList.add(vmId);
    JSONObject vmIdListJson = new JSONObject();
    vmIdListJson.put("vmIds", vmIdList);
    payloadInfo.put("vmIdList", vmIdListJson.toString());
    JSONObject vserverIdListJson = new JSONObject();
    payloadInfo.put("vserverIdList", vserverIdListJson.toString());
    String controllerType = "testControllerType";
    Status status = new Status();
    Optional<String> otherPayloadVm = PayloadClient.snapshotFormat(vmId, payloadInfo.get("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);
}
Also used : Status(org.onap.appc.client.lcm.model.Status) Action(org.onap.appc.client.lcm.model.Action) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 10 with Action

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

the class ApplicationControllerActionTest method runAppCCommand_ResumeTraffic_Test.

@Test
public void runAppCCommand_ResumeTraffic_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
    // Prepare method
    Action action = Action.ResumeTraffic;
    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");
    String controllerType = "testControllerType";
    // Prepare mocks
    Status status = new Status();
    Optional<String> otherPayload = PayloadClient.resumeTrafficFormat(payloadInfo.get("vnfName"));
    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);
}
Also used : Status(org.onap.appc.client.lcm.model.Status) Action(org.onap.appc.client.lcm.model.Action) HashMap(java.util.HashMap) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

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