use of pro.taskana.Classification in project taskana by Taskana.
the class TaskServiceImplTest method testUpdateTaskUpdateAttachment.
@Test
public void testUpdateTaskUpdateAttachment() throws TaskNotFoundException, SystemException, WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException {
String channelUpdate = "OTHER CHANNEL";
Classification classification = createDummyClassification();
Workbasket wb = createWorkbasket("WB-ID", "WB-Key");
Attachment attachment = JunitHelper.createDefaultAttachment();
Attachment attachmentToUpdate = JunitHelper.createDefaultAttachment();
attachmentToUpdate.setChannel(channelUpdate);
ObjectReference objectReference = JunitHelper.createDefaultObjRef();
TaskImpl taskBefore = createUnitTestTask("ID", "taskName", wb.getKey(), classification);
taskBefore.addAttachment(attachment);
TaskImpl task = createUnitTestTask("ID", "taskName", wb.getKey(), classification);
taskBefore.setModified(null);
taskBefore.setCreated(Instant.now());
task.setModified(null);
task.setCreated(taskBefore.getCreated());
task.addAttachment(taskBefore.getAttachments().get(0));
task.setPrimaryObjRef(objectReference);
// should override old one and differ at comparison
task.addAttachment(attachmentToUpdate);
TaskServiceImpl cutSpy = Mockito.spy(cut);
doReturn(taskBefore).when(cutSpy).getTask(task.getId());
Task actualTask = cutSpy.updateTask(task);
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId());
verify(attachmentMapperMock, times(1)).update(((AttachmentImpl) attachmentToUpdate));
verify(taskanaEngineMock, times(1)).returnConnection();
assertThat(actualTask.getAttachments().size(), equalTo(1));
assertThat(actualTask.getAttachments().get(0).getChannel(), equalTo(channelUpdate));
}
use of pro.taskana.Classification in project taskana by Taskana.
the class TaskServiceImplTest method testCreateSimpleTaskWithObjectReference.
@Test
public void testCreateSimpleTaskWithObjectReference() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, TaskNotFoundException, InvalidWorkbasketException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
ObjectReference expectedObjectReference = JunitHelper.createDefaultObjRef();
WorkbasketImpl wb = new WorkbasketImpl();
wb.setId("1");
wb.setName("workbasket");
wb.setKey("k33");
wb.setDomain("dummy-domain");
Classification dummyClassification = createDummyClassification();
TaskImpl expectedTask = createUnitTestTask("", "DUMMYTASK", wb.getKey(), dummyClassification);
expectedTask.setPrimaryObjRef(expectedObjectReference);
ClassificationSummary classification = expectedTask.getClassificationSummary();
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(expectedTask.getId());
doReturn(wb).when(workbasketServiceMock).getWorkbasket(expectedTask.getWorkbasketKey(), expectedTask.getDomain());
doReturn(expectedObjectReference).when(objectReferenceMapperMock).findByObjectReference(expectedObjectReference);
doReturn(dummyClassification).when(classificationServiceImplMock).getClassification(dummyClassification.getKey(), dummyClassification.getDomain());
doNothing().when(taskMapperMock).insert(expectedTask);
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
doReturn(false).when(taskanaEngineConfigurationMock).isSecurityEnabled();
Task actualTask = cutSpy.createTask(expectedTask);
verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).getWorkbasket(wb.getKey(), wb.getDomain());
verify(workbasketServiceMock, times(1)).checkAuthorization(wb.getId(), WorkbasketPermission.APPEND);
verify(classificationServiceImplMock, times(1)).getClassification(classification.getKey(), classification.getDomain());
verify(taskanaEngineMock, times(1)).getConfiguration();
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
verify(taskMapperMock, times(1)).insert(expectedTask);
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock, classificationServiceImplMock);
assertNull(actualTask.getOwner());
assertNotNull(actualTask.getCreated());
assertNotNull(actualTask.getModified());
assertNull(actualTask.getCompleted());
assertThat(actualTask.getWorkbasketKey(), equalTo(expectedTask.getWorkbasketKey()));
assertThat(actualTask.getName(), equalTo(expectedTask.getName()));
assertThat(actualTask.getState(), equalTo(TaskState.READY));
assertThat(actualTask.getPrimaryObjRef(), equalTo(expectedObjectReference));
}
use of pro.taskana.Classification in project taskana by Taskana.
the class TaskServiceImplTest method testCreateSimpleTask.
@Test
public void testCreateSimpleTask() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, TaskNotFoundException, InvalidWorkbasketException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
TaskImpl expectedTask = createUnitTestTask("", "DUMMYTASK", "k1", dummyClassification);
WorkbasketImpl wb = new WorkbasketImpl();
wb.setId("1");
wb.setKey("k1");
wb.setName("workbasket");
wb.setDomain(dummyClassification.getDomain());
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(expectedTask.getId());
doReturn(wb).when(workbasketServiceMock).getWorkbasket(wb.getKey(), wb.getDomain());
doNothing().when(taskMapperMock).insert(expectedTask);
doReturn(dummyClassification).when(classificationServiceImplMock).getClassification(dummyClassification.getKey(), dummyClassification.getDomain());
expectedTask.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
doReturn(false).when(taskanaEngineConfigurationMock).isSecurityEnabled();
Task actualTask = cutSpy.createTask(expectedTask);
verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
verify(workbasketServiceMock, times(1)).getWorkbasket(any(), any());
verify(classificationServiceImplMock, times(1)).getClassification(any(), any());
verify(taskanaEngineMock, times(1)).getConfiguration();
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
verify(taskMapperMock, times(1)).insert(expectedTask);
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock, classificationServiceImplMock);
assertNull(actualTask.getOwner());
assertNotNull(actualTask.getCreated());
assertNotNull(actualTask.getModified());
assertNull(actualTask.getCompleted());
assertThat(actualTask.getWorkbasketKey(), equalTo(expectedTask.getWorkbasketKey()));
assertThat(actualTask.getName(), equalTo(expectedTask.getName()));
assertThat(actualTask.getState(), equalTo(TaskState.READY));
}
use of pro.taskana.Classification in project taskana by Taskana.
the class TaskServiceImplTest method testCompleteForcedNotClaimed.
@Test
public void testCompleteForcedNotClaimed() throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, InterruptedException, ClassificationNotFoundException, NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
final boolean isForced = true;
final long sleepTime = 100L;
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
task.setState(TaskState.READY);
task.setClaimed(null);
doReturn(task).when(cutSpy).getTask(task.getId());
TaskImpl claimedTask = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
// created and modify should be able to be different.
Thread.sleep(sleepTime);
claimedTask.setState(TaskState.CLAIMED);
claimedTask.setClaimed(Instant.now());
doReturn(claimedTask).when(cutSpy).claim(task.getId(), isForced);
doNothing().when(taskMapperMock).update(claimedTask);
Task actualTask = cutSpy.completeTask(task.getId(), isForced);
verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId());
verify(cutSpy, times(1)).claim(task.getId(), isForced);
verify(taskMapperMock, times(1)).update(claimedTask);
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock);
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
assertThat(actualTask.getCreated(), not(equalTo(claimedTask.getModified())));
assertThat(actualTask.getCompleted(), not(equalTo(null)));
assertThat(actualTask.getCompleted(), equalTo(actualTask.getModified()));
}
use of pro.taskana.Classification in project taskana by Taskana.
the class ClassificationServiceImplIntAutoCommitTest method testFindWithClassificationMapperPriorityTypeAndParent.
@Test
public void testFindWithClassificationMapperPriorityTypeAndParent() throws ClassificationAlreadyExistException, NumberFormatException, NotAuthorizedException, ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
Classification classification = this.createDummyClassificationWithUniqueKey("", "TASK");
classification.setPriority(Integer.decode("5"));
classificationService.createClassification(classification);
Classification classification1 = this.createDummyClassificationWithUniqueKey("", "TASK");
classification1.setPriority(Integer.decode("3"));
classification1.setParentId(classification.getId());
classificationService.createClassification(classification1);
Classification classification2 = this.createDummyClassificationWithUniqueKey("", "DOCUMENT");
classification2.setPriority(Integer.decode("5"));
classification2.setParentId(classification.getId());
classificationService.createClassification(classification2);
Classification classification3 = this.createDummyClassificationWithUniqueKey("", "TASK");
classification3.setPriority(Integer.decode("5"));
classification3.setParentId(classification1.getId());
classificationService.createClassification(classification3);
List<ClassificationSummary> list = classificationService.createClassificationQuery().parentIdIn(classification.getId()).list();
Assert.assertEquals(2, list.size());
list = classificationService.createClassificationQuery().typeIn("TASK").priorityIn(Integer.decode("5")).list();
Assert.assertEquals(2, list.size());
list = classificationService.createClassificationQuery().priorityIn(Integer.decode("5")).typeIn("TASK").parentIdIn(classification1.getId()).list();
Assert.assertEquals(1, list.size());
}
Aggregations