Search in sources :

Example 1 with InvalidArgumentException

use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.

the class CreateTaskAccTest method testThrowsExceptionIfMandatoryPrimaryObjectReferenceIsNotSetOrIncomplete.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testThrowsExceptionIfMandatoryPrimaryObjectReferenceIsNotSetOrIncomplete() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    newTask.setClassificationKey("T2100");
    try {
        taskService.createTask(newTask);
        fail("Should have thrown an InvalidArgumentException, becasue ObjRef is null.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    // Exception
    newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    newTask.setClassificationKey("T2100");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", null));
    try {
        taskService.createTask(newTask);
        fail("Should have thrown an InvalidArgumentException, becasue ObjRef-Value is null.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    // Exception
    newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    newTask.setClassificationKey("T2100");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", null, "1234567"));
    try {
        taskService.createTask(newTask);
        fail("Should have thrown an InvalidArgumentException, becasue ObjRef-Type is null.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    // Exception
    newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    newTask.setClassificationKey("T2100");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", null, "VNR", "1234567"));
    try {
        taskService.createTask(newTask);
        fail("Should have thrown an InvalidArgumentException, becasue ObjRef-SystemInstances is null.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    // Exception
    newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    newTask.setClassificationKey("T2100");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", null, "INSTANCE_A", "VNR", "1234567"));
    try {
        taskService.createTask(newTask);
        fail("Should have thrown an InvalidArgumentException, becasue ObjRef-System is null.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    // Exception
    newTask = taskService.newTask("WBI:100000000000000000000000000000000006");
    newTask.setClassificationKey("T2100");
    newTask.setPrimaryObjRef(createObjectReference(null, "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    try {
        taskService.createTask(newTask);
        fail("Should have thrown an InvalidArgumentException, becasue ObjRef-Company is null.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
}
Also used : Task(pro.taskana.Task) InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskService(pro.taskana.TaskService) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 2 with InvalidArgumentException

use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.

the class QueryTasksAccTest method testQueryForCustom6.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryForCustom6() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().customAttributeLike("6", "%a%", "%b%", "%c%", "%d%", "%e%", "%f%", "%g%", "%h%", "%i%", "%j%", "%k%", "%l%", "%m%", "%n%", "%o%", "%p%", "%q%", "%r%", "%s%", "%w%").list();
    assertThat(results.size(), equalTo(2));
    String[] ids = results.stream().map(t -> {
        try {
            return t.getCustomAttribute("6");
        } catch (InvalidArgumentException e) {
            e.printStackTrace();
            return "";
        }
    }).collect(Collectors.toList()).toArray(new String[0]);
    List<TaskSummary> result2 = taskService.createTaskQuery().customAttributeIn("6", ids).list();
    assertThat(result2.size(), equalTo(2));
}
Also used : InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 3 with InvalidArgumentException

use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.

the class QueryTasksAccTest method testQueryForCustom9.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryForCustom9() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().customAttributeLike("9", "%a%", "%b%", "%c%", "%d%", "%e%", "%f%", "%g%", "%h%", "%i%", "%j%", "%k%", "%l%", "%m%", "%n%", "%o%", "%p%", "%q%", "%r%", "%s%", "%w%").list();
    assertThat(results.size(), equalTo(1));
    String[] ids = results.stream().map(t -> {
        try {
            return t.getCustomAttribute("9");
        } catch (InvalidArgumentException e) {
            e.printStackTrace();
            return "";
        }
    }).collect(Collectors.toList()).toArray(new String[0]);
    List<TaskSummary> result2 = taskService.createTaskQuery().customAttributeIn("9", ids).list();
    assertThat(result2.size(), equalTo(1));
}
Also used : InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 4 with InvalidArgumentException

use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.

the class QueryTasksAccTest method testQueryForCustom8.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryForCustom8() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().customAttributeLike("8", "%a%", "%b%", "%c%", "%d%", "%e%", "%f%", "%g%", "%h%", "%i%", "%j%", "%k%", "%l%", "%m%", "%n%", "%o%", "%p%", "%q%", "%r%", "%s%", "%w%").list();
    assertThat(results.size(), equalTo(1));
    String[] ids = results.stream().map(t -> {
        try {
            return t.getCustomAttribute("8");
        } catch (InvalidArgumentException e) {
            e.printStackTrace();
            return "";
        }
    }).collect(Collectors.toList()).toArray(new String[0]);
    List<TaskSummary> result2 = taskService.createTaskQuery().customAttributeIn("8", ids).list();
    assertThat(result2.size(), equalTo(1));
}
Also used : InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 5 with InvalidArgumentException

use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.

the class QueryTasksAccTest method testQueryForCustom4.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryForCustom4() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().customAttributeLike("4", "%a%", "%b%", "%c%", "%d%", "%e%", "%f%", "%g%", "%h%", "%i%", "%j%", "%k%", "%l%", "%m%", "%n%", "%o%", "%p%", "%q%", "%r%", "%s%", "%w%").list();
    assertThat(results.size(), equalTo(1));
    String[] ids = results.stream().map(t -> {
        try {
            return t.getCustomAttribute("4");
        } catch (InvalidArgumentException e) {
            e.printStackTrace();
            return "";
        }
    }).collect(Collectors.toList()).toArray(new String[0]);
    List<TaskSummary> result2 = taskService.createTaskQuery().customAttributeIn("4", ids).list();
    assertThat(result2.size(), equalTo(1));
}
Also used : InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Aggregations

InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)41 Test (org.junit.Test)24 AbstractAccTest (acceptance.AbstractAccTest)21 WithAccessId (pro.taskana.security.WithAccessId)19 TaskService (pro.taskana.TaskService)18 TaskSummary (pro.taskana.TaskSummary)16 TaskanaEngineProxyForTest (pro.taskana.impl.TaskanaEngineProxyForTest)12 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)11 ArrayList (java.util.ArrayList)7 List (java.util.List)7 Task (pro.taskana.Task)7 Workbasket (pro.taskana.Workbasket)7 Classification (pro.taskana.Classification)6 ClassificationNotFoundException (pro.taskana.exceptions.ClassificationNotFoundException)6 SQLException (java.sql.SQLException)5 ClassificationSummary (pro.taskana.ClassificationSummary)5 WorkbasketAccessItem (pro.taskana.WorkbasketAccessItem)5 WorkbasketService (pro.taskana.WorkbasketService)5 Instant (java.time.Instant)4 Collectors (java.util.stream.Collectors)4