Search in sources :

Example 6 with Status

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

the class ApplicationControllerActionTest method runAppCCommand_Snapshot_vserverIdList_Empty_Test.

@Test
public void runAppCCommand_Snapshot_vserverIdList_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");
    ArrayList<String> vmIdList = new ArrayList<String>();
    String vmId = "testlink:testVmId";
    vmIdList.add(vmId);
    JSONObject vmIdListJson = new JSONObject();
    vmIdListJson.put("vmIds", vmIdList);
    payloadInfo.put("vmIdList", vmIdListJson.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 7 with Status

use of org.onap.appc.client.lcm.model.Status 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)

Example 8 with Status

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

the class ApplicationControllerActionTest method runAppCCommand_Upgrade_PayloadPresent_Test.

private void runAppCCommand_Upgrade_PayloadPresent_Test(Action action) throws ApplicationControllerOrchestratorException, JsonProcessingException {
    // Prepare method
    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>();
    payloadInfo.put("vnfName", "testVnfName");
    String controllerType = "testControllerType";
    // Prepare mocks
    Status status = new Status();
    Optional<String> modifiedPayload = PayloadClient.upgradeFormat(payload, payloadInfo.get("vnfName"));
    doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, modifiedPayload, controllerType);
    // Run method
    appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
    // Verify call
    verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, modifiedPayload, controllerType);
}
Also used : Status(org.onap.appc.client.lcm.model.Status) HashMap(java.util.HashMap)

Example 9 with Status

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

the class ApplicationControllerActionTest method runAppCCommand_QuiesceTraffic_PayloadPresent_Test.

@Test
public void runAppCCommand_QuiesceTraffic_PayloadPresent_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
    // Prepare method
    Action action = Action.QuiesceTraffic;
    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>();
    payloadInfo.put("vnfName", "testVnfName");
    String controllerType = "testControllerType";
    // Prepare mocks
    Status status = new Status();
    Optional<String> modifiedPayload = PayloadClient.quiesceTrafficFormat(payload, payloadInfo.get("vnfName"));
    doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, modifiedPayload, controllerType);
    // Run method
    appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
    // Verify call
    verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, modifiedPayload, 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 10 with Status

use of org.onap.appc.client.lcm.model.Status 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)

Aggregations

Status (org.onap.appc.client.lcm.model.Status)42 Test (org.junit.Test)27 HashMap (java.util.HashMap)14 Action (org.onap.appc.client.lcm.model.Action)10 BaseTest (org.onap.so.BaseTest)10 ConfigurationParameters (org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters)8 Parameters (org.onap.so.adapters.appc.orchestrator.client.beans.Parameters)8 RequestParameters (org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters)8 JSONObject (org.json.JSONObject)4 ArrayList (java.util.ArrayList)3 ResumeTrafficOutput (org.onap.appc.client.lcm.model.ResumeTrafficOutput)3 AppcClientException (org.onap.appc.client.lcm.exceptions.AppcClientException)2 ActionIdentifiers (org.onap.appc.client.lcm.model.ActionIdentifiers)2 Payload (org.onap.appc.client.lcm.model.Payload)2 ApplicationControllerCallback (org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback)2 Identity (org.onap.so.adapters.appc.orchestrator.client.beans.Identity)2 ApplicationControllerTaskRequest (org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1