use of pro.taskana.security.WithAccessId in project taskana by Taskana.
the class QueryTasksWithPaginationAccTest method testListOffsetAndLimitOutOfBounds.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testListOffsetAndLimitOutOfBounds() throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
// both will be 0, working
List<TaskSummary> results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).list(-1, -3);
assertThat(results.size(), equalTo(0));
// limit will be 0
results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).list(1, -3);
assertThat(results.size(), equalTo(0));
// offset will be 0
results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).list(-1, 3);
assertThat(results.size(), equalTo(3));
}
use of pro.taskana.security.WithAccessId in project taskana by Taskana.
the class QueryTasksWithPaginationAccTest method testCountOfTaskQuery.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testCountOfTaskQuery() throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
long count = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).count();
assertThat(count, equalTo(22L));
}
use of pro.taskana.security.WithAccessId in project taskana by Taskana.
the class QueryTasksWithPaginationAccTest method testSecondPageOfTaskQueryWithOffset.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testSecondPageOfTaskQueryWithOffset() throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).list(10, 10);
assertThat(results.size(), equalTo(10));
}
use of pro.taskana.security.WithAccessId in project taskana by Taskana.
the class QueryTasksWithPaginationAccTest method testPaginationWithPages.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testPaginationWithPages() throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
// Getting full page
int pageNumber = 2;
int pageSize = 4;
List<TaskSummary> results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).listPage(pageNumber, pageSize);
assertThat(results.size(), equalTo(4));
// Getting full page
pageNumber = 4;
pageSize = 1;
results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).listPage(pageNumber, pageSize);
assertThat(results.size(), equalTo(1));
// Getting last results on 1 big page
pageNumber = 1;
pageSize = 100;
results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).listPage(pageNumber, pageSize);
assertThat(results.size(), equalTo(22));
// Getting last results on multiple pages
pageNumber = 3;
pageSize = 10;
results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).listPage(pageNumber, pageSize);
assertThat(results.size(), equalTo(2));
}
use of pro.taskana.security.WithAccessId in project taskana by Taskana.
the class DeleteClassificationAccTest method testThrowExceptionWhenChildClassificationIsInUseAndRollback.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testThrowExceptionWhenChildClassificationIsInUseAndRollback() throws ClassificationInUseException, NotAuthorizedException, ClassificationNotFoundException {
boolean classificationInUse = false;
try {
classificationService.deleteClassification("L11010", "DOMAIN_A");
} catch (ClassificationInUseException e) {
classificationInUse = true;
}
Classification rollback = classificationService.getClassification("L11010", "DOMAIN_A");
assertTrue(classificationInUse);
assertEquals("DOMAIN_A", rollback.getDomain());
classificationInUse = false;
try {
classificationService.deleteClassification("L11010", "");
} catch (ClassificationInUseException e) {
classificationInUse = true;
}
Classification rollbackMaster = classificationService.getClassification("L11010", "");
Classification rollbackA = classificationService.getClassification("L11010", "DOMAIN_A");
assertTrue(classificationInUse);
assertEquals(rollbackMaster.getKey(), rollbackA.getKey());
assertNotEquals(rollbackMaster.getDomain(), rollbackA.getDomain());
}
Aggregations