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));
}
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));
}
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);
}
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;
}
}
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;
}
}
Aggregations