use of org.onap.appc.client.lcm.model.Status 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.Status in project so by onap.
the class ApplicationControllerActionTest method runAppCCommand_Snapshot_Test.
@Test
public void runAppCCommand_Snapshot_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
// Prepare method
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 vmId1 = "testlink:testVmId1";
vmIdList.add(vmId1);
String vmId2 = "testlink:testVmId2";
vmIdList.add(vmId2);
JSONObject vmIdListJson = new JSONObject();
vmIdListJson.put("vmIds", vmIdList);
payloadInfo.put("vmIdList", vmIdListJson.toString());
ArrayList<String> vserverIdList = new ArrayList<String>();
String vserverId1 = "testVserverId1";
Optional<String> vserverIdString1 = Optional.of(vserverId1);
vserverIdList.add(vserverId1);
String vserverId2 = "testVserverId2";
Optional<String> vserverIdString2 = Optional.of(vserverId2);
vserverIdList.add(vserverId2);
JSONObject vserverIdListJson = new JSONObject();
vserverIdListJson.put("vserverIds", vserverIdList);
payloadInfo.put("vserverIdList", vserverIdListJson.toString());
String controllerType = "testControllerType";
// Prepare mocks
Status status = new Status();
Optional<String> otherPayloadVm1 = PayloadClient.snapshotFormat(vmId1, payloadInfo.get("identityUrl"));
Optional<String> otherPayloadVm2 = PayloadClient.snapshotFormat(vmId2, payloadInfo.get("identityUrl"));
doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverIdString1, otherPayloadVm1, controllerType);
doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverIdString2, otherPayloadVm2, controllerType);
// Run method
appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
// Verify call
verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverIdString1, otherPayloadVm1, controllerType);
verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverIdString2, otherPayloadVm2, controllerType);
}
Aggregations