Search in sources :

Example 41 with Classification

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

the class ClassificationServiceImplTest method testGetClassificationFromDomain.

@Test
public void testGetClassificationFromDomain() throws ClassificationNotFoundException {
    Classification expectedClassification = createDummyClassification();
    doReturn(expectedClassification).when(classificationMapperMock).findByKeyAndDomain(expectedClassification.getKey(), expectedClassification.getDomain());
    Classification actualClassification = cutSpy.getClassification(expectedClassification.getKey(), expectedClassification.getDomain());
    verify(taskanaEngineImplMock, times(1)).openConnection();
    verify(classificationMapperMock, times(1)).findByKeyAndDomain(expectedClassification.getKey(), expectedClassification.getDomain());
    verify(taskanaEngineImplMock, times(1)).returnConnection();
    verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
    assertThat(actualClassification, equalTo(expectedClassification));
}
Also used : Classification(pro.taskana.Classification) Test(org.junit.Test)

Example 42 with Classification

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

the class ClassificationServiceImplTest method testCreateClassificationInOwnDomainAndCopyInRootDomain.

@Test
public void testCreateClassificationInOwnDomainAndCopyInRootDomain() throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
    Classification classification = createDummyClassification();
    String domain = classification.getDomain();
    String key = classification.getKey();
    doReturn(null).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(), classification.getDomain());
    doReturn(null).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(), "");
    doReturn(true).when(taskanaEngineImplMock).domainExists(any());
    classification = cutSpy.createClassification(classification);
    verify(taskanaEngineImplMock, times(2)).openConnection();
    verify(classificationMapperMock, times(1)).findByKeyAndDomain(key, domain);
    verify(classificationMapperMock, times(2)).findByKeyAndDomain(key, "");
    verify(classificationMapperMock, times(2)).insert(any());
    verify(taskanaEngineImplMock, times(2)).returnConnection();
    verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
    verify(taskanaEngineImplMock, times(1)).domainExists(any());
    verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
    assertThat(classification.getCreated().toString().substring(0, 10), equalTo(todaysDate));
    assertThat(classification.getDomain(), equalTo(domain));
    assertThat(classification.getKey(), equalTo(key));
}
Also used : Classification(pro.taskana.Classification) Test(org.junit.Test)

Example 43 with Classification

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

the class ClassificationServiceImplTest method testUpdateExistingClassification.

@Test
public void testUpdateExistingClassification() throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, InvalidArgumentException {
    Instant now = Instant.now();
    Classification classification = createDummyClassification();
    ((ClassificationImpl) classification).setModified(now);
    ClassificationImpl oldClassification = (ClassificationImpl) createDummyClassification();
    oldClassification.setModified(now);
    doReturn(oldClassification).when(cutSpy).getClassification(classification.getKey(), classification.getDomain());
    classification = cutSpy.updateClassification(classification);
    verify(taskanaEngineImplMock, times(1)).openConnection();
    verify(cutSpy, times(1)).getClassification(classification.getKey(), classification.getDomain());
    verify(classificationMapperMock, times(1)).update(any());
    verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
    verify(taskanaEngineImplMock, times(1)).returnConnection();
    verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
}
Also used : Instant(java.time.Instant) Classification(pro.taskana.Classification) Test(org.junit.Test)

Example 44 with Classification

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

the class ClassificationServiceImplTest method testGetClassificationThrowingNotFoundException.

@Test(expected = ClassificationNotFoundException.class)
public void testGetClassificationThrowingNotFoundException() throws ClassificationNotFoundException {
    Classification classification = createDummyClassification();
    doReturn(null).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(), classification.getDomain());
    doReturn(null).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(), "");
    try {
        cutSpy.getClassification(classification.getKey(), classification.getDomain());
    } catch (ClassificationNotFoundException e) {
        verify(taskanaEngineImplMock, times(1)).openConnection();
        verify(classificationMapperMock, times(1)).findByKeyAndDomain(classification.getKey(), classification.getDomain());
        verify(classificationMapperMock, times(1)).findByKeyAndDomain(classification.getKey(), "");
        verify(taskanaEngineImplMock, times(1)).returnConnection();
        verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
        throw e;
    }
}
Also used : Classification(pro.taskana.Classification) ClassificationNotFoundException(pro.taskana.exceptions.ClassificationNotFoundException) Test(org.junit.Test)

Example 45 with Classification

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

the class ClassificationServiceImplTest method testCreateClassificationAlreadyExisting.

@Test(expected = ClassificationAlreadyExistException.class)
public void testCreateClassificationAlreadyExisting() throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException, DomainNotFoundException, InvalidArgumentException {
    Classification classification = createDummyClassification();
    doReturn(classification).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(), classification.getDomain());
    doReturn(true).when(taskanaEngineImplMock).domainExists(any());
    try {
        cutSpy.createClassification(classification);
    } catch (ClassificationAlreadyExistException e) {
        verify(taskanaEngineImplMock, times(1)).openConnection();
        verify(classificationMapperMock, times(1)).findByKeyAndDomain(classification.getKey(), classification.getDomain());
        verify(taskanaEngineImplMock, times(1)).returnConnection();
        verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
        verify(taskanaEngineImplMock, times(1)).domainExists(any());
        verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
        throw e;
    }
}
Also used : Classification(pro.taskana.Classification) ClassificationAlreadyExistException(pro.taskana.exceptions.ClassificationAlreadyExistException) Test(org.junit.Test)

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