|
|
@ -48,6 +48,8 @@ import java.util.LinkedHashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.AfterAll; |
|
|
|
import org.junit.jupiter.api.AfterAll; |
|
|
|
import org.junit.jupiter.api.Assertions; |
|
|
|
import org.junit.jupiter.api.Assertions; |
|
|
|
import org.junit.jupiter.api.BeforeAll; |
|
|
|
import org.junit.jupiter.api.BeforeAll; |
|
|
@ -55,8 +57,6 @@ import org.junit.jupiter.api.Order; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.testcontainers.shaded.org.awaitility.Awaitility; |
|
|
|
import org.testcontainers.shaded.org.awaitility.Awaitility; |
|
|
|
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") |
|
|
|
@DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") |
|
|
|
@Slf4j |
|
|
|
@Slf4j |
|
|
|
public class ProcessInstanceAPITest { |
|
|
|
public class ProcessInstanceAPITest { |
|
|
@ -89,7 +89,8 @@ public class ProcessInstanceAPITest { |
|
|
|
public static void setup() { |
|
|
|
public static void setup() { |
|
|
|
LoginPage loginPage = new LoginPage(); |
|
|
|
LoginPage loginPage = new LoginPage(); |
|
|
|
HttpResponse loginHttpResponse = loginPage.login(username, password); |
|
|
|
HttpResponse loginHttpResponse = loginPage.login(username, password); |
|
|
|
sessionId = JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); |
|
|
|
sessionId = |
|
|
|
|
|
|
|
JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); |
|
|
|
processInstancePage = new ProcessInstancePage(sessionId); |
|
|
|
processInstancePage = new ProcessInstancePage(sessionId); |
|
|
|
executorPage = new ExecutorPage(sessionId); |
|
|
|
executorPage = new ExecutorPage(sessionId); |
|
|
|
processDefinitionPage = new ProcessDefinitionPage(sessionId); |
|
|
|
processDefinitionPage = new ProcessDefinitionPage(sessionId); |
|
|
@ -113,7 +114,8 @@ public class ProcessInstanceAPITest { |
|
|
|
HttpResponse createProjectResponse = projectPage.createProject(loginUser, "project-test"); |
|
|
|
HttpResponse createProjectResponse = projectPage.createProject(loginUser, "project-test"); |
|
|
|
HttpResponse queryAllProjectListResponse = projectPage.queryAllProjectList(loginUser); |
|
|
|
HttpResponse queryAllProjectListResponse = projectPage.queryAllProjectList(loginUser); |
|
|
|
assertTrue(queryAllProjectListResponse.getBody().getSuccess()); |
|
|
|
assertTrue(queryAllProjectListResponse.getBody().getSuccess()); |
|
|
|
projectCode = (long) ((LinkedHashMap<String, Object>) ((List<LinkedHashMap>) queryAllProjectListResponse.getBody().getData()).get(0)).get("code"); |
|
|
|
projectCode = (long) ((LinkedHashMap<String, Object>) ((List<LinkedHashMap>) queryAllProjectListResponse |
|
|
|
|
|
|
|
.getBody().getData()).get(0)).get("code"); |
|
|
|
|
|
|
|
|
|
|
|
// upload test workflow definition json
|
|
|
|
// upload test workflow definition json
|
|
|
|
ClassLoader classLoader = getClass().getClassLoader(); |
|
|
|
ClassLoader classLoader = getClass().getClassLoader(); |
|
|
@ -124,13 +126,18 @@ public class ProcessInstanceAPITest { |
|
|
|
assertTrue(data.contains("\"success\":true")); |
|
|
|
assertTrue(data.contains("\"success\":true")); |
|
|
|
|
|
|
|
|
|
|
|
// get workflow definition code
|
|
|
|
// get workflow definition code
|
|
|
|
HttpResponse queryAllProcessDefinitionByProjectCodeResponse = processDefinitionPage.queryAllProcessDefinitionByProjectCode(loginUser, projectCode); |
|
|
|
HttpResponse queryAllProcessDefinitionByProjectCodeResponse = |
|
|
|
|
|
|
|
processDefinitionPage.queryAllProcessDefinitionByProjectCode(loginUser, projectCode); |
|
|
|
assertTrue(queryAllProcessDefinitionByProjectCodeResponse.getBody().getSuccess()); |
|
|
|
assertTrue(queryAllProcessDefinitionByProjectCodeResponse.getBody().getSuccess()); |
|
|
|
assertTrue(queryAllProcessDefinitionByProjectCodeResponse.getBody().getData().toString().contains("hello world")); |
|
|
|
assertTrue(queryAllProcessDefinitionByProjectCodeResponse.getBody().getData().toString() |
|
|
|
processDefinitionCode = (long) ((LinkedHashMap<String, Object>) ((LinkedHashMap<String, Object>) ((List<LinkedHashMap>) queryAllProcessDefinitionByProjectCodeResponse.getBody().getData()).get(0)).get("processDefinition")).get("code"); |
|
|
|
.contains("hello world")); |
|
|
|
|
|
|
|
processDefinitionCode = |
|
|
|
|
|
|
|
(long) ((LinkedHashMap<String, Object>) ((LinkedHashMap<String, Object>) ((List<LinkedHashMap>) queryAllProcessDefinitionByProjectCodeResponse |
|
|
|
|
|
|
|
.getBody().getData()).get(0)).get("processDefinition")).get("code"); |
|
|
|
|
|
|
|
|
|
|
|
// release test workflow
|
|
|
|
// release test workflow
|
|
|
|
HttpResponse releaseProcessDefinitionResponse = processDefinitionPage.releaseProcessDefinition(loginUser, projectCode, processDefinitionCode, ReleaseState.ONLINE); |
|
|
|
HttpResponse releaseProcessDefinitionResponse = processDefinitionPage.releaseProcessDefinition(loginUser, |
|
|
|
|
|
|
|
projectCode, processDefinitionCode, ReleaseState.ONLINE); |
|
|
|
assertTrue(releaseProcessDefinitionResponse.getBody().getSuccess()); |
|
|
|
assertTrue(releaseProcessDefinitionResponse.getBody().getSuccess()); |
|
|
|
|
|
|
|
|
|
|
|
// trigger workflow instance
|
|
|
|
// trigger workflow instance
|
|
|
@ -138,7 +145,8 @@ public class ProcessInstanceAPITest { |
|
|
|
Date date = new Date(); |
|
|
|
Date date = new Date(); |
|
|
|
String scheduleTime = String.format("%s,%s", formatter.format(date), formatter.format(date)); |
|
|
|
String scheduleTime = String.format("%s,%s", formatter.format(date), formatter.format(date)); |
|
|
|
log.info("use current time {} as scheduleTime", scheduleTime); |
|
|
|
log.info("use current time {} as scheduleTime", scheduleTime); |
|
|
|
HttpResponse startProcessInstanceResponse = executorPage.startProcessInstance(loginUser, projectCode, processDefinitionCode, scheduleTime, FailureStrategy.END, WarningType.NONE); |
|
|
|
HttpResponse startProcessInstanceResponse = executorPage.startProcessInstance(loginUser, projectCode, |
|
|
|
|
|
|
|
processDefinitionCode, scheduleTime, FailureStrategy.END, WarningType.NONE); |
|
|
|
assertTrue(startProcessInstanceResponse.getBody().getSuccess()); |
|
|
|
assertTrue(startProcessInstanceResponse.getBody().getSuccess()); |
|
|
|
|
|
|
|
|
|
|
|
// make sure process instance has completed and successfully persisted into db
|
|
|
|
// make sure process instance has completed and successfully persisted into db
|
|
|
@ -147,9 +155,12 @@ public class ProcessInstanceAPITest { |
|
|
|
.untilAsserted(() -> { |
|
|
|
.untilAsserted(() -> { |
|
|
|
// query workflow instance by trigger code
|
|
|
|
// query workflow instance by trigger code
|
|
|
|
triggerCode = (long) startProcessInstanceResponse.getBody().getData(); |
|
|
|
triggerCode = (long) startProcessInstanceResponse.getBody().getData(); |
|
|
|
HttpResponse queryProcessInstancesByTriggerCodeResponse = processInstancePage.queryProcessInstancesByTriggerCode(loginUser, projectCode, triggerCode); |
|
|
|
HttpResponse queryProcessInstancesByTriggerCodeResponse = processInstancePage |
|
|
|
|
|
|
|
.queryProcessInstancesByTriggerCode(loginUser, projectCode, triggerCode); |
|
|
|
assertTrue(queryProcessInstancesByTriggerCodeResponse.getBody().getSuccess()); |
|
|
|
assertTrue(queryProcessInstancesByTriggerCodeResponse.getBody().getSuccess()); |
|
|
|
List<LinkedHashMap<String, Object>> body = (List<LinkedHashMap<String, Object>>) queryProcessInstancesByTriggerCodeResponse.getBody().getData(); |
|
|
|
List<LinkedHashMap<String, Object>> body = |
|
|
|
|
|
|
|
(List<LinkedHashMap<String, Object>>) queryProcessInstancesByTriggerCodeResponse |
|
|
|
|
|
|
|
.getBody().getData(); |
|
|
|
assertTrue(CollectionUtils.isNotEmpty(body)); |
|
|
|
assertTrue(CollectionUtils.isNotEmpty(body)); |
|
|
|
assertEquals("SUCCESS", body.get(0).get("state")); |
|
|
|
assertEquals("SUCCESS", body.get(0).get("state")); |
|
|
|
processInstanceId = (int) body.get(0).get("id"); |
|
|
|
processInstanceId = (int) body.get(0).get("id"); |
|
|
@ -163,7 +174,8 @@ public class ProcessInstanceAPITest { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@Order(2) |
|
|
|
@Order(2) |
|
|
|
public void testQueryProcessInstanceList() { |
|
|
|
public void testQueryProcessInstanceList() { |
|
|
|
HttpResponse queryProcessInstanceListResponse = processInstancePage.queryProcessInstanceList(loginUser, projectCode, 1, 10); |
|
|
|
HttpResponse queryProcessInstanceListResponse = |
|
|
|
|
|
|
|
processInstancePage.queryProcessInstanceList(loginUser, projectCode, 1, 10); |
|
|
|
assertTrue(queryProcessInstanceListResponse.getBody().getSuccess()); |
|
|
|
assertTrue(queryProcessInstanceListResponse.getBody().getSuccess()); |
|
|
|
assertTrue(queryProcessInstanceListResponse.getBody().getData().toString().contains("test_import")); |
|
|
|
assertTrue(queryProcessInstanceListResponse.getBody().getData().toString().contains("test_import")); |
|
|
|
} |
|
|
|
} |
|
|
@ -171,7 +183,8 @@ public class ProcessInstanceAPITest { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@Order(3) |
|
|
|
@Order(3) |
|
|
|
public void testQueryTaskListByProcessId() { |
|
|
|
public void testQueryTaskListByProcessId() { |
|
|
|
HttpResponse queryTaskListByProcessIdResponse = processInstancePage.queryTaskListByProcessId(loginUser, projectCode, processInstanceId); |
|
|
|
HttpResponse queryTaskListByProcessIdResponse = |
|
|
|
|
|
|
|
processInstancePage.queryTaskListByProcessId(loginUser, projectCode, processInstanceId); |
|
|
|
assertTrue(queryTaskListByProcessIdResponse.getBody().getSuccess()); |
|
|
|
assertTrue(queryTaskListByProcessIdResponse.getBody().getSuccess()); |
|
|
|
assertTrue(queryTaskListByProcessIdResponse.getBody().getData().toString().contains("test_import")); |
|
|
|
assertTrue(queryTaskListByProcessIdResponse.getBody().getData().toString().contains("test_import")); |
|
|
|
} |
|
|
|
} |
|
|
@ -179,7 +192,8 @@ public class ProcessInstanceAPITest { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@Order(4) |
|
|
|
@Order(4) |
|
|
|
public void testQueryProcessInstanceById() { |
|
|
|
public void testQueryProcessInstanceById() { |
|
|
|
HttpResponse queryProcessInstanceByIdResponse = processInstancePage.queryProcessInstanceById(loginUser, projectCode, processInstanceId); |
|
|
|
HttpResponse queryProcessInstanceByIdResponse = |
|
|
|
|
|
|
|
processInstancePage.queryProcessInstanceById(loginUser, projectCode, processInstanceId); |
|
|
|
assertTrue(queryProcessInstanceByIdResponse.getBody().getSuccess()); |
|
|
|
assertTrue(queryProcessInstanceByIdResponse.getBody().getSuccess()); |
|
|
|
assertTrue(queryProcessInstanceByIdResponse.getBody().getData().toString().contains("test_import")); |
|
|
|
assertTrue(queryProcessInstanceByIdResponse.getBody().getData().toString().contains("test_import")); |
|
|
|
} |
|
|
|
} |
|
|
@ -187,10 +201,12 @@ public class ProcessInstanceAPITest { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@Order(5) |
|
|
|
@Order(5) |
|
|
|
public void testDeleteProcessInstanceById() { |
|
|
|
public void testDeleteProcessInstanceById() { |
|
|
|
HttpResponse deleteProcessInstanceByIdResponse = processInstancePage.deleteProcessInstanceById(loginUser, projectCode, processInstanceId); |
|
|
|
HttpResponse deleteProcessInstanceByIdResponse = |
|
|
|
|
|
|
|
processInstancePage.deleteProcessInstanceById(loginUser, projectCode, processInstanceId); |
|
|
|
assertTrue(deleteProcessInstanceByIdResponse.getBody().getSuccess()); |
|
|
|
assertTrue(deleteProcessInstanceByIdResponse.getBody().getSuccess()); |
|
|
|
|
|
|
|
|
|
|
|
HttpResponse queryProcessInstanceListResponse = processInstancePage.queryProcessInstanceList(loginUser, projectCode, 1, 10); |
|
|
|
HttpResponse queryProcessInstanceListResponse = |
|
|
|
|
|
|
|
processInstancePage.queryProcessInstanceList(loginUser, projectCode, 1, 10); |
|
|
|
assertTrue(queryProcessInstanceListResponse.getBody().getSuccess()); |
|
|
|
assertTrue(queryProcessInstanceListResponse.getBody().getSuccess()); |
|
|
|
Assertions.assertFalse(queryProcessInstanceListResponse.getBody().getData().toString().contains("test_import")); |
|
|
|
Assertions.assertFalse(queryProcessInstanceListResponse.getBody().getData().toString().contains("test_import")); |
|
|
|
} |
|
|
|
} |
|
|
|