use of pro.taskana.Classification in project taskana by Taskana.
the class TaskServiceImplTest method testCreateTaskWithSecurityButNoUserId.
@Test(expected = SystemException.class)
public void testCreateTaskWithSecurityButNoUserId() throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException, TaskAlreadyExistException, 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(true).when(taskanaEngineConfigurationMock).isSecurityEnabled();
cutSpy.createTask(expectedTask);
}
use of pro.taskana.Classification in project taskana by Taskana.
the class TaskServiceImplTest method testTransferTaskToDestinationWorkbasketWithoutSecurity.
@Test
public void testTransferTaskToDestinationWorkbasketWithoutSecurity() throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, InvalidWorkbasketException, ClassificationNotFoundException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Workbasket destinationWorkbasket = createWorkbasket("2", "k1");
Workbasket sourceWorkbasket = createWorkbasket("47", "key47");
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "key47", dummyClassification);
task.setWorkbasketSummary(sourceWorkbasket.asSummary());
task.setRead(true);
doReturn(destinationWorkbasket).when(workbasketServiceMock).getWorkbasket(destinationWorkbasket.getId());
doReturn(sourceWorkbasket).when(workbasketServiceMock).getWorkbasket(sourceWorkbasket.getId());
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
doReturn(false).when(taskanaEngineConfigurationMock).isSecurityEnabled();
doReturn(task).when(cutSpy).getTask(task.getId());
doNothing().when(taskMapperMock).update(any());
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasket.getId(), WorkbasketPermission.APPEND);
doNothing().when(workbasketServiceMock).checkAuthorization(sourceWorkbasket.getId(), WorkbasketPermission.TRANSFER);
Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId());
verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasket.getId(), WorkbasketPermission.APPEND);
verify(workbasketServiceMock, times(1)).checkAuthorization(sourceWorkbasket.getId(), WorkbasketPermission.TRANSFER);
verify(workbasketServiceMock, times(1)).getWorkbasket(destinationWorkbasket.getId());
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 ClassificationServiceImplIntAutoCommitTest method testFindWithClassificationMapperCustomAndCategory.
@Test
public void testFindWithClassificationMapperCustomAndCategory() throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
Classification classification1 = this.createDummyClassificationWithUniqueKey("", "TASK");
classification1.setDescription("DESC1");
classification1.setCategory("EXTERNAL");
classificationService.createClassification(classification1);
Classification classification2 = this.createDummyClassificationWithUniqueKey("", "TASK");
classification2.setDescription("DESC1");
classification2.setCustom1("custom1");
classification2.setCategory("EXTERNAL");
classificationService.createClassification(classification2);
Classification classification3 = this.createDummyClassificationWithUniqueKey("", "TASK");
classification3.setCustom1("custom2");
classification3.setCustom2("custom1");
classification3.setCategory("MANUAL");
classificationService.createClassification(classification3);
Classification classification4 = this.createDummyClassificationWithUniqueKey("", "TASK");
classification4.setDescription("description2");
classification4.setCustom8("custom2");
classification4.setCategory("EXTERNAL");
classificationService.createClassification(classification4);
List<ClassificationSummary> list = classificationService.createClassificationQuery().descriptionLike("DESC1").custom1In("custom1").list();
Assert.assertEquals(1, list.size());
list = classificationService.createClassificationQuery().custom1In("custom2").list();
Assert.assertEquals(1, list.size());
list = classificationService.createClassificationQuery().descriptionLike("DESC1").categoryIn("EXTERNAL").list();
Assert.assertEquals(2, list.size());
}
use of pro.taskana.Classification in project taskana by Taskana.
the class ClassificationServiceImplIntAutoCommitTest method testModifiedClassification.
@Test
public void testModifiedClassification() throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, DomainNotFoundException, InvalidArgumentException {
String description = "TEST SOMETHING";
Classification classification = this.createDummyClassificationWithUniqueKey("DOMAIN_A", "TASK");
classification.setDescription("");
classification = classificationService.createClassification(classification);
classification.setDescription("TEST SOMETHING");
classificationService.updateClassification(classification);
classification = classificationService.getClassification(classification.getKey(), classification.getDomain());
Assert.assertThat(description, equalTo(classification.getDescription()));
}
use of pro.taskana.Classification in project taskana by Taskana.
the class ClassificationServiceImplIntAutoCommitTest method testInsertClassifications.
@Test
public void testInsertClassifications() throws Exception {
final String domain = "DOMAIN_A";
final String key = "dummy-key";
ClassificationImpl expectedClassification;
Classification actualClassification;
Classification actualClassification2;
// empty classification (root)
expectedClassification = (ClassificationImpl) this.createDummyClassificationWithUniqueKey("", "TASK");
expectedClassification = (ClassificationImpl) classificationService.createClassification(expectedClassification);
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.createDummyClassificationWithUniqueKey(domain, "TASK");
expectedClassification.setKey(key);
expectedClassification = (ClassificationImpl) classificationService.createClassification(expectedClassification);
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.createDummyClassificationWithUniqueKey(domain, "TASK");
expectedClassification.setKey(key);
classificationService.createClassification(expectedClassification);
fail("Should have thrown 'ClassificationAlreadyExistException' here.");
} catch (ClassificationAlreadyExistException e) {
}
// new classification but root existing
expectedClassification = (ClassificationImpl) this.createDummyClassificationWithUniqueKey("DOMAIN_B", "TASK");
expectedClassification.setKey(key);
classificationService.createClassification(expectedClassification);
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));
// verify that
Classification rootResults = classificationService.getClassification(key, "");
assertThat(rootResults, not(equalTo(null)));
// invalid serviceLevel
try {
expectedClassification = (ClassificationImpl) this.createDummyClassificationWithUniqueKey(domain, "TASK");
expectedClassification.setKey("");
expectedClassification.setServiceLevel("ASAP");
classificationService.createClassification(expectedClassification);
fail("Should have thrown IllegalArgumentException, because ServiceLevel is invalid.");
} catch (InvalidArgumentException e) {
}
}
Aggregations