use of pro.taskana.Classification in project taskana by Taskana.
the class ClassificationServiceImplTest method testCreateClassificationInOwnDomainButExistingInRoot.
@Test
public void testCreateClassificationInOwnDomainButExistingInRoot() throws ClassificationAlreadyExistException, ClassificationNotFoundException, InterruptedException, NotAuthorizedException, DomainNotFoundException, InvalidArgumentException {
Instant beforeTimestamp = Instant.now();
Thread.sleep(10L);
Classification classification = createDummyClassification();
String domain = classification.getDomain();
String key = classification.getKey();
doReturn(null).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(), classification.getDomain());
doReturn(classification).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(), "");
doReturn(true).when(taskanaEngineImplMock).domainExists(any());
classification = cutSpy.createClassification(classification);
Thread.sleep(10L);
verify(taskanaEngineImplMock, times(2)).openConnection();
verify(classificationMapperMock, times(1)).findByKeyAndDomain(key, domain);
verify(classificationMapperMock, times(1)).findByKeyAndDomain(key, "");
verify(classificationMapperMock, times(1)).insert(any());
verify(taskanaEngineImplMock, times(2)).returnConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(1)).domainExists(any());
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
Thread.sleep(15);
assertThat(classification.getCreated().toString().substring(0, 10), equalTo(todaysDate));
assertFalse(classification.getCreated().isAfter(Instant.now()));
assertTrue(classification.getCreated().isAfter(beforeTimestamp));
assertThat(classification.getDomain(), equalTo(domain));
assertThat(classification.getKey(), equalTo(key));
}
use of pro.taskana.Classification in project taskana by Taskana.
the class TaskServiceImplTest method testTransferTaskToDestinationWorkbasketUsingSecurityTrue.
@Test
public void testTransferTaskToDestinationWorkbasketUsingSecurityTrue() throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, InvalidWorkbasketException, ClassificationNotFoundException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Workbasket destinationWorkbasket = createWorkbasket("2", "k2");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "k1", dummyClassification);
task.setRead(true);
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
doReturn(true).when(taskanaEngineConfigurationMock).isSecurityEnabled();
doReturn(task).when(cutSpy).getTask(task.getId());
doReturn(destinationWorkbasket).when(workbasketServiceMock).getWorkbasket(destinationWorkbasket.getId());
doNothing().when(taskMapperMock).update(any());
doNothing().when(workbasketServiceMock).checkAuthorization(any(), any());
// doNothing().when(workbasketServiceMock).checkAuthorizationById(any(), WorkbasketAuthorization.TRANSFER);
Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId());
verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(2)).checkAuthorization(any(), any());
verify(workbasketServiceMock, times(1)).getWorkbasket(destinationWorkbasket.getId());
verify(taskanaEngineMock, times(0)).getConfiguration();
verify(taskanaEngineConfigurationMock, times(0)).isSecurityEnabled();
verify(taskMapperMock, times(1)).update(any());
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock);
assertThat(actualTask.isRead(), equalTo(false));
assertThat(actualTask.getState(), equalTo(TaskState.READY));
assertThat(actualTask.isTransferred(), equalTo(true));
assertThat(actualTask.getWorkbasketKey(), equalTo(destinationWorkbasket.getKey()));
}
use of pro.taskana.Classification in project taskana by Taskana.
the class TaskServiceImplTest method testGetTaskByIdWhereTaskDoesNotExist.
@Test(expected = TaskNotFoundException.class)
public void testGetTaskByIdWhereTaskDoesNotExist() throws Exception {
Classification dummyClassification = createDummyClassification();
Task task = createUnitTestTask("1", "DUMMY-TASK", "1", dummyClassification);
doThrow(TaskNotFoundException.class).when(taskMapperMock).findById(task.getId());
try {
cut.getTask(task.getId());
} catch (Exception e) {
verify(taskanaEngineMock, times(1)).openConnection();
verify(taskMapperMock, times(1)).findById(task.getId());
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock);
throw e;
}
}
use of pro.taskana.Classification in project taskana by Taskana.
the class CreateClassificationAccTest method testCreateRootClassification.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testCreateRootClassification() throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException, DomainNotFoundException, InvalidArgumentException {
long amountOfClassificationsBefore = classificationService.createClassificationQuery().count();
Classification classification = classificationService.newClassification("Key0", "", "TASK");
classification.setIsValidInDomain(true);
classification = classificationService.createClassification(classification);
// check only 1 created
long amountOfClassificationsAfter = classificationService.createClassificationQuery().count();
assertThat(amountOfClassificationsAfter, equalTo(amountOfClassificationsBefore + 1));
classification = classificationService.getClassification(classification.getId());
assertNotNull(classification);
assertNotNull(classification.getCreated());
assertNotNull(classification.getModified());
assertNotNull(classification.getId());
assertThat(classification.getIsValidInDomain(), equalTo(false));
}
use of pro.taskana.Classification in project taskana by Taskana.
the class CreateClassificationAccTest method testCreateClassificationAlreadyExisting.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test(expected = ClassificationAlreadyExistException.class)
public void testCreateClassificationAlreadyExisting() throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
Classification classification = classificationService.newClassification("Key3", "", "TASK");
classification = classificationService.createClassification(classification);
classification = classificationService.createClassification(classification);
}
Aggregations