TSK-817: Moved functionality testing into acceptance and removed duplicated testing
This commit is contained in:
parent
4eb7a6f74b
commit
3195490d38
|
@ -288,7 +288,6 @@ public class UpdateClassificationAccTest extends AbstractAccTest {
|
|||
classificationService.updateClassification(classification);
|
||||
}
|
||||
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
|
|
|
@ -43,7 +43,7 @@ public class TaskCleanupJobAccTest extends AbstractAccTest {
|
|||
@Test
|
||||
public void shouldCleanCompletedTasksUntilDate() throws Exception {
|
||||
long totalTasksCount = taskService.createTaskQuery().count();
|
||||
assertEquals(72, totalTasksCount);
|
||||
assertEquals(73, totalTasksCount);
|
||||
|
||||
taskanaEngine.getConfiguration().setTaskCleanupJobAllCompletedSameParentBusiness(false);
|
||||
|
||||
|
@ -51,14 +51,14 @@ public class TaskCleanupJobAccTest extends AbstractAccTest {
|
|||
job.run();
|
||||
|
||||
totalTasksCount = taskService.createTaskQuery().count();
|
||||
assertEquals(66, totalTasksCount);
|
||||
assertEquals(67, totalTasksCount);
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "admin")
|
||||
@Test
|
||||
public void shouldCleanCompletedTasksUntilDateWithSameParentBussiness() throws Exception {
|
||||
long totalTasksCount = taskService.createTaskQuery().count();
|
||||
assertEquals(67, totalTasksCount);
|
||||
assertEquals(68, totalTasksCount);
|
||||
|
||||
taskanaEngine.getConfiguration().setTaskCleanupJobAllCompletedSameParentBusiness(true);
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class TaskCleanupJobAccTest extends AbstractAccTest {
|
|||
job.run();
|
||||
|
||||
totalTasksCount = taskService.createTaskQuery().count();
|
||||
assertEquals(66, totalTasksCount);
|
||||
assertEquals(67, totalTasksCount);
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "admin")
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package acceptance.task;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import java.time.Instant;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -10,10 +15,17 @@ import org.junit.runner.RunWith;
|
|||
import acceptance.AbstractAccTest;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskService;
|
||||
import pro.taskana.TaskState;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidOwnerException;
|
||||
import pro.taskana.exceptions.InvalidStateException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskAlreadyExistException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.impl.TaskImpl;
|
||||
import pro.taskana.security.CurrentUserContext;
|
||||
import pro.taskana.security.JAASRunner;
|
||||
import pro.taskana.security.WithAccessId;
|
||||
|
||||
|
@ -35,8 +47,15 @@ public class CompleteTaskAccTest extends AbstractAccTest {
|
|||
public void testCompleteTask()
|
||||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
|
||||
assertEquals(TaskState.CLAIMED,
|
||||
taskService.getTask("TKI:000000000000000000000000000000000001").getState());
|
||||
|
||||
Task completedTask = taskService.completeTask("TKI:000000000000000000000000000000000001");
|
||||
assertNotNull(completedTask);
|
||||
assertNotNull(completedTask.getCompleted());
|
||||
assertEquals(TaskState.COMPLETED, completedTask.getState());
|
||||
assertNotEquals(completedTask.getCreated(), completedTask.getModified());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
|
@ -51,6 +70,59 @@ public class CompleteTaskAccTest extends AbstractAccTest {
|
|||
assertEquals(completedTask, completedTask2);
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test
|
||||
public void testForceCompleteAlreadyClaimed()
|
||||
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
|
||||
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
|
||||
InvalidOwnerException, InvalidStateException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
|
||||
newTask.setClassificationKey("T2100");
|
||||
newTask.setOwner("other");
|
||||
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||
TaskImpl newTaskImpl = (TaskImpl) newTask;
|
||||
newTaskImpl.setState(TaskState.CLAIMED);
|
||||
newTaskImpl.setClaimed(Instant.now());
|
||||
|
||||
Task createdTask = taskService.createTask(newTaskImpl);
|
||||
Task completedTask = taskService.forceCompleteTask(createdTask.getId());
|
||||
|
||||
assertEquals(TaskState.COMPLETED, completedTask.getState());
|
||||
assertNotNull(completedTask.getCompleted());
|
||||
assertNotEquals(completedTask.getCreated(), completedTask.getModified());
|
||||
assertEquals(completedTask.getModified(), completedTask.getCompleted());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test
|
||||
public void testForceCompleteNotClaimed()
|
||||
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
|
||||
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
|
||||
InvalidOwnerException, InvalidStateException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
|
||||
newTask.setClassificationKey("T2100");
|
||||
newTask.setOwner("other");
|
||||
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||
TaskImpl newTaskImpl = (TaskImpl) newTask;
|
||||
newTaskImpl.setClaimed(Instant.now());
|
||||
|
||||
Task createdTask = taskService.createTask(newTaskImpl);
|
||||
Task completedTask = taskService.forceCompleteTask(createdTask.getId());
|
||||
|
||||
assertEquals(TaskState.COMPLETED, completedTask.getState());
|
||||
assertNotNull(completedTask.getCompleted());
|
||||
assertNotEquals(completedTask.getCreated(), completedTask.getModified());
|
||||
assertEquals(completedTask.getModified(), completedTask.getCompleted());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
|
@ -81,4 +153,186 @@ public class CompleteTaskAccTest extends AbstractAccTest {
|
|||
Assert.assertEquals(InvalidOwnerException.class, e.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test
|
||||
public void testClaimTaskWithDefaultFlag()
|
||||
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
|
||||
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException, InvalidStateException,
|
||||
InvalidOwnerException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
|
||||
newTask.setClassificationKey("T2100");
|
||||
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||
newTask.setOwner(null);
|
||||
Task createdTask = taskService.createTask(newTask);
|
||||
|
||||
assertNotNull(createdTask);
|
||||
assertNull(createdTask.getClaimed());
|
||||
|
||||
Instant before = Instant.now();
|
||||
Task claimedTask = taskService.claim(createdTask.getId());
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Instant after = Instant.now();
|
||||
|
||||
assertNotNull(claimedTask.getOwner());
|
||||
assertEquals(claimedTask.getOwner(), CurrentUserContext.getUserid());
|
||||
assertNotNull(claimedTask.getClaimed());
|
||||
assertTrue(claimedTask.getClaimed().isAfter(before));
|
||||
assertTrue(claimedTask.getClaimed().isBefore(after));
|
||||
assertTrue(claimedTask.getModified().isAfter(before));
|
||||
assertTrue(claimedTask.getModified().isBefore(after));
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test
|
||||
public void testForceClaimTaskFromOtherUser()
|
||||
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
|
||||
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
|
||||
InvalidStateException, InvalidOwnerException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
|
||||
newTask.setClassificationKey("T2100");
|
||||
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||
newTask.setOwner("other_user");
|
||||
Task createdTask = taskService.createTask(newTask);
|
||||
|
||||
assertNotNull(createdTask);
|
||||
assertEquals(createdTask.getOwner(), "other_user");
|
||||
|
||||
Instant beforeForceClaim = Instant.now();
|
||||
Task taskAfterClaim = taskService.forceClaim(createdTask.getId());
|
||||
|
||||
assertEquals(CurrentUserContext.getUserid(), taskAfterClaim.getOwner());
|
||||
assertTrue(taskAfterClaim.getModified().isAfter(beforeForceClaim));
|
||||
assertTrue(taskAfterClaim.getClaimed().isAfter(beforeForceClaim));
|
||||
assertEquals(TaskState.CLAIMED, taskAfterClaim.getState());
|
||||
assertNotEquals(createdTask.getCreated(), taskAfterClaim.getModified());
|
||||
assertTrue(taskAfterClaim.isRead());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test(expected = TaskNotFoundException.class)
|
||||
public void testClaimTaskNotExisting()
|
||||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
|
||||
NotAuthorizedException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
taskService.claim("NOT_EXISTING");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test(expected = InvalidStateException.class)
|
||||
public void testClaimTaskWithInvalidState()
|
||||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
|
||||
NotAuthorizedException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
taskService.forceClaim("TKI:000000000000000000000000000000000036");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test(expected = InvalidOwnerException.class)
|
||||
public void testClaimTaskWithInvalidOwner()
|
||||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
|
||||
NotAuthorizedException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
taskService.claim("TKI:000000000000000000000000000000000100");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test(expected = InvalidStateException.class)
|
||||
public void testCancelClaimForcedWithInvalidState()
|
||||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
|
||||
NotAuthorizedException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
taskService.forceCancelClaim("TKI:000000000000000000000000000000000036");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test
|
||||
public void testCancelClaimDefaultFlag()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
|
||||
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
|
||||
InvalidStateException, InvalidOwnerException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
|
||||
newTask.setClassificationKey("T2100");
|
||||
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||
Task createdTask = taskService.createTask(newTask);
|
||||
|
||||
assertNotNull(createdTask);
|
||||
assertEquals(createdTask.getState(), TaskState.READY);
|
||||
|
||||
createdTask = taskService.cancelClaim(createdTask.getId());
|
||||
|
||||
assertNotNull(createdTask);
|
||||
assertEquals(createdTask.getState(), TaskState.READY);
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "admin",
|
||||
groupNames = {"admin"})
|
||||
@Test
|
||||
public void testForceCancelClaimSuccessfull()
|
||||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
|
||||
NotAuthorizedException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task taskBefore = taskService.getTask("TKI:000000000000000000000000000000000043");
|
||||
|
||||
assertNotNull(taskBefore);
|
||||
assertEquals(TaskState.CLAIMED, taskBefore.getState());
|
||||
|
||||
Instant before = Instant.now();
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Task taskAfter = taskService.forceCancelClaim("TKI:000000000000000000000000000000000043");
|
||||
|
||||
assertNotNull(taskAfter);
|
||||
assertEquals(TaskState.READY, taskAfter.getState());
|
||||
assertNull(taskAfter.getClaimed());
|
||||
assertTrue(taskAfter.getModified().isAfter(before));
|
||||
assertNull(taskAfter.getOwner());
|
||||
assertTrue(taskAfter.isRead());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test(expected = InvalidOwnerException.class)
|
||||
public void testCancelClaimWithInvalidOwner()
|
||||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
|
||||
NotAuthorizedException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
taskService.cancelClaim("TKI:000000000000000000000000000000000100");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import static org.junit.Assert.fail;
|
|||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -19,6 +20,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
|
||||
import acceptance.AbstractAccTest;
|
||||
import pro.taskana.ObjectReference;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskService;
|
||||
import pro.taskana.TaskState;
|
||||
|
@ -61,13 +63,17 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
|
||||
newTask.setClassificationKey("T2100");
|
||||
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||
ObjectReference objectReference = createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567");
|
||||
newTask.setPrimaryObjRef(objectReference);
|
||||
newTask.setOwner("user_1_1");
|
||||
Task createdTask = taskService.createTask(newTask);
|
||||
|
||||
assertNotNull(createdTask);
|
||||
assertThat(createdTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
|
||||
assertThat(createdTask.getOwner(), equalTo("user_1_1"));
|
||||
assertEquals("USER_1_1", createdTask.getWorkbasketKey());
|
||||
assertEquals("T-Vertragstermin VERA", createdTask.getName());
|
||||
assertEquals("1234567", createdTask.getPrimaryObjRef().getValue());
|
||||
assertEquals(objectReference, createdTask.getPrimaryObjRef());
|
||||
assertNotNull(createdTask.getCreated());
|
||||
assertNotNull(createdTask.getModified());
|
||||
assertNotNull(createdTask.getBusinessProcessId());
|
||||
|
@ -82,6 +88,29 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
assertEquals(false, createdTask.isTransferred());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testCreateTaskWithPlanned()
|
||||
throws NotAuthorizedException, InvalidArgumentException,
|
||||
ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
|
||||
newTask.setClassificationKey("T2100");
|
||||
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||
newTask.setOwner("user_1_1");
|
||||
newTask.setPlanned(Instant.now().plus(2, ChronoUnit.HOURS));
|
||||
Task createdTask = taskService.createTask(newTask);
|
||||
|
||||
assertNotNull(createdTask);
|
||||
assertNotNull(createdTask.getCreated());
|
||||
assertNotNull(createdTask.getPlanned());
|
||||
assertEquals(createdTask.getCreated().plus(2, ChronoUnit.HOURS).truncatedTo(ChronoUnit.SECONDS),
|
||||
createdTask.getPlanned().truncatedTo(ChronoUnit.SECONDS));
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
|
@ -414,14 +443,6 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
}
|
||||
}
|
||||
|
||||
private Task makeNewTask(TaskService taskService) {
|
||||
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
|
||||
newTask.setClassificationKey("L12010");
|
||||
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||
newTask.setClassificationKey("L12010");
|
||||
return newTask;
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
|
@ -505,7 +526,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
newTask.setClassificationKey("T2100");
|
||||
try {
|
||||
taskService.createTask(newTask);
|
||||
fail("Should have thrown an InvalidArgumentException, becasue ObjRef is null.");
|
||||
fail("Should have thrown an InvalidArgumentException, because ObjRef is null.");
|
||||
} catch (InvalidArgumentException ex) {
|
||||
// nothing to do
|
||||
}
|
||||
|
@ -658,4 +679,50 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
}
|
||||
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testCreateTaskWithSecurityButNoUserId()
|
||||
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
|
||||
TaskAlreadyExistException, InvalidArgumentException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
|
||||
newTask.setClassificationKey("T2100");
|
||||
newTask.setPrimaryObjRef(createObjectReference("COMPANY_B", "SYSTEM_B", "INSTANCE_B", "VNR", "1234567"));
|
||||
taskService.createTask(newTask);
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test(expected = TaskAlreadyExistException.class)
|
||||
public void testCreateTaskAlreadyExisting()
|
||||
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
|
||||
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task existingTask = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
taskService.createTask(existingTask);
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testCreateTaskNotAuthorizedOnWorkbasket() throws WorkbasketNotFoundException,
|
||||
ClassificationNotFoundException, NotAuthorizedException, TaskAlreadyExistException,
|
||||
InvalidArgumentException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task task = taskService.newTask("TEAMLEAD_2", "DOMAIN_A");
|
||||
taskService.createTask(task);
|
||||
}
|
||||
|
||||
private Task makeNewTask(TaskService taskService) {
|
||||
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
|
||||
newTask.setClassificationKey("L12010");
|
||||
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||
newTask.setClassificationKey("L12010");
|
||||
return newTask;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,4 +80,16 @@ public class GetTaskAccTest extends AbstractAccTest {
|
|||
assertEquals("custom15", task.getCustomAttribute("15"));
|
||||
assertEquals("custom16", task.getCustomAttribute("16"));
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test(expected = TaskNotFoundException.class)
|
||||
public void testGetTaskByIdNotExisting()
|
||||
throws TaskNotFoundException, NotAuthorizedException {
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
|
||||
taskService.getTask("INVALID");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
|
|||
List<TaskSummary> results = taskService.createTaskQuery()
|
||||
.classificationKeyLike("L10%")
|
||||
.list();
|
||||
assertThat(results.size(), equalTo(66));
|
||||
assertThat(results.size(), equalTo(67));
|
||||
|
||||
String[] ids = results.stream()
|
||||
.map(t -> t.getClassificationSummary().getKey())
|
||||
|
@ -220,12 +220,12 @@ public class QueryTasksAccTest extends AbstractAccTest {
|
|||
List<TaskSummary> result2 = taskService.createTaskQuery()
|
||||
.classificationKeyIn(ids)
|
||||
.list();
|
||||
assertThat(result2.size(), equalTo(66));
|
||||
assertThat(result2.size(), equalTo(67));
|
||||
|
||||
List<TaskSummary> result3 = taskService.createTaskQuery()
|
||||
.classificationKeyNotIn("T2100", "T2000")
|
||||
.list();
|
||||
assertThat(result3.size(), equalTo(70));
|
||||
assertThat(result3.size(), equalTo(71));
|
||||
|
||||
List<TaskSummary> result4 = taskService.createTaskQuery()
|
||||
.classificationKeyNotIn("L1050", "L1060", "T2100")
|
||||
|
@ -739,7 +739,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
|
|||
List<TaskSummary> results = taskService.createTaskQuery()
|
||||
.customAttributeLike("14", "%")
|
||||
.list();
|
||||
assertThat(results.size(), equalTo(47));
|
||||
assertThat(results.size(), equalTo(48));
|
||||
|
||||
String[] ids = results.stream()
|
||||
.map(t -> {
|
||||
|
@ -755,7 +755,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
|
|||
List<TaskSummary> results2 = taskService.createTaskQuery()
|
||||
.customAttributeIn("14", ids)
|
||||
.list();
|
||||
assertThat(results2.size(), equalTo(47));
|
||||
assertThat(results2.size(), equalTo(48));
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
|
@ -888,11 +888,11 @@ public class QueryTasksAccTest extends AbstractAccTest {
|
|||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||
long numberOfTasks = taskQuery.count();
|
||||
assertEquals(24, numberOfTasks);
|
||||
assertEquals(25, numberOfTasks);
|
||||
List<TaskSummary> tasks = taskQuery
|
||||
.orderByDue(SortDirection.DESCENDING)
|
||||
.list();
|
||||
assertEquals(24, tasks.size());
|
||||
assertEquals(25, tasks.size());
|
||||
List<TaskSummary> tasksp = taskQuery
|
||||
.orderByDue(SortDirection.DESCENDING)
|
||||
.listPage(4, 5);
|
||||
|
@ -900,7 +900,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
|
|||
tasksp = taskQuery
|
||||
.orderByDue(SortDirection.DESCENDING)
|
||||
.listPage(5, 5);
|
||||
assertEquals(4, tasksp.size());
|
||||
assertEquals(5, tasksp.size());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
|
@ -1043,7 +1043,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
|
|||
List<TaskSummary> results = taskService.createTaskQuery()
|
||||
.businessProcessIdLike("pI_%")
|
||||
.list();
|
||||
assertEquals(66, results.size());
|
||||
assertEquals(67, results.size());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
|
|
|
@ -107,7 +107,7 @@ public class QueryTasksByTimeIntervalsAccTest extends AbstractAccTest {
|
|||
.orderByCreated(asc)
|
||||
.list();
|
||||
|
||||
assertThat(results.size(), equalTo(37));
|
||||
assertThat(results.size(), equalTo(38));
|
||||
TaskSummary previousSummary = null;
|
||||
for (TaskSummary taskSummary : results) {
|
||||
Instant cr = taskSummary.getCreated();
|
||||
|
|
|
@ -35,7 +35,7 @@ import pro.taskana.security.JAASRunner;
|
|||
import pro.taskana.security.WithAccessId;
|
||||
|
||||
/**
|
||||
* Acceptance test for all "update task" scenarios.
|
||||
* Acceptance test for all "transfer task" scenarios.
|
||||
*/
|
||||
@RunWith(JAASRunner.class)
|
||||
public class TransferTaskAccTest extends AbstractAccTest {
|
||||
|
@ -114,6 +114,43 @@ public class TransferTaskAccTest extends AbstractAccTest {
|
|||
taskService.transfer(task.getId(), "WBI:100000000000000000000000000000000005");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void testTransferDestinationWorkbasketDoesNotExist()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, TaskNotFoundException, InvalidStateException,
|
||||
InvalidOwnerException {
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000003");
|
||||
taskService.claim(task.getId());
|
||||
taskService.setTaskRead(task.getId(), true);
|
||||
|
||||
taskService.transfer(task.getId(), "INVALID");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test(expected = TaskNotFoundException.class)
|
||||
public void testTransferTaskDoesNotExist()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, TaskNotFoundException, InvalidStateException {
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
|
||||
taskService.transfer("Invalid", "WBI:100000000000000000000000000000000006");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"teamlead_1"})
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testTransferNotAuthorizationOnWorkbasketTransfer()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, TaskNotFoundException, InvalidStateException {
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
|
||||
taskService.transfer("TKI:200000000000000000000000000000000007", "WBI:100000000000000000000000000000000006");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"group_1"})
|
||||
|
|
|
@ -204,6 +204,10 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
assertFalse(updatedTask2.isRead());
|
||||
assertFalse(updatedTask2.getModified().isBefore(updatedTask.getModified()));
|
||||
|
||||
try {
|
||||
taskService.setTaskRead("INVALID", true);
|
||||
fail("TaskNotFoundException should have been thrown.");
|
||||
} catch (TaskNotFoundException e) { }
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
|
|
|
@ -99,6 +99,29 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
|
|||
assertTrue(task.getDue().equals(task.getPlanned().plus(Duration.ofDays(1))));
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test
|
||||
public void testAddValidAttachmentTwice()
|
||||
throws TaskNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException,
|
||||
NotAuthorizedException,
|
||||
AttachmentPersistenceException {
|
||||
setUpMethod();
|
||||
task.getAttachments().clear();
|
||||
task = taskService.updateTask(task);
|
||||
task = taskService.getTask(task.getId());
|
||||
assertEquals(0, task.getAttachments().size());
|
||||
|
||||
AttachmentImpl attachment = (AttachmentImpl) this.attachment;
|
||||
attachment.setId("TAI:000017");
|
||||
task.addAttachment(attachment);
|
||||
task.addAttachment(attachment);
|
||||
task = taskService.updateTask(task);
|
||||
|
||||
assertEquals(1, task.getAttachments().size());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
|
@ -505,6 +528,9 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
|
|||
task.addAttachment(attachment);
|
||||
taskService.updateTask(task);
|
||||
Task updatedTask = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
assertEquals("TEST_VALUE", updatedTask.getAttachments().get(0).getCustomAttributes().get("TEST_KEY"));
|
||||
Attachment updatedAttachment = updatedTask.getAttachments().stream()
|
||||
.filter(a -> attachment.getId().equals(a.getId())).findFirst().orElse(null);
|
||||
assertNotNull(updatedAttachment);
|
||||
assertEquals("TEST_VALUE", updatedAttachment.getCustomAttributes().get("TEST_KEY"));
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -119,7 +119,7 @@ public class TaskanaEngineConfigurationTest {
|
|||
* @param propertiesFileName
|
||||
* @return
|
||||
*/
|
||||
private static DataSource createDataSourceFromProperties(String propertiesFileName) {
|
||||
public static DataSource createDataSourceFromProperties(String propertiesFileName) {
|
||||
DataSource ds = null;
|
||||
try (InputStream input = new FileInputStream(propertiesFileName)) {
|
||||
Properties prop = new Properties();
|
||||
|
|
|
@ -31,6 +31,7 @@ import pro.taskana.Workbasket;
|
|||
import pro.taskana.WorkbasketAccessItem;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.WorkbasketType;
|
||||
import pro.taskana.configuration.DbSchemaCreator;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.exceptions.ClassificationAlreadyExistException;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
|
@ -68,24 +69,26 @@ import pro.taskana.security.WithAccessId;
|
|||
@RunWith(JAASRunner.class)
|
||||
public class TaskServiceImplIntExplicitTest {
|
||||
|
||||
private DataSource dataSource;
|
||||
private TaskServiceImpl taskServiceImpl;
|
||||
private TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
private TaskanaEngine taskanaEngine;
|
||||
private TaskanaEngineImpl taskanaEngineImpl;
|
||||
private ClassificationService classificationService;
|
||||
private WorkbasketService workbasketService;
|
||||
|
||||
@BeforeClass
|
||||
public static void resetDb() {
|
||||
DataSource ds = TaskanaEngineConfigurationTest.getDataSource();
|
||||
DBCleaner cleaner = new DBCleaner();
|
||||
cleaner.clearDb(ds, true);
|
||||
}
|
||||
private static DataSource dataSource;
|
||||
private static DBCleaner cleaner;
|
||||
private static TaskServiceImpl taskServiceImpl;
|
||||
private static TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
private static TaskanaEngine taskanaEngine;
|
||||
private static TaskanaEngineImpl taskanaEngineImpl;
|
||||
private static ClassificationService classificationService;
|
||||
private static WorkbasketService workbasketService;
|
||||
|
||||
@Before
|
||||
public void setup() throws SQLException {
|
||||
dataSource = TaskanaEngineConfigurationTest.getDataSource();
|
||||
public void resetDb() {
|
||||
cleaner.clearDb(dataSource, false);
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() throws SQLException {
|
||||
String userHomeDirectroy = System.getProperty("user.home");
|
||||
String propertiesFileName = userHomeDirectroy + "/taskanaUnitTest.properties";
|
||||
|
||||
dataSource = TaskanaEngineConfigurationTest.createDataSourceFromProperties(propertiesFileName);
|
||||
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false,
|
||||
TaskanaEngineConfigurationTest.getSchemaName());
|
||||
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
|
@ -94,8 +97,10 @@ public class TaskServiceImplIntExplicitTest {
|
|||
classificationService = taskanaEngine.getClassificationService();
|
||||
taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.EXPLICIT);
|
||||
workbasketService = taskanaEngine.getWorkbasketService();
|
||||
DBCleaner cleaner = new DBCleaner();
|
||||
cleaner.clearDb(dataSource, false);
|
||||
cleaner = new DBCleaner();
|
||||
cleaner.clearDb(dataSource, true);
|
||||
DbSchemaCreator creator = new DbSchemaCreator(dataSource, dataSource.getConnection().getSchema());
|
||||
creator.run();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
|
|
|
@ -75,3 +75,4 @@ INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000065', 'ETI:0000000
|
|||
-- Task for TransferAccTest
|
||||
INSERT INTO TASK VALUES('TKI:100000000000000000000000000000000006', 'ETI:100000000000000000000000000000000006', '2018-01-29 15:55:06', '2018-01-30 15:55:06', '2018-01-30 16:55:06', '2018-01-30 16:55:06', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000004' , 'TEAMLEAD_1' , 'DOMAIN_A', 'PI_0000000000041' , 'DOC_0000000000000000041' , null , '00' , 'PASystem' , '00' , 'VNR' , '11223344' , false , false , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
|
||||
INSERT INTO TASK VALUES('TKI:200000000000000000000000000000000006', 'ETI:200000000000000000000000000000000006', '2018-03-29 15:55:06', '2018-03-30 15:55:06', null , '2018-03-30 15:55:06', '2018-03-29 15:55:00', '2018-03-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000005' , 'TEAMLEAD_2' , 'DOMAIN_A', 'PI_0000000000006' , 'DOC_0000000000000000006' , null , '00' , 'PASystem' , '00' , 'SDNR' , '98765432' , false , false , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
|
||||
INSERT INTO TASK VALUES('TKI:200000000000000000000000000000000007', 'ETI:200000000000000000000000000000000007', '2018-03-29 15:55:06', '2018-03-30 15:55:06', null , '2018-03-30 15:55:06', '2018-03-29 15:55:00', '2018-03-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'READY' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000005' , 'TEAMLEAD_2' , 'DOMAIN_A', 'PI_0000000000006' , 'DOC_0000000000000000006' , null , '00' , 'PASystem' , '00' , 'SDNR' , '98765432' , false , false , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
|
||||
|
|
Loading…
Reference in New Issue