TSK-125: Create/Update/Enable Acc-Tests, especially for querying WB content.
This commit is contained in:
parent
2f468939ed
commit
87e11970f3
|
@ -35,7 +35,7 @@ public interface QueryMapper {
|
|||
+ "<if test='states != null'>AND t.STATE IN(<foreach item='item' collection='states' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='workbasketKey != null'>AND t.WORKBASKET_KEY IN(<foreach item='item' collection='workbasketKey' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='classificationKey != null'>AND t.CLASSIFICATION_KEY IN(<foreach item='item' collection='classificationKey' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='domain != null'>AND t.DOMAIN IN(<foreach item='item' collection='owner' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='domain != null'>AND t.DOMAIN IN(<foreach item='item' collection='domain' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='owner != null'>AND t.OWNER IN(<foreach item='item' collection='owner' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='isRead != null'>AND t.IS_READ = #{isRead}</if> "
|
||||
+ "<if test='isTransferred != null'>AND t.IS_TRANSFERRED = #{isTransferred}</if> "
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
package acceptance.task;
|
||||
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.h2.store.fs.FileUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import acceptance.AbstractAccTest;
|
||||
import pro.taskana.TaskService;
|
||||
import pro.taskana.TaskSummary;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.security.JAASRunner;
|
||||
|
@ -24,30 +29,55 @@ public class QueryTasksByWorkbasketAccTest extends AbstractAccTest {
|
|||
super();
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = { "group_1" })
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testThrowsExceptionIfNoOpenerPermissionOnQueriedWorkbasket()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
// TaskService taskService = taskanaEngine.getTaskService();
|
||||
// List<TaskSummary> results = taskService.createTaskQuery()
|
||||
// .workbasketKeyIn("USER_2_1")
|
||||
// .list();
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
List<TaskSummary> results = taskService.createTaskQuery()
|
||||
.workbasketKeyIn("USER_2_1")
|
||||
.list();
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testThrowsExceptionIfNoOpenerPermissionOnAtLeastOneQueriedWorkbasket()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
// TaskService taskService = taskanaEngine.getTaskService();
|
||||
// List<TaskSummary> results = taskService.createTaskQuery()
|
||||
// .workbasketKeyIn("USER_1_1", "USER_2_1")
|
||||
// .list();
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
List<TaskSummary> results = taskService.createTaskQuery()
|
||||
.workbasketKeyIn("USER_1_1", "USER_2_1")
|
||||
.list();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "user_1_1")
|
||||
@Test
|
||||
public void testQueryAllTasksForDomains() throws NotAuthorizedException {
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
List<TaskSummary> results = taskService.createTaskQuery()
|
||||
.domainIn("DOMAIN_B", "", "DOMAIN_A")
|
||||
.list();
|
||||
assertThat(results.size(), equalTo(17));
|
||||
|
||||
results = taskService.createTaskQuery()
|
||||
.domainIn("DOMAIN_A")
|
||||
.workbasketKeyIn("USER_1_1")
|
||||
.list();
|
||||
assertThat(results.size(), equalTo(2));
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "user_1_1")
|
||||
@Test
|
||||
public void testQueryTasksForWorkbasket() throws NotAuthorizedException {
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
List<TaskSummary> results = taskService.createTaskQuery()
|
||||
.domainIn("DOMAIN_A")
|
||||
.workbasketKeyIn("USER_1_1")
|
||||
.list();
|
||||
assertThat(results.size(), equalTo(2));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
@ -1,17 +1,23 @@
|
|||
package acceptance.task;
|
||||
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.h2.store.fs.FileUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import acceptance.AbstractAccTest;
|
||||
import pro.taskana.ClassificationSummary;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskService;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
|
@ -37,7 +43,7 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testUpdatePrimaryObjectReferenceOfTask()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
|
@ -48,6 +54,7 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "7654321"));
|
||||
Task updatedTask = taskService.updateTask(task);
|
||||
updatedTask = taskService.getTask(updatedTask.getId());
|
||||
|
||||
Assert.assertNotNull(updatedTask);
|
||||
Assert.assertEquals("7654321", updatedTask.getPrimaryObjRef().getValue());
|
||||
|
@ -60,7 +67,7 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testThrowsExceptionIfMandatoryPrimaryObjectReferenceIsNotSetOrIncomplete()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
|
@ -73,6 +80,7 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
Task updatedTask = null;
|
||||
try {
|
||||
updatedTask = taskService.updateTask(task);
|
||||
fail("update() should have thrown InvalidArgumentException.");
|
||||
} catch (InvalidArgumentException ex) {
|
||||
// nothing to do
|
||||
}
|
||||
|
@ -80,6 +88,7 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", null));
|
||||
try {
|
||||
updatedTask = taskService.updateTask(task);
|
||||
fail("update() should have thrown InvalidArgumentException.");
|
||||
} catch (InvalidArgumentException ex) {
|
||||
// nothing to do
|
||||
}
|
||||
|
@ -87,24 +96,28 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", null, "1234567"));
|
||||
try {
|
||||
updatedTask = taskService.updateTask(task);
|
||||
fail("update() should have thrown InvalidArgumentException.");
|
||||
} catch (InvalidArgumentException ex) {
|
||||
// nothing to do
|
||||
}
|
||||
task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", null, "VNR", "1234567"));
|
||||
try {
|
||||
updatedTask = taskService.updateTask(task);
|
||||
fail("update() should have thrown InvalidArgumentException.");
|
||||
} catch (InvalidArgumentException ex) {
|
||||
// nothing to do
|
||||
}
|
||||
task.setPrimaryObjRef(createObjectReference("COMPANY_A", null, "INSTANCE_A", "VNR", "1234567"));
|
||||
try {
|
||||
updatedTask = taskService.updateTask(task);
|
||||
fail("update() should have thrown InvalidArgumentException.");
|
||||
} catch (InvalidArgumentException ex) {
|
||||
// nothing to do
|
||||
}
|
||||
task.setPrimaryObjRef(createObjectReference(null, "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||
try {
|
||||
updatedTask = taskService.updateTask(task);
|
||||
fail("update() should have thrown InvalidArgumentException.");
|
||||
} catch (InvalidArgumentException ex) {
|
||||
// nothing to do
|
||||
}
|
||||
|
@ -112,7 +125,7 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testThrowsExceptionIfTaskHasAlreadyBeenUpdated()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
|
@ -126,6 +139,7 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
task.setCustom1("willi");
|
||||
Task updatedTask = null;
|
||||
updatedTask = taskService.updateTask(task);
|
||||
updatedTask = taskService.getTask(updatedTask.getId());
|
||||
|
||||
task2.setCustom2("Walter");
|
||||
try {
|
||||
|
@ -136,64 +150,59 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testUpdateClassificationOfTask()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
|
||||
|
||||
// TaskService taskService = taskanaEngine.getTaskService();
|
||||
// Task with classification T2000
|
||||
// Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
// task.setClassificationKey("T2100"));
|
||||
// Task updatedTask = taskService.updateTask(task);
|
||||
//
|
||||
// assertNotNull(updatedTask);
|
||||
// assertEquals("T2100", updatedTask.getClassification().getKey());
|
||||
// assertNotEquals(updatedTask.getCreated(), updatedTask.getModified());
|
||||
// assertEquals(22, updatedTask.getPriority());
|
||||
// assertEquals(task.getPlanned(), updatedTask.getPlanned());
|
||||
// assertEquals(???, updatedTask.getDue()); // should be one day later
|
||||
// assertEquals("T-Vertragstermin VERA", updatedTask.getName());
|
||||
// assertEquals("T-Vertragstermin VERA", updatedTask.getDescription());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test
|
||||
public void testCustomPropertiesOfTask()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
|
||||
|
||||
// TaskService taskService = taskanaEngine.getTaskService();
|
||||
// Task with classification T2000
|
||||
// Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
// task.setCustomProperty1("T2100"));
|
||||
// ...
|
||||
// Task updatedTask = taskService.updateTask(task);
|
||||
//
|
||||
// assertNotNull(updatedTask);
|
||||
// meaningful assertions
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
// @Test(expected = InvalidOperationException.class)
|
||||
public void testUpdateOfWorkbasketKeyNotAllowed()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
|
||||
throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException,
|
||||
InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
// Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
// task.setWorkbasketKey("USER_2_2");
|
||||
// Task updatedTask = taskService.updateTask(task);
|
||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
ClassificationSummary classificationSummary = task.getClassificationSummary();
|
||||
task.setClassificationKey("T2100");
|
||||
Task updatedTask = taskService.updateTask(task);
|
||||
updatedTask = taskService.getTask(updatedTask.getId());
|
||||
|
||||
assertNotNull(updatedTask);
|
||||
assertEquals("T2100", updatedTask.getClassificationSummary().getKey());
|
||||
assertThat(updatedTask.getClassificationSummary(), not(equalTo(classificationSummary)));
|
||||
assertNotEquals(updatedTask.getCreated(), updatedTask.getModified());
|
||||
assertEquals(task.getPlanned(), updatedTask.getPlanned());
|
||||
assertEquals(task.getName(), updatedTask.getName());
|
||||
assertEquals(task.getDescription(), updatedTask.getDescription());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testCustomPropertiesOfTask()
|
||||
throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException,
|
||||
InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException {
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
task.setCustom1("T2100");
|
||||
Task updatedTask = taskService.updateTask(task);
|
||||
updatedTask = taskService.getTask(updatedTask.getId());
|
||||
|
||||
assertNotNull(updatedTask);
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = { "group_1" })
|
||||
@Test(expected = InvalidArgumentException.class)
|
||||
public void testUpdateOfWorkbasketKeyWhatIsNotAllowed()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||
ConcurrencyException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
task.setWorkbasketKey("USER_2_2");
|
||||
Task updatedTask = taskService.updateTask(task);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.sql.SQLException;
|
|||
import org.h2.store.fs.FileUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
@ -55,7 +54,6 @@ public class GetWorkbasketAccTest extends AbstractAccTest {
|
|||
Workbasket workbasket = workbasketService.getWorkbasket("INVALID_ID");
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testThrowsExceptionIfNotAuthorized()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
|
||||
|
|
|
@ -36,8 +36,8 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
|
|||
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
|
||||
.accessIdsHavePersmission(WorkbasketAuthorization.APPEND, "user_1_1")
|
||||
.list();
|
||||
Assert.assertEquals(1L, results.size());
|
||||
Assert.assertEquals("USER_1_1", results.get(0).getKey());
|
||||
Assert.assertEquals(2, results.size());
|
||||
Assert.assertEquals("USER_1_1", results.get(1).getKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,12 +47,12 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
|
|||
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
|
||||
.accessIdsHavePersmission(WorkbasketAuthorization.APPEND, "user_1_1", "group_1")
|
||||
.list();
|
||||
Assert.assertEquals(8L, results.size());
|
||||
Assert.assertEquals(9, results.size());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testQueryAllTransferTargetsForUserAndGroupFromSubject()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
|
||||
|
@ -60,11 +60,10 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
|
|||
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
|
||||
.callerHasPermission(WorkbasketAuthorization.APPEND)
|
||||
.list();
|
||||
Assert.assertEquals(8L, results.size());
|
||||
Assert.assertEquals(9, results.size());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1")
|
||||
@WithAccessId(userName = "user_1_1")
|
||||
@Test
|
||||
public void testQueryAllAvailableWorkbasketForOpeningForUserAndGroupFromSubject()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
|
@ -72,7 +71,7 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
|
|||
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
|
||||
.callerHasPermission(WorkbasketAuthorization.READ)
|
||||
.list();
|
||||
Assert.assertEquals(1L, results.size());
|
||||
Assert.assertEquals(2, results.size());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('1', 'key1', 'Elena', true, true, true, true, true, false, false, false, false, false, false, false, false);
|
||||
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('2', 'key2', 'Max', true, true, true, true, true, true, true, true, true, false, false, false, false);
|
||||
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('3', 'key3', 'Simone', true, true, true, true, true, true, true, true, true, true, true, true, true);
|
||||
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('4', 'key4', 'user_1_1', true, true, true, true, true, true, true, true, true, true, true, true, true);
|
||||
|
||||
-- KSC authorizations (ID, WB_KEY, ACCESS_ID, READ, OPEN, APPEND, TRANSFER, DISTRIBUTE, C1, .., C8)
|
||||
-- PPKs
|
||||
|
@ -32,7 +33,6 @@ INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:10000000000000000000000000000000
|
|||
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000021', 'GPK_KSC', 'teamlead_1', true, true, true, true, true, true, true, true, true, true, true, true, true);
|
||||
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000022', 'GPK_KSC', 'teamlead_2', true, true, true, true, true, true, true, true, true, true, true, true, true);
|
||||
|
||||
|
||||
-- Access to other domains
|
||||
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000023', 'GPK_B_KSC_1', 'group_1', true, false, true, true, false, false, false, false, false, false, false, false, false);
|
||||
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000024', 'GPK_B_KSC_2', 'group_2', true, false, true, true, false, false, false, false, false, false, false, false, false);
|
||||
|
|
Loading…
Reference in New Issue