Search in sources :

Example 61 with Classification

use of pro.taskana.Classification in project taskana by Taskana.

the class ClassificationServiceImplIntExplicitTest method testDefaultSettingsWithClassificationQuery.

@Test
public void testDefaultSettingsWithClassificationQuery() throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, DomainNotFoundException {
    Connection connection = dataSource.getConnection();
    taskanaEngineImpl.setConnection(connection);
    Classification classification = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
    classification = classificationService.createClassification(classification);
    Classification classification1 = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
    classification1 = classificationService.createClassification(classification1);
    classification1.setParentId(classification.getId());
    classification1 = classificationService.updateClassification(classification1);
    List<ClassificationSummary> list = classificationService.createClassificationQuery().parentIdIn("").list();
    Assert.assertEquals(3, list.size());
    list = classificationService.createClassificationQuery().list();
    Assert.assertEquals(4, list.size());
    connection.commit();
    list = classificationService.createClassificationQuery().validInDomainEquals(true).list();
    Assert.assertEquals(2, list.size());
    list = classificationService.createClassificationQuery().createdWithin(today()).list();
    Assert.assertEquals(4, list.size());
    list = classificationService.createClassificationQuery().domainIn("DOMAIN_C").validInDomainEquals(false).list();
    Assert.assertEquals(0, list.size());
    list = classificationService.createClassificationQuery().keyIn(classification1.getKey()).list();
    Assert.assertEquals(2, list.size());
    list = classificationService.createClassificationQuery().parentIdIn(classification.getId()).list();
    Assert.assertEquals(1, list.size());
    assertThat(list.get(0).getKey(), equalTo(classification1.getKey()));
    connection.commit();
}
Also used : ClassificationSummary(pro.taskana.ClassificationSummary) Classification(pro.taskana.Classification) Connection(java.sql.Connection) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Example 62 with Classification

use of pro.taskana.Classification in project taskana by Taskana.

the class ClassificationServiceImplIntExplicitTest method testInsertClassification.

@Test
public void testInsertClassification() throws SQLException, ClassificationNotFoundException, ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException, InvalidArgumentException {
    Connection connection = dataSource.getConnection();
    taskanaEngineImpl.setConnection(connection);
    final String domain = "DOMAIN_A";
    final String key = "dummy-key";
    ClassificationImpl expectedClassification;
    Classification actualClassification;
    Classification actualClassification2;
    // empty classification (root)
    expectedClassification = (ClassificationImpl) this.createNewClassificationWithUniqueKey("", "TASK");
    expectedClassification = (ClassificationImpl) classificationService.createClassification(expectedClassification);
    connection.commit();
    actualClassification = classificationService.getClassification(expectedClassification.getKey(), expectedClassification.getDomain());
    assertThat(actualClassification, not(equalTo(null)));
    assertThat(actualClassification.getCreated(), not(equalTo(null)));
    assertThat(actualClassification.getId(), not(equalTo(null)));
    assertThat(actualClassification.getId(), startsWith(ID_PREFIX_CLASSIFICATION));
    // specific to domain + root
    expectedClassification = (ClassificationImpl) this.createNewClassificationWithUniqueKey(domain, "TASK");
    expectedClassification.setKey(key);
    expectedClassification = (ClassificationImpl) classificationService.createClassification(expectedClassification);
    connection.commit();
    actualClassification = classificationService.getClassification(expectedClassification.getKey(), expectedClassification.getDomain());
    actualClassification2 = classificationService.getClassification(expectedClassification.getKey(), "");
    assertThat(actualClassification, not(equalTo(null)));
    assertThat(actualClassification.getCreated(), not(equalTo(null)));
    assertThat(actualClassification.getId(), not(equalTo(null)));
    assertThat(actualClassification.getKey(), equalTo(key));
    assertThat(actualClassification.getDomain(), equalTo(domain));
    assertThat(actualClassification.getId(), startsWith(ID_PREFIX_CLASSIFICATION));
    assertThat(actualClassification2, not(equalTo(null)));
    assertThat(actualClassification2.getCreated(), not(equalTo(null)));
    assertThat(actualClassification2.getId(), not(equalTo(null)));
    assertThat(actualClassification2.getId(), not(equalTo(actualClassification.getId())));
    assertThat(actualClassification2.getKey(), equalTo(key));
    assertThat(actualClassification2.getDomain(), equalTo(""));
    assertThat(actualClassification2.getId(), startsWith(ID_PREFIX_CLASSIFICATION));
    // does exist already
    try {
        expectedClassification = (ClassificationImpl) this.createNewClassificationWithUniqueKey(domain, "TASK");
        expectedClassification.setKey(key);
        classificationService.createClassification(expectedClassification);
        connection.commit();
        fail("Should have thrown 'ClassificationAlreadyExistException' here.");
    } catch (ClassificationAlreadyExistException e) {
    }
    // new classification but root existing
    expectedClassification = (ClassificationImpl) this.createNewClassificationWithUniqueKey("", "TASK");
    expectedClassification.setKey(key);
    expectedClassification.setDomain("DOMAIN_B");
    classificationService.createClassification(expectedClassification);
    connection.commit();
    actualClassification = classificationService.getClassification(key, "DOMAIN_B");
    assertThat(actualClassification, not(equalTo(null)));
    assertThat(actualClassification.getCreated(), not(equalTo(null)));
    assertThat(actualClassification.getId(), not(equalTo(null)));
    assertThat(actualClassification.getKey(), equalTo(key));
    assertThat(actualClassification.getDomain(), equalTo("DOMAIN_B"));
    assertThat(actualClassification.getId(), startsWith(ID_PREFIX_CLASSIFICATION));
    Classification rootResult = classificationService.getClassification(key, "");
    assertThat(rootResult, not(equalTo(null)));
    // invalid serviceLevel
    try {
        expectedClassification = (ClassificationImpl) this.createNewClassificationWithUniqueKey("", "TASK");
        expectedClassification.setDomain(domain);
        expectedClassification.setKey("");
        expectedClassification.setServiceLevel("ASAP");
        classificationService.createClassification(expectedClassification);
        connection.commit();
        fail("Should have thrown IllegalArgumentException, because ServiceLevel is invalid.");
    } catch (InvalidArgumentException e) {
    }
}
Also used : InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) Classification(pro.taskana.Classification) ClassificationAlreadyExistException(pro.taskana.exceptions.ClassificationAlreadyExistException) Connection(java.sql.Connection) ClassificationImpl(pro.taskana.impl.ClassificationImpl) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Example 63 with Classification

use of pro.taskana.Classification in project taskana by Taskana.

the class ClassificationServiceImplIntExplicitTest method testFindAllClassifications.

@Test
public void testFindAllClassifications() throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
    Connection connection = dataSource.getConnection();
    taskanaEngineImpl.setConnection(connection);
    Classification classification0 = this.createNewClassificationWithUniqueKey("", "TASK");
    classificationService.createClassification(classification0);
    Classification classification1 = this.createNewClassificationWithUniqueKey("", "TASK");
    classificationService.createClassification(classification1);
    Classification classification2 = this.createNewClassificationWithUniqueKey("", "TASK");
    classification2.setParentId(classification0.getId());
    classificationService.createClassification(classification2);
    Assert.assertEquals(2 + 1, classificationService.createClassificationQuery().list().size());
    connection.commit();
}
Also used : Classification(pro.taskana.Classification) Connection(java.sql.Connection) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Example 64 with Classification

use of pro.taskana.Classification in project taskana by Taskana.

the class TaskServiceImplIntExplicitTest method should_ReturnList_when_BuilderIsUsed.

@WithAccessId(userName = "Elena", groupNames = { "DummyGroup", "businessadmin" })
@Test
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, SystemException, WorkbasketAlreadyExistException, DomainNotFoundException {
    Connection connection = dataSource.getConnection();
    taskanaEngineImpl.setConnection(connection);
    generateSampleAccessItems();
    WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
    workbasket.setName("workbasket");
    Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
    classificationService.createClassification(classification);
    // set id manually for authorization tests
    workbasket.setId("1");
    workbasket.setType(WorkbasketType.GROUP);
    workbasket = (WorkbasketImpl) workbasketService.createWorkbasket(workbasket);
    Task task = taskServiceImpl.newTask(workbasket.getId());
    task.setName("Unit Test Task");
    task.setClassificationKey(classification.getKey());
    task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
    task = taskServiceImpl.createTask(task);
    List<TaskSummary> results = taskServiceImpl.createTaskQuery().nameIn("bla", "test").descriptionLike("test").priorityIn(1, 2, 2).stateIn(TaskState.CLAIMED).workbasketKeyDomainIn(new KeyDomain("k1", "DOMAIN_A")).ownerIn("test", "test2", "bla").customAttributeLike("13", "test").classificationKeyIn("pId1", "pId2").primaryObjectReferenceCompanyIn("first comp", "sonstwo gmbh").primaryObjectReferenceSystemIn("sys").primaryObjectReferenceTypeIn("type1", "type2").primaryObjectReferenceSystemInstanceIn("sysInst1", "sysInst2").primaryObjectReferenceValueIn("val1", "val2", "val3").list();
    Assert.assertEquals(0, results.size());
    connection.commit();
}
Also used : Task(pro.taskana.Task) Classification(pro.taskana.Classification) Connection(java.sql.Connection) TaskSummary(pro.taskana.TaskSummary) WorkbasketImpl(pro.taskana.impl.WorkbasketImpl) KeyDomain(pro.taskana.KeyDomain) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 65 with Classification

use of pro.taskana.Classification in project taskana by Taskana.

the class TaskServiceImplIntExplicitTest method createManualTaskShouldThrowClassificationNotFoundException.

@WithAccessId(userName = "Elena", groupNames = { "businessadmin" })
@Test(expected = ClassificationNotFoundException.class)
public void createManualTaskShouldThrowClassificationNotFoundException() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
    Connection connection = dataSource.getConnection();
    taskanaEngineImpl.setConnection(connection);
    generateSampleAccessItems();
    Workbasket wb = workbasketService.newWorkbasket("WB NR.1", "DOMAIN_A");
    wb.setName("dummy-WB");
    wb.setType(WorkbasketType.PERSONAL);
    wb = workbasketService.createWorkbasket(wb);
    this.createWorkbasketWithSecurity(wb, CurrentUserContext.getUserid(), true, true, true, false);
    Classification classification = classificationService.newClassification(UUID.randomUUID().toString(), wb.getDomain(), // not persisted,
    "t1");
    // not found.
    classification.setName("not persisted - so not found.");
    Task task = this.generateDummyTask();
    ((TaskImpl) task).setWorkbasketKey(wb.getKey());
    task.setClassificationKey(classification.getKey());
    taskServiceImpl.createTask(task);
}
Also used : Task(pro.taskana.Task) TaskImpl(pro.taskana.impl.TaskImpl) Classification(pro.taskana.Classification) Connection(java.sql.Connection) Workbasket(pro.taskana.Workbasket) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Aggregations

Classification (pro.taskana.Classification)102 Test (org.junit.Test)88 Task (pro.taskana.Task)32 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)29 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)28 AbstractAccTest (acceptance.AbstractAccTest)23 WithAccessId (pro.taskana.security.WithAccessId)21 ClassificationSummary (pro.taskana.ClassificationSummary)20 Workbasket (pro.taskana.Workbasket)18 Connection (java.sql.Connection)14 ClassificationNotFoundException (pro.taskana.exceptions.ClassificationNotFoundException)14 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)13 TaskAlreadyExistException (pro.taskana.exceptions.TaskAlreadyExistException)11 ClassificationService (pro.taskana.ClassificationService)10 AttachmentPersistenceException (pro.taskana.exceptions.AttachmentPersistenceException)10 ConcurrencyException (pro.taskana.exceptions.ConcurrencyException)10 InvalidOwnerException (pro.taskana.exceptions.InvalidOwnerException)10 InvalidStateException (pro.taskana.exceptions.InvalidStateException)10 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)10 SystemException (pro.taskana.exceptions.SystemException)10