use of com.woorea.openstack.heat.model.Stack in project so by onap.
the class PollServiceTest method testExecuteExternalTask.
@Test
public void testExecuteExternalTask() throws MsoException, IOException {
String xmlString = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/vnfAdapterTaskRequestCreate.xml")));
Mockito.when(vnfAdapterUtils.isMulticloudMode(Mockito.any(), Mockito.any())).thenReturn(false);
Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(xmlString);
Mockito.when(mockExternalTask.getVariable("PollRollbackStatus")).thenReturn(false);
Mockito.when(mockExternalTask.getVariable("stackId")).thenReturn("stackId/stack123");
Mockito.when(msoHeatUtils.pollStackForStatus(eq(118), any(Stack.class), eq("CREATE_IN_PROGRESS"), eq("regionOne"), eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(false))).thenReturn(new Stack());
Mockito.when(msoHeatUtils.getVfHeatTimeoutValue(any(), eq(false))).thenReturn(118);
// Mockito.doNothing().when(msoHeatUtils).postProcessStackCreate(Mockito.any(), Mockito.any(), Mockito.any(),
// Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
pollService.executeExternalTask(mockExternalTask, mockExternalTaskService);
Mockito.verify(msoHeatUtils).pollStackForStatus(eq(118), any(Stack.class), eq("CREATE_IN_PROGRESS"), eq("regionOne"), eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(false));
Mockito.verify(msoHeatUtils).getVfHeatTimeoutValue(any(), eq(false));
}
use of com.woorea.openstack.heat.model.Stack in project so by onap.
the class StackInfoMapperTest method checkOutputToMap.
@Test
public void checkOutputToMap() throws JsonParseException, JsonMappingException, IOException {
ObjectMapper jacksonMapper = new ObjectMapper();
Stack sample = jacksonMapper.readValue(this.getJson("stack-example.json"), Stack.class);
StackInfoMapper mapper = new StackInfoMapper(sample);
StackInfo result = mapper.map();
Map<String, Object> map = result.getOutputs();
assertEquals(true, map.containsKey("key2"));
assertEquals("value1", map.get("key1"));
}
use of com.woorea.openstack.heat.model.Stack in project so by onap.
the class PollServiceTest method testExecuteExternalTask_rollback.
@Test
public void testExecuteExternalTask_rollback() throws MsoException, IOException {
String xmlString = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/vnfAdapterTaskRequestCreate.xml")));
Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(xmlString);
Mockito.when(mockExternalTask.getVariable("PollRollbackStatus")).thenReturn(true);
Mockito.when(mockExternalTask.getVariable("stackId")).thenReturn("stackId/stack123");
Mockito.when(msoHeatUtils.pollStackForStatus(eq(118), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"), eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(true))).thenReturn(new Stack());
Mockito.doNothing().when(msoHeatUtils).postProcessStackDelete(Mockito.any());
Mockito.when(msoHeatUtils.getVfHeatTimeoutValue(any(), eq(false))).thenReturn(118);
pollService.executeExternalTask(mockExternalTask, mockExternalTaskService);
Mockito.verify(msoHeatUtils).pollStackForStatus(eq(118), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"), eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(true));
Mockito.verify(msoHeatUtils).getVfHeatTimeoutValue(any(), eq(false));
}
use of com.woorea.openstack.heat.model.Stack in project so by onap.
the class RollbackServiceTest method testExecuteExternalTask.
@Test
public void testExecuteExternalTask() throws VnfException, MsoException, IOException {
String payload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/vnfAdapterTaskRequestCreate.xml")));
Stack stack = new Stack();
stack.setId("heatId");
Mockito.when(vnfAdapterUtils.isMulticloudMode(Mockito.any(), Mockito.any())).thenReturn(false);
Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(payload);
Mockito.doNothing().when(vnfAdapterImpl).deleteVfModule(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
Mockito.doNothing().when(mockExternalTaskService).complete(Mockito.any(), Mockito.any());
rollbackService.executeExternalTask(mockExternalTask, mockExternalTaskService);
Mockito.verify(vnfAdapterImpl, Mockito.times(1)).deleteVfModule(Mockito.eq("regionOne"), Mockito.eq("CloudOwner"), Mockito.eq("0422ffb57ba042c0800a29dc85ca70f8"), Mockito.eq("dummy_id"), Mockito.any(String.class), Mockito.any(), Mockito.any());
Mockito.verify(mockExternalTaskService).complete(Mockito.eq(mockExternalTask), Mockito.any());
}
use of com.woorea.openstack.heat.model.Stack in project so by onap.
the class StackServiceTest method testExecuteExternalTask.
@Test
public void testExecuteExternalTask() throws VnfException, MsoException, IOException {
String payload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/vnfAdapterTaskRequestCreate.xml")));
Stack stack = new Stack();
stack.setId("heatId");
Mockito.when(vnfAdapterUtils.isMulticloudMode(Mockito.any(), Mockito.any())).thenReturn(false);
Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(payload);
Mockito.doNothing().when(vnfAdapterImpl).createVfModule(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
Mockito.doNothing().when(mockExternalTaskService).complete(Mockito.any(), Mockito.any());
stackService.executeExternalTask(mockExternalTask, mockExternalTaskService);
Map<String, Object> paramsMap = new HashMap<String, Object>();
paramsMap.put("vf_module_id", "985a468b-328b-4c2b-ad0e-b8f1e19501c4");
paramsMap.put("vnf_id", "6640feba-55f6-4946-9694-4d9558c8870a");
paramsMap.put("vnf_name", "Robot_VNF_For_Volume_Group");
paramsMap.put("availability_zone_0", "AZ-MN02");
paramsMap.put("environment_context", "General_Revenue-Bearing");
paramsMap.put("user_directives", "{}");
paramsMap.put("workload_context", "");
paramsMap.put("vf_module_name", "dummy_id");
paramsMap.put("vf_module_index", "0");
paramsMap.put("sdnc_directives", "{ \"attributes\": [ {\"attribute_name\": \"availability_zone_0\", \"attribute_value\": \"AZ-MN02\"}] }");
Map<String, Object> variables = new HashMap<>();
variables.put("backout", true);
variables.put("OpenstackInvokeSuccess", true);
variables.put("stackId", null);
variables.put("openstackAdapterErrorMessage", "");
variables.put("PollRollbackStatus", false);
variables.put("rollbackPerformed", false);
variables.put("OpenstackRollbackSuccess", false);
variables.put("OpenstackPollSuccess", false);
variables.put("os3Nw", false);
Mockito.verify(vnfAdapterImpl, Mockito.times(1)).createVfModule(Mockito.eq("regionOne"), Mockito.eq("CloudOwner"), Mockito.eq("0422ffb57ba042c0800a29dc85ca70f8"), Mockito.eq("Vf zrdm5bpxmc02092017-Service/Vf zrdm5bpxmc02092017-VF 0::VfZrdm5bpxmc02092017Vf..pxmc_base..module-0"), Mockito.eq("1.0"), Mockito.eq("6640feba-55f6-4946-9694-4d9558c8870a"), Mockito.eq("dummy_id"), Mockito.eq("985a468b-328b-4c2b-ad0e-b8f1e19501c4"), Mockito.eq(null), Mockito.eq(null), Mockito.eq(null), Mockito.eq("074c64d0-7e13-4bcc-8bdb-ea922331102d"), Mockito.eq(paramsMap), Mockito.eq(false), Mockito.eq(false), Mockito.eq(null), Mockito.any(), Mockito.any());
Mockito.verify(mockExternalTaskService).complete(Mockito.eq(mockExternalTask), Mockito.eq(variables));
}
Aggregations