|
|
@ -73,27 +73,28 @@ public class ProcessDefinitionControllerTest { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testCreateProcessDefinition() throws Exception { |
|
|
|
public void testCreateProcessDefinition() throws Exception { |
|
|
|
String json = "{\"globalParams\":[],\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-36196\",\"name\"" |
|
|
|
String json = "[{\"name\":\"\",\"pre_task_code\":0,\"pre_task_version\":0,\"post_task_code\":123456789,\"post_task_version\":1," |
|
|
|
+ ":\"ssh_test1\",\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"aa=\\\"1234\\\"\\" |
|
|
|
+ "\"condition_type\":0,\"condition_params\":{}},{\"name\":\"\",\"pre_task_code\":123456789,\"pre_task_version\":1," |
|
|
|
+ "necho ${aa}\"},\"desc\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\"" |
|
|
|
+ "\"post_task_code\":123451234,\"post_task_version\":1,\"condition_type\":0,\"condition_params\":{}}]"; |
|
|
|
+ ",\"retryInterval\":\"1\",\"timeout\":{\"strategy\":\"\",\"interval\":null,\"enable\":false}," |
|
|
|
|
|
|
|
+ "\"taskInstancePriority\":\"MEDIUM\",\"workerGroupId\":-1,\"preTasks\":[]}],\"tenantId\":-1,\"timeout\":0}"; |
|
|
|
|
|
|
|
String locations = "{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String projectName = "test"; |
|
|
|
String projectName = "test"; |
|
|
|
String name = "dag_test"; |
|
|
|
String name = "dag_test"; |
|
|
|
String description = "desc test"; |
|
|
|
String description = "desc test"; |
|
|
|
|
|
|
|
String globalParams = "[]"; |
|
|
|
String connects = "[]"; |
|
|
|
String connects = "[]"; |
|
|
|
|
|
|
|
String locations = "[]"; |
|
|
|
|
|
|
|
int timeout = 0; |
|
|
|
|
|
|
|
String tenantCode = "root"; |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
result.put(Constants.DATA_LIST, 1); |
|
|
|
result.put(Constants.DATA_LIST, 1); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(processDefinitionService.createProcessDefinition(user, projectName, name, json, |
|
|
|
Mockito.when(processDefinitionService.createProcessDefinition(user, projectName, name, description, globalParams, |
|
|
|
description, locations, connects)).thenReturn(result); |
|
|
|
connects, locations, timeout, tenantCode, json)).thenReturn(result); |
|
|
|
|
|
|
|
|
|
|
|
Result response = processDefinitionController.createProcessDefinition(user, projectName, name, json, |
|
|
|
Result response = processDefinitionController.createProcessDefinition(user, projectName, name, description, globalParams, |
|
|
|
locations, connects, description); |
|
|
|
connects, locations, timeout, tenantCode, json); |
|
|
|
Assert.assertTrue(response.isSuccess()); |
|
|
|
Assert.assertEquals(Status.SUCCESS.getCode(), response.getCode().intValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void putMsg(Map<String, Object> result, Status status, Object... statusParams) { |
|
|
|
private void putMsg(Map<String, Object> result, Status status, Object... statusParams) { |
|
|
@ -122,28 +123,29 @@ public class ProcessDefinitionControllerTest { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void updateProcessDefinition() throws Exception { |
|
|
|
public void updateProcessDefinition() throws Exception { |
|
|
|
|
|
|
|
String json = "[{\"name\":\"\",\"pre_task_code\":0,\"pre_task_version\":0,\"post_task_code\":123456789,\"post_task_version\":1," |
|
|
|
String json = "{\"globalParams\":[],\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-36196\",\"name\":\"ssh_test1\"" |
|
|
|
+ "\"condition_type\":0,\"condition_params\":{}},{\"name\":\"\",\"pre_task_code\":123456789,\"pre_task_version\":1," |
|
|
|
+ ",\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"aa=\\\"1234\\\"\\necho ${aa}\"}" |
|
|
|
+ "\"post_task_code\":123451234,\"post_task_version\":1,\"condition_type\":0,\"condition_params\":{}}]"; |
|
|
|
+ ",\"desc\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\",\"retryInterval\"" |
|
|
|
|
|
|
|
+ ":\"1\",\"timeout\":{\"strategy\":\"\",\"interval\":null,\"enable\":false},\"taskInstancePriority\"" |
|
|
|
|
|
|
|
+ ":\"MEDIUM\",\"workerGroupId\":-1,\"preTasks\":[]}],\"tenantId\":-1,\"timeout\":0}"; |
|
|
|
|
|
|
|
String locations = "{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}"; |
|
|
|
String locations = "{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}"; |
|
|
|
String projectName = "test"; |
|
|
|
String projectName = "test"; |
|
|
|
String name = "dag_test"; |
|
|
|
String name = "dag_test"; |
|
|
|
String description = "desc test"; |
|
|
|
String description = "desc test"; |
|
|
|
String connects = "[]"; |
|
|
|
String connects = "[]"; |
|
|
|
int id = 1; |
|
|
|
String globalParams = "[]"; |
|
|
|
|
|
|
|
int timeout = 0; |
|
|
|
|
|
|
|
String tenantCode = "root"; |
|
|
|
|
|
|
|
long code = 123L; |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
result.put("processDefinitionId", 1); |
|
|
|
result.put("processDefinitionId", 1); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(processDefinitionService.updateProcessDefinition(user, projectName, id, name, json, |
|
|
|
Mockito.when(processDefinitionService.updateProcessDefinition(user, projectName, name, code, description, globalParams, |
|
|
|
description, locations, connects)).thenReturn(result); |
|
|
|
connects, locations, timeout, tenantCode, json)).thenReturn(result); |
|
|
|
|
|
|
|
|
|
|
|
Result response = processDefinitionController.updateProcessDefinition(user, projectName, name, id, json, |
|
|
|
Result response = processDefinitionController.updateProcessDefinition(user, projectName, name, code, description, globalParams, |
|
|
|
locations, connects, description,ReleaseState.OFFLINE); |
|
|
|
connects, locations, timeout, tenantCode, json, ReleaseState.OFFLINE); |
|
|
|
Assert.assertTrue(response != null && response.isSuccess()); } |
|
|
|
Assert.assertEquals(Status.SUCCESS.getCode(), response.getCode().intValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testReleaseProcessDefinition() throws Exception { |
|
|
|
public void testReleaseProcessDefinition() throws Exception { |
|
|
@ -158,25 +160,19 @@ public class ProcessDefinitionControllerTest { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryProcessDefinitionById() throws Exception { |
|
|
|
public void testQueryProcessDefinitionByCode() { |
|
|
|
|
|
|
|
|
|
|
|
String json = "{\"globalParams\":[],\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-36196\",\"name\":\"ssh_test1" |
|
|
|
|
|
|
|
+ "\",\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"aa=\\\"1234\\\"\\necho ${aa}" |
|
|
|
|
|
|
|
+ "\"},\"desc\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\",\"retryInterval\"" |
|
|
|
|
|
|
|
+ ":\"1\",\"timeout\":{\"strategy\":\"\",\"interval\":null,\"enable\":false},\"taskInstancePriority\":" |
|
|
|
|
|
|
|
+ "\"MEDIUM\",\"workerGroupId\":-1,\"preTasks\":[]}],\"tenantId\":-1,\"timeout\":0}"; |
|
|
|
|
|
|
|
String locations = "{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}"; |
|
|
|
String locations = "{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}"; |
|
|
|
String projectName = "test"; |
|
|
|
String projectName = "test"; |
|
|
|
String name = "dag_test"; |
|
|
|
String name = "dag_test"; |
|
|
|
String description = "desc test"; |
|
|
|
String description = "desc test"; |
|
|
|
String connects = "[]"; |
|
|
|
String connects = "[]"; |
|
|
|
int id = 1; |
|
|
|
long code = 1L; |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = new ProcessDefinition(); |
|
|
|
ProcessDefinition processDefinition = new ProcessDefinition(); |
|
|
|
processDefinition.setProjectName(projectName); |
|
|
|
processDefinition.setProjectName(projectName); |
|
|
|
processDefinition.setConnects(connects); |
|
|
|
processDefinition.setConnects(connects); |
|
|
|
processDefinition.setDescription(description); |
|
|
|
processDefinition.setDescription(description); |
|
|
|
processDefinition.setId(id); |
|
|
|
processDefinition.setCode(code); |
|
|
|
processDefinition.setLocations(locations); |
|
|
|
processDefinition.setLocations(locations); |
|
|
|
processDefinition.setName(name); |
|
|
|
processDefinition.setName(name); |
|
|
|
|
|
|
|
|
|
|
@ -184,10 +180,10 @@ public class ProcessDefinitionControllerTest { |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
result.put(Constants.DATA_LIST, processDefinition); |
|
|
|
result.put(Constants.DATA_LIST, processDefinition); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(processDefinitionService.queryProcessDefinitionById(user, projectName, id)).thenReturn(result); |
|
|
|
Mockito.when(processDefinitionService.queryProcessDefinitionByCode(user, projectName, code)).thenReturn(result); |
|
|
|
Result response = processDefinitionController.queryProcessDefinitionById(user, projectName, id); |
|
|
|
Result response = processDefinitionController.queryProcessDefinitionByCode(user, projectName, code); |
|
|
|
|
|
|
|
|
|
|
|
Assert.assertTrue(response != null && response.isSuccess()); |
|
|
|
Assert.assertEquals(Status.SUCCESS.getCode(), response.getCode().intValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|