|
|
|
@ -143,25 +143,6 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
|
|
|
|
|
Assertions.assertNotEquals(0, taskInstances.size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* test query task instance by process instance id and state |
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void testQueryTaskByProcessIdAndState() { |
|
|
|
|
// insert ProcessInstance
|
|
|
|
|
ProcessInstance processInstance = insertProcessInstance(); |
|
|
|
|
|
|
|
|
|
// insert taskInstance
|
|
|
|
|
TaskInstance task = insertTaskInstance(processInstance.getId()); |
|
|
|
|
task.setProcessInstanceId(processInstance.getId()); |
|
|
|
|
taskInstanceMapper.updateById(task); |
|
|
|
|
List<Integer> taskInstances = taskInstanceMapper.queryTaskByProcessIdAndState( |
|
|
|
|
task.getProcessInstanceId(), |
|
|
|
|
TaskExecutionStatus.RUNNING_EXECUTION.getCode()); |
|
|
|
|
taskInstanceMapper.deleteById(task.getId()); |
|
|
|
|
Assertions.assertNotEquals(0, taskInstances.size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* test find valid task list by process instance id |
|
|
|
|
*/ |
|
|
|
@ -194,66 +175,6 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
|
|
|
|
|
Assertions.assertNotEquals(0, taskInstances1.size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* test query by host and status |
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void testQueryByHostAndStatus() { |
|
|
|
|
// insert ProcessInstance
|
|
|
|
|
ProcessInstance processInstance = insertProcessInstance(); |
|
|
|
|
|
|
|
|
|
// insert taskInstance
|
|
|
|
|
TaskInstance task = insertTaskInstance(processInstance.getId()); |
|
|
|
|
task.setHost("111.111.11.11"); |
|
|
|
|
taskInstanceMapper.updateById(task); |
|
|
|
|
|
|
|
|
|
List<TaskInstance> taskInstances = taskInstanceMapper.queryByHostAndStatus( |
|
|
|
|
task.getHost(), new int[]{TaskExecutionStatus.RUNNING_EXECUTION.getCode()}); |
|
|
|
|
taskInstanceMapper.deleteById(task.getId()); |
|
|
|
|
Assertions.assertNotEquals(0, taskInstances.size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* test set failover by host and state array |
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void testSetFailoverByHostAndStateArray() { |
|
|
|
|
// insert ProcessInstance
|
|
|
|
|
ProcessInstance processInstance = insertProcessInstance(); |
|
|
|
|
|
|
|
|
|
// insert taskInstance
|
|
|
|
|
TaskInstance task = insertTaskInstance(processInstance.getId()); |
|
|
|
|
task.setHost("111.111.11.11"); |
|
|
|
|
taskInstanceMapper.updateById(task); |
|
|
|
|
|
|
|
|
|
int setResult = taskInstanceMapper.setFailoverByHostAndStateArray( |
|
|
|
|
task.getHost(), |
|
|
|
|
new int[]{TaskExecutionStatus.RUNNING_EXECUTION.getCode()}, |
|
|
|
|
TaskExecutionStatus.NEED_FAULT_TOLERANCE); |
|
|
|
|
taskInstanceMapper.deleteById(task.getId()); |
|
|
|
|
Assertions.assertNotEquals(0, setResult); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* test query by task instance id and name |
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void testQueryByInstanceIdAndName() { |
|
|
|
|
// insert ProcessInstance
|
|
|
|
|
ProcessInstance processInstance = insertProcessInstance(); |
|
|
|
|
|
|
|
|
|
// insert taskInstance
|
|
|
|
|
TaskInstance task = insertTaskInstance(processInstance.getId()); |
|
|
|
|
task.setHost("111.111.11.11"); |
|
|
|
|
taskInstanceMapper.updateById(task); |
|
|
|
|
|
|
|
|
|
TaskInstance taskInstance = taskInstanceMapper.queryByInstanceIdAndName( |
|
|
|
|
task.getProcessInstanceId(), |
|
|
|
|
task.getName()); |
|
|
|
|
taskInstanceMapper.deleteById(task.getId()); |
|
|
|
|
Assertions.assertNotEquals(null, taskInstance); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* test query by task instance id and code |
|
|
|
|
*/ |
|
|
|
@ -294,37 +215,6 @@ public class TaskInstanceMapperTest extends BaseDaoTest {
|
|
|
|
|
Assertions.assertEquals(1, taskInstances.size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* test count task instance |
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void testCountTask() { |
|
|
|
|
// insert ProcessInstance
|
|
|
|
|
ProcessInstance processInstance = insertProcessInstance(); |
|
|
|
|
|
|
|
|
|
// insert taskInstance
|
|
|
|
|
TaskInstance task = insertTaskInstance(processInstance.getId()); |
|
|
|
|
ProcessDefinition definition = new ProcessDefinition(); |
|
|
|
|
definition.setCode(1L); |
|
|
|
|
definition.setProjectCode(1111L); |
|
|
|
|
definition.setCreateTime(new Date()); |
|
|
|
|
definition.setUpdateTime(new Date()); |
|
|
|
|
processDefinitionMapper.insert(definition); |
|
|
|
|
taskInstanceMapper.updateById(task); |
|
|
|
|
|
|
|
|
|
int countTask = taskInstanceMapper.countTask( |
|
|
|
|
new Long[0], |
|
|
|
|
new int[0]); |
|
|
|
|
int countTask2 = taskInstanceMapper.countTask( |
|
|
|
|
new Long[]{definition.getProjectCode()}, |
|
|
|
|
new int[]{task.getId()}); |
|
|
|
|
taskInstanceMapper.deleteById(task.getId()); |
|
|
|
|
processDefinitionMapper.deleteById(definition.getId()); |
|
|
|
|
Assertions.assertEquals(0, countTask); |
|
|
|
|
Assertions.assertEquals(0, countTask2); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* test count task instance state by user |
|
|
|
|
*/ |
|
|
|
|