Merge branch 'master' of https://github.com/Taskana/taskana into TSK-65
This commit is contained in:
commit
c085f4e5f8
|
@ -1,16 +1,17 @@
|
|||
package pro.taskana;
|
||||
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.Task;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.EJB;
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
import javax.enterprise.context.Initialized;
|
||||
import javax.enterprise.event.Observes;
|
||||
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.Task;
|
||||
|
||||
@ApplicationScoped
|
||||
public class ExampleBootstrap {
|
||||
|
||||
|
@ -18,9 +19,9 @@ public class ExampleBootstrap {
|
|||
private TaskanaEjb taskanaEjb;
|
||||
|
||||
@PostConstruct
|
||||
public void init(@Observes @Initialized(ApplicationScoped.class) Object init) throws TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException {
|
||||
public void init(@Observes @Initialized(ApplicationScoped.class) Object init) throws TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
System.out.println("---------------------------> Start App");
|
||||
Task task = taskanaEjb.getTaskService().create(new Task());
|
||||
Task task = taskanaEjb.getTaskService().createTask(new Task());
|
||||
System.out.println("---------------------------> Task started: " + task.getId());
|
||||
taskanaEjb.getTaskService().claim(task.getId(), "John Doe");
|
||||
System.out.println(
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package pro.taskana;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
|
@ -13,10 +12,10 @@ import javax.naming.Context;
|
|||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
@ApplicationScoped
|
||||
public class TaskanaProducers {
|
||||
|
@ -61,4 +60,16 @@ public class TaskanaProducers {
|
|||
return taskanaEngine.getTaskService();
|
||||
}
|
||||
|
||||
@ApplicationScoped
|
||||
@Produces
|
||||
public ClassificationService generateClassificationService() {
|
||||
return taskanaEngine.getClassificationService();
|
||||
}
|
||||
|
||||
@ApplicationScoped
|
||||
@Produces
|
||||
public WorkbasketService generateWorkbasketService() {
|
||||
return taskanaEngine.getWorkbasketService();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,24 +1,39 @@
|
|||
package pro.taskana;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.Task;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.inject.Inject;
|
||||
|
||||
@Stateless
|
||||
public class TaskanaEjb {
|
||||
|
||||
@Inject
|
||||
private TaskService taskService;
|
||||
|
||||
@Inject
|
||||
private ClassificationService classificationService;
|
||||
|
||||
@Inject
|
||||
private WorkbasketService workbasketService;
|
||||
|
||||
public TaskService getTaskService() {
|
||||
return taskService;
|
||||
}
|
||||
|
||||
public void triggerRollback() throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
Task t = taskService.create(new Task());
|
||||
public ClassificationService getClassificationService() {
|
||||
return classificationService;
|
||||
}
|
||||
|
||||
public WorkbasketService getWorkbasketService() {
|
||||
return workbasketService;
|
||||
}
|
||||
|
||||
public void triggerRollback() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
Task t = taskService.createTask(new Task());
|
||||
System.out.println("---------------->" + t.getId());
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
package pro.taskana;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.Classification;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.Workbasket;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
@Path("/test")
|
||||
public class TaskanaRestTest {
|
||||
|
@ -24,14 +23,25 @@ public class TaskanaRestTest {
|
|||
private TaskanaEjb taskanaEjb;
|
||||
|
||||
@GET
|
||||
public Response startTask() throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
Task result = taskanaEjb.getTaskService().create(new Task());
|
||||
public Response startTask() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
Workbasket workbasket = new Workbasket();
|
||||
workbasket.setName("wb");
|
||||
taskanaEjb.getWorkbasketService().createWorkbasket(workbasket);
|
||||
Classification classification = new Classification();
|
||||
taskanaEjb.getClassificationService().addClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
task.setClassification(classification);
|
||||
task.setWorkbasketId(workbasket.getId());
|
||||
|
||||
Task result = taskanaEjb.getTaskService().createTask(task);
|
||||
|
||||
logger.info(result.getId() + ":" + result.getOwner());
|
||||
return Response.status(200).entity(result.getId()).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
public Response rollbackTask() throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
public Response rollbackTask() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
taskanaEjb.triggerRollback();
|
||||
return Response.status(204).build();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package pro.taskana;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.TaskSummary;
|
||||
|
||||
/**
|
||||
|
@ -9,5 +10,5 @@ import pro.taskana.model.TaskSummary;
|
|||
*/
|
||||
public interface SummaryService {
|
||||
|
||||
List<TaskSummary> getTaskSummariesByWorkbasketId(String workbasketId);
|
||||
List<TaskSummary> getTaskSummariesByWorkbasketId(String workbasketId) throws WorkbasketNotFoundException;
|
||||
}
|
||||
|
|
|
@ -4,11 +4,12 @@ import pro.taskana.exceptions.ClassificationNotFoundException;
|
|||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.*;
|
||||
import pro.taskana.model.DueWorkbasketCounter;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.TaskStateCounter;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The Task Service manages all operations on tasks.
|
||||
|
@ -41,21 +42,8 @@ public interface TaskService {
|
|||
* @return the created task
|
||||
* @throws NotAuthorizedException
|
||||
*/
|
||||
Task create(Task task) throws NotAuthorizedException, WorkbasketNotFoundException;
|
||||
Task createTask(Task task) throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException;
|
||||
|
||||
/**
|
||||
* Create a task manually by filling the fields.
|
||||
* @param workbasketId not null
|
||||
* @param classificationId not null
|
||||
* @param domain
|
||||
* @param planned
|
||||
* @param name
|
||||
* @param description
|
||||
* @param primaryObjectReference
|
||||
* @param customAttributes
|
||||
* @return
|
||||
*/
|
||||
Task createManualTask(String workbasketId, String classificationId, String domain, Timestamp planned, String name, String description, ObjectReference primaryObjectReference, Map<String, Object> customAttributes) throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException;
|
||||
/**
|
||||
* Get the details of a task.
|
||||
* @param taskId
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package pro.taskana.impl;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import pro.taskana.ClassificationQuery;
|
||||
import pro.taskana.ClassificationService;
|
||||
import pro.taskana.TaskanaEngine;
|
||||
|
@ -16,9 +18,6 @@ import java.time.LocalDate;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This is the implementation of ClassificationService.
|
||||
*/
|
||||
|
@ -170,6 +169,9 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
|
||||
@Override
|
||||
public Classification getClassification(String id, String domain) throws ClassificationNotFoundException {
|
||||
if (id == null) {
|
||||
throw new ClassificationNotFoundException(null);
|
||||
}
|
||||
LOGGER.debug("entry to getClassification(id = {}, domain = {})", id, domain);
|
||||
Classification result = null;
|
||||
try {
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import pro.taskana.SummaryService;
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.impl.util.LoggerUtils;
|
||||
import pro.taskana.model.TaskSummary;
|
||||
import pro.taskana.model.mappings.SummaryMapper;
|
||||
|
@ -28,9 +29,10 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<TaskSummary> getTaskSummariesByWorkbasketId(String workbasketId) {
|
||||
public List<TaskSummary> getTaskSummariesByWorkbasketId(String workbasketId) throws WorkbasketNotFoundException {
|
||||
LOGGER.debug("entry to getTaskSummariesByWorkbasketId(workbasketId = {}", workbasketId);
|
||||
List<TaskSummary> taskSummaries = new ArrayList<>();
|
||||
taskanaEngineImpl.getWorkbasketService().getWorkbasket(workbasketId);
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskSummaries = summaryMapper.findTasksummariesByWorkbasketId(workbasketId);
|
||||
|
|
|
@ -1,17 +1,7 @@
|
|||
package pro.taskana.impl;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.TaskQuery;
|
||||
import pro.taskana.TaskService;
|
||||
import pro.taskana.TaskanaEngine;
|
||||
|
@ -21,16 +11,18 @@ import pro.taskana.exceptions.TaskNotFoundException;
|
|||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.impl.util.IdGenerator;
|
||||
import pro.taskana.impl.util.LoggerUtils;
|
||||
import pro.taskana.model.Classification;
|
||||
import pro.taskana.model.DueWorkbasketCounter;
|
||||
import pro.taskana.model.ObjectReference;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.TaskStateCounter;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
import pro.taskana.model.*;
|
||||
import pro.taskana.model.mappings.ObjectReferenceMapper;
|
||||
import pro.taskana.model.mappings.TaskMapper;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is the implementation of TaskService.
|
||||
*/
|
||||
|
@ -109,66 +101,31 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Task create(Task task) throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
LOGGER.debug("entry to create(task = {})", task);
|
||||
public Task createTask(Task task) throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
LOGGER.debug("entry to createTask(task = {})", task);
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
Workbasket wb = taskanaEngine.getWorkbasketService().getWorkbasket(task.getWorkbasketId());
|
||||
taskanaEngine.getWorkbasketService().checkAuthorization(task.getWorkbasketId(), WorkbasketAuthorization.APPEND);
|
||||
|
||||
Classification classification = task.getClassification();
|
||||
if (classification == null) {
|
||||
throw new ClassificationNotFoundException(null);
|
||||
}
|
||||
taskanaEngine.getClassificationService().getClassification(classification.getId(), "");
|
||||
|
||||
standardSettings(task);
|
||||
|
||||
this.taskMapper.insert(task);
|
||||
|
||||
LOGGER.debug("Method create() created Task '{}'.", task.getId());
|
||||
LOGGER.debug("Method createTask() created Task '{}'.", task.getId());
|
||||
return task;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
LOGGER.debug("exit from create(task = {})");
|
||||
LOGGER.debug("exit from createTask(task = {})");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task createManualTask(String workbasketId, String classificationId, String domain, Timestamp planned, String name,
|
||||
String description, ObjectReference primaryObjectReference, Map<String, Object> customAttributes) throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("entry to createManualTask(workbasketId = {}, classificationId = {}, domain = {}, planned = {}, name = {},"
|
||||
+ " description = {}, primaryObjectReference = {}, customAttributes = {})", workbasketId, classificationId, domain, planned, name,
|
||||
description, primaryObjectReference, LoggerUtils.mapToString(customAttributes));
|
||||
}
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.getWorkbasketService().checkAuthorization(workbasketId, WorkbasketAuthorization.APPEND);
|
||||
|
||||
taskanaEngine.getWorkbasketService().getWorkbasket(workbasketId);
|
||||
Classification classification = taskanaEngine.getClassificationService().getClassification(classificationId, domain);
|
||||
|
||||
if (!TYPE_MANUAL.equals(classification.getCategory())) {
|
||||
throw new NotAuthorizedException("You're not allowed to add a task manually to a '" + classification.getCategory() + "'- Classification!");
|
||||
}
|
||||
|
||||
Task task = new Task();
|
||||
|
||||
task.setWorkbasketId(workbasketId);
|
||||
task.setClassification(classification);
|
||||
task.setPlanned(planned);
|
||||
task.setPrimaryObjRef(primaryObjectReference);
|
||||
task.setCustomAttributes(customAttributes);
|
||||
task.setName(name);
|
||||
task.setDescription(description);
|
||||
|
||||
this.standardSettings(task);
|
||||
this.setCustomAttributes(task);
|
||||
|
||||
this.taskMapper.insert(task);
|
||||
|
||||
LOGGER.debug("Method create() created Task '{}'.", task.getId());
|
||||
return task;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
LOGGER.debug("exit from create()");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task getTaskById(String id) throws TaskNotFoundException {
|
||||
LOGGER.debug("entry to getTaskById(id = {})", id);
|
||||
|
@ -382,34 +339,4 @@ public class TaskServiceImpl implements TaskService {
|
|||
task.setPrimaryObjRef(objectReference);
|
||||
}
|
||||
}
|
||||
|
||||
private void setCustomAttributes(Task task) {
|
||||
if (task.getCustomAttributes() != null) {
|
||||
for (String custom : task.getCustomAttributes().keySet()) {
|
||||
if (task.getCustom1() == null) {
|
||||
task.setCustom1(custom);
|
||||
} else if (task.getCustom2() == null) {
|
||||
task.setCustom2(custom);
|
||||
} else if (task.getCustom3() == null) {
|
||||
task.setCustom3(custom);
|
||||
} else if (task.getCustom4() == null) {
|
||||
task.setCustom4(custom);
|
||||
} else if (task.getCustom5() == null) {
|
||||
task.setCustom5(custom);
|
||||
} else if (task.getCustom6() == null) {
|
||||
task.setCustom6(custom);
|
||||
} else if (task.getCustom7() == null) {
|
||||
task.setCustom7(custom);
|
||||
} else if (task.getCustom8() == null) {
|
||||
task.setCustom8(custom);
|
||||
} else if (task.getCustom9() == null) {
|
||||
task.setCustom9(custom);
|
||||
} else if (task.getCustom10() == null) {
|
||||
task.setCustom10(custom);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import pro.taskana.model.Classification;
|
|||
import pro.taskana.model.mappings.ClassificationMapper;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -87,6 +88,22 @@ public class ClassificationServiceImplTest {
|
|||
Assert.assertEquals(classification2.getValidUntil(), classification3.getValidUntil());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetClassification() throws ClassificationNotFoundException, SQLException {
|
||||
doNothing().when(classificationMapper).insert(any());
|
||||
doNothing().when(taskanaEngineImpl).openConnection();
|
||||
doNothing().when(taskanaEngineImpl).returnConnection();
|
||||
|
||||
Classification classification = new Classification();
|
||||
classification.setDomain("domain");
|
||||
classificationService.addClassification(classification);
|
||||
|
||||
doReturn(classification).when(classificationMapper).findByIdAndDomain(any(), any(), any());
|
||||
|
||||
Classification test = classificationService.getClassification(classification.getId(), "domain");
|
||||
Assert.assertEquals("domain", test.getDomain());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindAllClassifications() throws NotAuthorizedException {
|
||||
doNothing().when(classificationMapper).insert(any());
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
package pro.taskana.impl;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.TaskSummary;
|
||||
import pro.taskana.model.Workbasket;
|
||||
import pro.taskana.model.mappings.SummaryMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* Testing the {@link SummaryServiceImpl} component.
|
||||
* Mocks are initialized before each Method by @Runner-Annotation.
|
||||
|
@ -42,14 +38,19 @@ public class SummaryServiceImplTest {
|
|||
@Mock
|
||||
private SqlSession sqlSessionMock;
|
||||
|
||||
@Mock
|
||||
private WorkbasketServiceImpl workbasketServiceMock;
|
||||
|
||||
@Test
|
||||
public void testGetTaskSummariesByWorkbasketIdWithInternalException() {
|
||||
public void testGetTaskSummariesByWorkbasketIdWithInternalException() throws WorkbasketNotFoundException {
|
||||
// given - set behaviour and expected result
|
||||
String workbasketId = "1";
|
||||
List<TaskSummary> expectedResultList = new ArrayList<>();
|
||||
doNothing().when(taskanaEngineImplMock).openConnection();
|
||||
doThrow(new IllegalArgumentException("Invalid ID: " + workbasketId)).when(summaryMapperMock).findTasksummariesByWorkbasketId(workbasketId);
|
||||
doNothing().when(taskanaEngineImplMock).returnConnection();
|
||||
doReturn(workbasketServiceMock).when(taskanaEngineImplMock).getWorkbasketService();
|
||||
doReturn(new Workbasket()).when(workbasketServiceMock).getWorkbasket(any());
|
||||
|
||||
// when - make the call
|
||||
List<TaskSummary> actualResultList = cut.getTaskSummariesByWorkbasketId(workbasketId);
|
||||
|
@ -58,42 +59,56 @@ public class SummaryServiceImplTest {
|
|||
verify(taskanaEngineImplMock, times(1)).openConnection();
|
||||
verify(summaryMapperMock, times(1)).findTasksummariesByWorkbasketId(workbasketId);
|
||||
verify(taskanaEngineImplMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(summaryMapperMock, taskanaEngineImplMock, sqlSessionMock);
|
||||
verify(taskanaEngineImplMock, times(1)).getWorkbasketService();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||
|
||||
verifyNoMoreInteractions(summaryMapperMock, taskanaEngineImplMock, sqlSessionMock,
|
||||
workbasketServiceMock);
|
||||
assertThat(actualResultList, equalTo(expectedResultList));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTaskSummariesByWorkbasketIdGettingResults() {
|
||||
public void testGetTaskSummariesByWorkbasketIdGettingResults() throws WorkbasketNotFoundException {
|
||||
String workbasketId = "1";
|
||||
List<TaskSummary> expectedResultList = Arrays.asList(new TaskSummary(), new TaskSummary());
|
||||
doNothing().when(taskanaEngineImplMock).openConnection();
|
||||
doNothing().when(taskanaEngineImplMock).returnConnection();
|
||||
doReturn(workbasketServiceMock).when(taskanaEngineImplMock).getWorkbasketService();
|
||||
doReturn(new Workbasket()).when(workbasketServiceMock).getWorkbasket(any());
|
||||
doReturn(expectedResultList).when(summaryMapperMock).findTasksummariesByWorkbasketId(workbasketId);
|
||||
|
||||
List<TaskSummary> actualResultList = cut.getTaskSummariesByWorkbasketId(workbasketId);
|
||||
|
||||
verify(taskanaEngineImplMock, times(1)).getWorkbasketService();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||
verify(taskanaEngineImplMock, times(1)).openConnection();
|
||||
verify(summaryMapperMock, times(1)).findTasksummariesByWorkbasketId(workbasketId);
|
||||
verify(taskanaEngineImplMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(summaryMapperMock, taskanaEngineImplMock, sqlSessionMock);
|
||||
verifyNoMoreInteractions(summaryMapperMock, taskanaEngineImplMock, sqlSessionMock, workbasketServiceMock);
|
||||
assertThat(actualResultList, equalTo(expectedResultList));
|
||||
assertThat(actualResultList.size(), equalTo(expectedResultList.size()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTaskSummariesByWorkbasketIdGettingNull() {
|
||||
public void testGetTaskSummariesByWorkbasketIdGettingNull() throws WorkbasketNotFoundException {
|
||||
String workbasketId = "1";
|
||||
List<TaskSummary> expectedResultList = new ArrayList<>();
|
||||
doNothing().when(taskanaEngineImplMock).openConnection();
|
||||
doNothing().when(taskanaEngineImplMock).returnConnection();
|
||||
doReturn(null).when(summaryMapperMock).findTasksummariesByWorkbasketId(workbasketId);
|
||||
doReturn(workbasketServiceMock).when(taskanaEngineImplMock).getWorkbasketService();
|
||||
doReturn(new Workbasket()).when(workbasketServiceMock).getWorkbasket(any());
|
||||
|
||||
List<TaskSummary> actualResultList = cut.getTaskSummariesByWorkbasketId(workbasketId);
|
||||
|
||||
verify(taskanaEngineImplMock, times(1)).openConnection();
|
||||
verify(summaryMapperMock, times(1)).findTasksummariesByWorkbasketId(workbasketId);
|
||||
verify(taskanaEngineImplMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(summaryMapperMock, taskanaEngineImplMock, sqlSessionMock);
|
||||
verify(taskanaEngineImplMock, times(1)).getWorkbasketService();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||
verifyNoMoreInteractions(summaryMapperMock, taskanaEngineImplMock, sqlSessionMock,
|
||||
workbasketServiceMock);
|
||||
|
||||
assertThat(actualResultList, equalTo(expectedResultList));
|
||||
assertThat(actualResultList.size(), equalTo(expectedResultList.size()));
|
||||
}
|
||||
|
|
|
@ -80,19 +80,25 @@ public class TaskServiceImplTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateSimpleTask() throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
public void testCreateSimpleTask() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
Mockito.doNothing().when(taskMapperMock).insert(any());
|
||||
Task expectedTask = createUnitTestTask("1", "DUMMYTASK", "1");
|
||||
|
||||
Task actualTask = cut.create(expectedTask);
|
||||
Task actualTask = cut.createTask(expectedTask);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
||||
verify(taskanaEngineMock, times(2)).getWorkbasketService();
|
||||
verify(taskanaEngineMock, times(1)).getClassificationService();
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(classificationServiceMock, times(1)).addClassification(any());
|
||||
verify(classificationServiceMock, times(1)).getClassification(any(), any());
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
|
||||
assertNull(actualTask.getOwner());
|
||||
assertNotNull(actualTask.getCreated());
|
||||
assertNotNull(actualTask.getModified());
|
||||
|
@ -103,7 +109,7 @@ public class TaskServiceImplTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateSimpleTaskWithObjectReference() throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
public void testCreateSimpleTaskWithObjectReference() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
ObjectReference expectedObjectReference = new ObjectReference();
|
||||
expectedObjectReference.setId("1");
|
||||
expectedObjectReference.setType("DUMMY");
|
||||
|
@ -114,16 +120,22 @@ public class TaskServiceImplTest {
|
|||
Mockito.doNothing().when(taskMapperMock).insert(any());
|
||||
Mockito.doReturn(expectedObjectReference).when(objectReferenceMapperMock).findByObjectReference(any());
|
||||
|
||||
Task actualTask = cut.create(expectedTask);
|
||||
Task actualTask = cut.createTask(expectedTask);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
||||
verify(taskanaEngineMock, times(2)).getWorkbasketService();
|
||||
verify(taskanaEngineMock, times(1)).getClassificationService();
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||
verify(objectReferenceMapperMock, times(1)).findByObjectReference(any());
|
||||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(classificationServiceMock, times(1)).addClassification(any());
|
||||
verify(classificationServiceMock, times(1)).getClassification(any(),
|
||||
any());
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
|
||||
assertNull(actualTask.getOwner());
|
||||
assertNotNull(actualTask.getCreated());
|
||||
|
@ -136,7 +148,7 @@ public class TaskServiceImplTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateSimpleTaskWithObjectReferenceIsNull() throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
public void testCreateSimpleTaskWithObjectReferenceIsNull() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
ObjectReference expectedObjectReference = new ObjectReference();
|
||||
expectedObjectReference.setId("1");
|
||||
expectedObjectReference.setType("DUMMY");
|
||||
|
@ -148,18 +160,23 @@ public class TaskServiceImplTest {
|
|||
Mockito.doNothing().when(objectReferenceMapperMock).insert(any());
|
||||
Mockito.doReturn(null).when(objectReferenceMapperMock).findByObjectReference(any());
|
||||
|
||||
Task actualTask = cut.create(expectedTask);
|
||||
Task actualTask = cut.createTask(expectedTask);
|
||||
expectedTask.getPrimaryObjRef().setId(actualTask.getPrimaryObjRef().getId()); // get only new ID
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
||||
verify(taskanaEngineMock, times(2)).getWorkbasketService();
|
||||
verify(taskanaEngineMock, times(1)).getClassificationService();
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||
verify(classificationServiceMock, times(1)).addClassification(any());
|
||||
verify(classificationServiceMock, times(1)).getClassification(any(), any());
|
||||
verify(objectReferenceMapperMock, times(1)).findByObjectReference(any());
|
||||
verify(objectReferenceMapperMock, times(1)).insert(any());
|
||||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
|
||||
assertNull(actualTask.getOwner());
|
||||
assertNotNull(actualTask.getCreated());
|
||||
|
@ -172,7 +189,7 @@ public class TaskServiceImplTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateManualTask() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
public void testCreateTaskWithPlanned() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
ObjectReference expectedObjectReference = new ObjectReference();
|
||||
expectedObjectReference.setId("1");
|
||||
expectedObjectReference.setType("DUMMY");
|
||||
|
@ -185,40 +202,55 @@ public class TaskServiceImplTest {
|
|||
Mockito.doNothing().when(taskMapperMock).insert(any());
|
||||
Mockito.doNothing().when(objectReferenceMapperMock).insert(any());
|
||||
|
||||
Task manualTask = cut.createManualTask("workbasketId", "classification", "domain", null, null, "simply awesome task", expectedObjectReference, null);
|
||||
Task test = new Task();
|
||||
test.setWorkbasketId("workbasketId");
|
||||
test.setClassification(classification);
|
||||
test.setPrimaryObjRef(expectedObjectReference);
|
||||
test.setDescription("simply awesome task");
|
||||
|
||||
Task manualTask2 = cut.createManualTask("workbasketId", "classification", "domain", Timestamp.valueOf(LocalDateTime.now().minusHours(1)), "Task2", "simply awesome task", expectedObjectReference, null);
|
||||
cut.createTask(test);
|
||||
|
||||
Task test2 = new Task();
|
||||
test2.setWorkbasketId("workbasketId");
|
||||
test2.setClassification(classification);
|
||||
test2.setPrimaryObjRef(expectedObjectReference);
|
||||
test2.setPlanned(Timestamp.valueOf(LocalDateTime.now().minusHours(1)));
|
||||
test2.setName("Task2");
|
||||
|
||||
cut.createTask(test2);
|
||||
|
||||
verify(taskanaEngineImpl, times(2)).openConnection();
|
||||
verify(taskanaEngineMock, times(2 + 2)).getWorkbasketService();
|
||||
verify(taskanaEngineMock, times(2)).getClassificationService();
|
||||
verify(workbasketServiceMock, times(2)).checkAuthorization(any(), any());
|
||||
verify(workbasketServiceMock, times(2)).getWorkbasket(any());
|
||||
verify(classificationServiceMock, times(2)).getClassification(any(), any());
|
||||
verify(objectReferenceMapperMock, times(2)).findByObjectReference(any());
|
||||
verify(objectReferenceMapperMock, times(2)).insert(any());
|
||||
verify(taskMapperMock, times(1)).insert(manualTask);
|
||||
verify(taskMapperMock, times(1)).insert(manualTask2);
|
||||
verify(taskMapperMock, times(1)).insert(test);
|
||||
verify(taskMapperMock, times(1)).insert(test2);
|
||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
|
||||
assertNull(manualTask.getOwner());
|
||||
assertNotNull(manualTask.getCreated());
|
||||
assertNotNull(manualTask.getModified());
|
||||
assertNull(manualTask.getCompleted());
|
||||
assertNull(manualTask.getDue());
|
||||
assertThat(manualTask.getWorkbasketId(), equalTo(manualTask2.getWorkbasketId()));
|
||||
assertThat(manualTask.getName(), equalTo(classification.getName()));
|
||||
assertThat(manualTask.getState(), equalTo(TaskState.READY));
|
||||
assertThat(manualTask.getPrimaryObjRef(), equalTo(expectedObjectReference));
|
||||
assertThat(manualTask.getName(), not(manualTask2.getName()));
|
||||
assertThat(manualTask.getPlanned(), not(manualTask2.getPlanned()));
|
||||
assertThat(manualTask2.getPlanned(), not(manualTask2.getCreated()));
|
||||
assertNull(test.getOwner());
|
||||
assertNotNull(test.getCreated());
|
||||
assertNotNull(test.getModified());
|
||||
assertNull(test.getCompleted());
|
||||
assertNull(test.getDue());
|
||||
assertThat(test.getWorkbasketId(), equalTo(test2.getWorkbasketId()));
|
||||
assertThat(test.getName(), equalTo(classification.getName()));
|
||||
assertThat(test.getState(), equalTo(TaskState.READY));
|
||||
assertThat(test.getPrimaryObjRef(), equalTo(expectedObjectReference));
|
||||
assertThat(test.getName(), not(test2.getName()));
|
||||
assertThat(test.getPlanned(), not(test2.getPlanned()));
|
||||
assertThat(test2.getPlanned(), not(test2.getCreated()));
|
||||
|
||||
}
|
||||
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testCreateThrowingAuthorizedOnWorkbasket() throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
public void testCreateThrowingAuthorizedOnWorkbasket() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
try {
|
||||
Mockito.doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(any(), any());
|
||||
Task task = new Task();
|
||||
|
@ -226,33 +258,36 @@ public class TaskServiceImplTest {
|
|||
task.setBusinessProcessId("BPI1");
|
||||
task.setParentBusinessProcessId("PBPI1");
|
||||
|
||||
cut.create(task);
|
||||
cut.createTask(task);
|
||||
} catch (Exception e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
||||
verify(taskanaEngineMock, times(2)).getWorkbasketService();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void testCreateThrowsWorkbasketNotFoundException() throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
public void testCreateThrowsWorkbasketNotFoundException() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
try {
|
||||
Mockito.doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock).checkAuthorization(any(), any());
|
||||
Mockito.doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock).getWorkbasket(any());
|
||||
Task task = new Task();
|
||||
task.setWorkbasketId("1");
|
||||
|
||||
cut.create(task);
|
||||
cut.createTask(task);
|
||||
} catch (Exception e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -614,6 +649,9 @@ public class TaskServiceImplTest {
|
|||
Timestamp now = new Timestamp(System.currentTimeMillis());
|
||||
task.setCreated(now);
|
||||
task.setModified(now);
|
||||
Classification classification = new Classification();
|
||||
classificationServiceMock.addClassification(classification);
|
||||
task.setClassification(classification);
|
||||
return task;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +1,15 @@
|
|||
package pro.taskana.impl.integration;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.h2.store.fs.FileUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.impl.ClassificationServiceImpl;
|
||||
import pro.taskana.impl.SummaryServiceImpl;
|
||||
import pro.taskana.impl.TaskServiceImpl;
|
||||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
import pro.taskana.impl.WorkbasketServiceImpl;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.impl.*;
|
||||
import pro.taskana.impl.configuration.DBCleaner;
|
||||
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
||||
import pro.taskana.model.Classification;
|
||||
|
@ -32,6 +17,16 @@ import pro.taskana.model.Task;
|
|||
import pro.taskana.model.TaskSummary;
|
||||
import pro.taskana.model.Workbasket;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
import javax.sql.DataSource;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* Testing {@link SummaryServiceImpl} with real DB-Connection and
|
||||
* real results.
|
||||
|
@ -95,22 +90,20 @@ public class SummaryServiceImplIntAutoCommitTest {
|
|||
assertThat(actualTaskSumamryResult.size(), equalTo(expectedTaskSumamries.size()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnEmptyTaskSummaryListByNullParameter() {
|
||||
List<TaskSummary> expectedTaskSumamries = new ArrayList<>();
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void shouldThrowWorkbasketNotFoundExceptionByNullParameter() throws WorkbasketNotFoundException {
|
||||
List<TaskSummary> actualTaskSumamryResult = summaryServiceImp.getTaskSummariesByWorkbasketId(null);
|
||||
assertThat(actualTaskSumamryResult, equalTo(expectedTaskSumamries));
|
||||
assertThat(actualTaskSumamryResult.size(), equalTo(expectedTaskSumamries.size()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnEmptyTaskSummaryListByNoResultFound() {
|
||||
List<TaskSummary> expectedTaskSumamries = new ArrayList<>();
|
||||
List<TaskSummary> actualTaskSumamryResult = summaryServiceImp.getTaskSummariesByWorkbasketId("123");
|
||||
assertThat(actualTaskSumamryResult, equalTo(expectedTaskSumamries));
|
||||
assertThat(actualTaskSumamryResult.size(), equalTo(expectedTaskSumamries.size()));
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void shouldThrowWorkbasketNotFoundExceptionByInvalidWorkbasketParameter() throws WorkbasketNotFoundException {
|
||||
Workbasket wb = new Workbasket();
|
||||
wb.setName("wb");
|
||||
workbasketServiceImpl.createWorkbasket(wb);
|
||||
List<TaskSummary> actualTaskSumamryResult = summaryServiceImp.getTaskSummariesByWorkbasketId("1");
|
||||
}
|
||||
|
||||
|
||||
private void generateDummyData() throws Exception {
|
||||
dummyWorkbasket = new Workbasket();
|
||||
dummyWorkbasket.setId("1");
|
||||
|
@ -127,7 +120,7 @@ public class SummaryServiceImplIntAutoCommitTest {
|
|||
dummyTask.setName("Dummy-Task");
|
||||
dummyTask.setClassification(dummyClassification);
|
||||
dummyTask.setWorkbasketId(dummyWorkbasket.getId());
|
||||
dummyTask = taskServiceImpl.create(dummyTask);
|
||||
dummyTask = taskServiceImpl.createTask(dummyTask);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
@ -1,24 +1,13 @@
|
|||
package pro.taskana.impl.integration;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.h2.store.fs.FileUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.junit.*;
|
||||
import pro.taskana.ClassificationQuery;
|
||||
import pro.taskana.ObjectReferenceQuery;
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
|
@ -28,9 +17,16 @@ import pro.taskana.impl.TaskServiceImpl;
|
|||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
import pro.taskana.impl.configuration.DBCleaner;
|
||||
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
||||
import pro.taskana.impl.util.IdGenerator;
|
||||
import pro.taskana.model.Classification;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.Workbasket;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
import javax.sql.DataSource;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Integration Test for TaskServiceImpl transactions with connection management mode AUTOCOMMIT.
|
||||
|
@ -66,12 +62,19 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
|
||||
@Test
|
||||
public void testStart() throws FileNotFoundException, SQLException, TaskNotFoundException,
|
||||
WorkbasketNotFoundException, NotAuthorizedException {
|
||||
WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException {
|
||||
Workbasket wb = new Workbasket();
|
||||
wb.setName("workbasket");
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
|
||||
Classification classification = new Classification();
|
||||
taskanaEngine.getClassificationService().addClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
task.setName("Unit Test Task");
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
task.setWorkbasketId(id1);
|
||||
task = taskServiceImpl.create(task);
|
||||
task.setWorkbasketId(wb.getId());
|
||||
task.setClassification(classification);
|
||||
|
||||
task = taskServiceImpl.createTask(task);
|
||||
//skanaEngineImpl.getSqlSession().commit(); // needed so that the change is visible in the other session
|
||||
|
||||
TaskanaEngine te2 = taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
|
@ -82,43 +85,61 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
|
||||
@Test(expected = TaskNotFoundException.class)
|
||||
public void testStartTransactionFail()
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException {
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
Workbasket wb = new Workbasket();
|
||||
wb.setName("sdf");
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
|
||||
Classification classification = new Classification();
|
||||
taskanaEngine.getClassificationService().addClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
task.setName("Unit Test Task");
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
task.setWorkbasketId("id1");
|
||||
task = taskServiceImpl.create(task);
|
||||
taskServiceImpl.getTaskById(id1);
|
||||
task.setWorkbasketId(wb.getId());
|
||||
task.setClassification(classification);
|
||||
taskServiceImpl.createTask(task);
|
||||
taskServiceImpl.getTaskById(task.getId());
|
||||
|
||||
TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
|
||||
taskServiceImpl2.getTaskById(id1);
|
||||
taskServiceImpl2.getTaskById(wb.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateTaskInTaskanaWithDefaultDb()
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException {
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(null, false, false);
|
||||
TaskanaEngine te = taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
TaskServiceImpl taskServiceImpl = (TaskServiceImpl) te.getTaskService();
|
||||
|
||||
Workbasket wb = new Workbasket();
|
||||
wb.setName("workbasket");
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
|
||||
Classification classification = new Classification();
|
||||
taskanaEngine.getClassificationService().addClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
task.setName("Unit Test Task");
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
task.setWorkbasketId(id1);
|
||||
task = taskServiceImpl.create(task);
|
||||
task.setWorkbasketId(wb.getId());
|
||||
task.setClassification(classification);
|
||||
task = taskServiceImpl.createTask(task);
|
||||
|
||||
Assert.assertNotNull(task);
|
||||
Assert.assertNotNull(task.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException, WorkbasketNotFoundException {
|
||||
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
Workbasket wb = new Workbasket();
|
||||
wb.setName("workbasket");
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
|
||||
Classification classification = new Classification();
|
||||
taskanaEngine.getClassificationService().addClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
task.setName("Unit Test Task");
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
task.setWorkbasketId(id1);
|
||||
task = taskServiceImpl.create(task);
|
||||
task.setWorkbasketId(wb.getId());
|
||||
task.setClassification(classification);
|
||||
taskServiceImpl.createTask(task);
|
||||
|
||||
TaskanaEngineImpl taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
|
||||
ClassificationQuery classificationQuery = new ClassificationQueryImpl(taskanaEngineImpl)
|
||||
|
|
|
@ -10,9 +10,7 @@ import java.sql.SQLException;
|
|||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.security.auth.Subject;
|
||||
import javax.security.auth.login.LoginException;
|
||||
|
@ -36,13 +34,9 @@ import pro.taskana.exceptions.ClassificationNotFoundException;
|
|||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.impl.ClassificationQueryImpl;
|
||||
import pro.taskana.impl.ObjectReferenceQueryImpl;
|
||||
import pro.taskana.impl.TaskServiceImpl;
|
||||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
import pro.taskana.impl.*;
|
||||
import pro.taskana.impl.configuration.DBCleaner;
|
||||
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
||||
import pro.taskana.impl.util.IdGenerator;
|
||||
import pro.taskana.model.Classification;
|
||||
import pro.taskana.model.ObjectReference;
|
||||
import pro.taskana.model.Task;
|
||||
|
@ -106,7 +100,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
try {
|
||||
Subject.doAs(subject, new PrivilegedExceptionAction<Object>() {
|
||||
@Override
|
||||
public Object run() throws TaskNotFoundException, WorkbasketNotFoundException, FileNotFoundException, NotAuthorizedException, SQLException {
|
||||
public Object run() throws TaskNotFoundException, WorkbasketNotFoundException, FileNotFoundException, NotAuthorizedException, SQLException, ClassificationNotFoundException {
|
||||
do_testTaskService();
|
||||
return null;
|
||||
}
|
||||
|
@ -116,13 +110,12 @@ public class TaskServiceImplIntExplicitTest {
|
|||
}
|
||||
}
|
||||
|
||||
public void do_testTaskService() throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException {
|
||||
public void do_testTaskService() throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
Task task = new Task();
|
||||
task.setName("Unit Test Task");
|
||||
task.setWorkbasketId("1");
|
||||
task = taskServiceImpl.create(task);
|
||||
|
||||
Task task = this.generateDummyTask();
|
||||
task = taskServiceImpl.createTask(task);
|
||||
connection.commit(); // needed so that the change is visible in the other session
|
||||
|
||||
TaskanaEngine te2 = taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
|
@ -136,7 +129,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
public void testStartTransactionFail() throws TaskNotFoundException {
|
||||
try {
|
||||
Subject.doAs(subject, new PrivilegedExceptionAction<Object>() {
|
||||
public Object run() throws TaskNotFoundException, FileNotFoundException, NotAuthorizedException, SQLException, WorkbasketNotFoundException {
|
||||
public Object run() throws TaskNotFoundException, FileNotFoundException, NotAuthorizedException, SQLException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
do_testStartTransactionFail();
|
||||
return null;
|
||||
}
|
||||
|
@ -151,22 +144,28 @@ public class TaskServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
public void do_testStartTransactionFail()
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException {
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
// taskServiceImpl = (TaskServiceImpl) taskanaEngine.getTaskService();
|
||||
|
||||
Workbasket workbasket = new Workbasket();
|
||||
workbasket.setName("workbasket");
|
||||
Classification classification = new Classification();
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(workbasket);
|
||||
taskanaEngine.getClassificationService().addClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
task.setName("Unit Test Task");
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
task.setWorkbasketId("1");
|
||||
task = taskServiceImpl.create(task);
|
||||
task.setWorkbasketId(workbasket.getId());
|
||||
task.setClassification(classification);
|
||||
task = taskServiceImpl.createTask(task);
|
||||
connection.commit();
|
||||
taskServiceImpl.getTaskById(id1);
|
||||
taskServiceImpl.getTaskById(workbasket.getId());
|
||||
|
||||
TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
|
||||
taskServiceImpl2.getTaskById(id1);
|
||||
taskServiceImpl2.getTaskById(workbasket.getId());
|
||||
connection.commit();
|
||||
}
|
||||
|
||||
|
@ -175,7 +174,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
try {
|
||||
Subject.doAs(subject, new PrivilegedExceptionAction<Object>() {
|
||||
@Override
|
||||
public Object run() throws TaskNotFoundException, WorkbasketNotFoundException, FileNotFoundException, NotAuthorizedException, SQLException {
|
||||
public Object run() throws TaskNotFoundException, WorkbasketNotFoundException, FileNotFoundException, NotAuthorizedException, SQLException, ClassificationNotFoundException {
|
||||
do_testCreateTaskInTaskanaWithDefaultDb();
|
||||
return null;
|
||||
}
|
||||
|
@ -186,18 +185,27 @@ public class TaskServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
public void do_testCreateTaskInTaskanaWithDefaultDb()
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException {
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
DataSource ds = TaskanaEngineConfiguration.createDefaultDataSource();
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(ds, false, false);
|
||||
TaskanaEngine te = taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
Connection connection = ds.getConnection();
|
||||
te.setConnection(connection);
|
||||
TaskServiceImpl taskServiceImpl = (TaskServiceImpl) te.getTaskService();
|
||||
WorkbasketServiceImpl workbasketServiceImpl = (WorkbasketServiceImpl) te.getWorkbasketService();
|
||||
ClassificationServiceImpl classificationServiceImpl = (ClassificationServiceImpl) te.getClassificationService();
|
||||
|
||||
Workbasket workbasket = new Workbasket();
|
||||
workbasket.setName("workbasket");
|
||||
Classification classification = new Classification();
|
||||
workbasketServiceImpl.createWorkbasket(workbasket);
|
||||
classificationServiceImpl.addClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
task.setName("Unit Test Task");
|
||||
task.setWorkbasketId("1");
|
||||
task = taskServiceImpl.create(task);
|
||||
task.setWorkbasketId(workbasket.getId());
|
||||
task.setClassification(classification);
|
||||
task = taskServiceImpl.createTask(task);
|
||||
|
||||
Assert.assertNotNull(task);
|
||||
Assert.assertNotNull(task.getId());
|
||||
|
@ -206,12 +214,12 @@ public class TaskServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateManualTask() throws Throwable {
|
||||
public void testCreateTaskWithPlannedAndName() throws Throwable {
|
||||
try {
|
||||
Subject.doAs(subject, new PrivilegedExceptionAction<Object>() {
|
||||
@Override
|
||||
public Object run() throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException, SQLException {
|
||||
do_testCreateManualTask();
|
||||
do_testCreateTaskWithPlannedAndName();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
@ -220,17 +228,11 @@ public class TaskServiceImplIntExplicitTest {
|
|||
}
|
||||
}
|
||||
|
||||
public void do_testCreateManualTask() throws SQLException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
public void do_testCreateTaskWithPlannedAndName() throws SQLException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
Workbasket workbasket = new Workbasket();
|
||||
workbasket.setName("workbasket1");
|
||||
workbasket.setId("1");
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(workbasket);
|
||||
|
||||
Classification classification = new Classification();
|
||||
classification.setDomain("domain");
|
||||
classification.setCategory("MANUAL");
|
||||
classification.setName("classification name");
|
||||
classification.setServiceLevel("P1D");
|
||||
|
@ -243,28 +245,39 @@ public class TaskServiceImplIntExplicitTest {
|
|||
objectReference.setValue("4444");
|
||||
objectReference.setType("type");
|
||||
|
||||
Task test = taskServiceImpl.createManualTask(workbasket.getId(), classification.getId(), "domain", null, "Name", null, objectReference, null);
|
||||
Timestamp tomorrow = Timestamp.valueOf(LocalDateTime.now().plusDays(1));
|
||||
|
||||
Assert.assertEquals(test.getPlanned(), test.getCreated());
|
||||
Task test = this.generateDummyTask();
|
||||
test.setClassification(classification);
|
||||
test.setName("Name");
|
||||
test.setPrimaryObjRef(objectReference);
|
||||
test.setPlanned(tomorrow);
|
||||
test = taskServiceImpl.createTask(test);
|
||||
|
||||
Assert.assertNotEquals(test.getPlanned(), test.getCreated());
|
||||
Assert.assertNotNull(test.getDue());
|
||||
|
||||
Timestamp tomorrow = Timestamp.valueOf(LocalDateTime.now().plusDays(1));
|
||||
Map<String, Object> customs = new HashMap<String, Object>();
|
||||
customs.put("Daimler", "Tons of money. And cars. And gold.");
|
||||
customs.put("Audi", 2);
|
||||
Task test2 = new Task();
|
||||
test2.setWorkbasketId(test.getWorkbasketId());
|
||||
test2.setClassification(classification);
|
||||
test2.setPrimaryObjRef(objectReference);
|
||||
test2.setDescription("desc");
|
||||
taskServiceImpl.createTask(test2);
|
||||
|
||||
Task test2 = taskServiceImpl.createManualTask(workbasket.getId(), classification.getId(), "domain", tomorrow, "Name2", "desc", objectReference, customs);
|
||||
Assert.assertEquals(test2.getPlanned(), test2.getCreated());
|
||||
Assert.assertTrue(test2.getName().equals(classification.getName()));
|
||||
|
||||
Assert.assertEquals(test.getClassification().getId(), test2.getClassification().getId());
|
||||
Assert.assertTrue(test.getDue().before(test2.getDue()));
|
||||
Assert.assertTrue(test.getDue().after(test2.getDue()));
|
||||
Assert.assertFalse(test.getName().equals(test2.getName()));
|
||||
}
|
||||
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void createManualTaskShouldThrowWorkbasketNotFoundException() throws WorkbasketNotFoundException {
|
||||
public void createTaskShouldThrowWorkbasketNotFoundException() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException {
|
||||
try {
|
||||
Subject.doAs(subject, new PrivilegedExceptionAction<Object>() {
|
||||
public Object run() throws NotAuthorizedException, SQLException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
do_createManualTaskShouldThrowWorkbasketNotFoundException();
|
||||
do_createTaskShouldThrowWorkbasketNotFoundException();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
@ -277,15 +290,13 @@ public class TaskServiceImplIntExplicitTest {
|
|||
}
|
||||
}
|
||||
|
||||
public void do_createManualTaskShouldThrowWorkbasketNotFoundException() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException {
|
||||
public void do_createTaskShouldThrowWorkbasketNotFoundException() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
Workbasket workbasket = new Workbasket();
|
||||
workbasket.setName("wb");
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(workbasket);
|
||||
|
||||
taskServiceImpl.createManualTask("1", "classification", "domain", null, null, null, null, null);
|
||||
Task test = this.generateDummyTask();
|
||||
test.setWorkbasketId("1");
|
||||
taskServiceImpl.createTask(test);
|
||||
}
|
||||
|
||||
@Test(expected = ClassificationNotFoundException.class)
|
||||
|
@ -310,30 +321,9 @@ public class TaskServiceImplIntExplicitTest {
|
|||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
Workbasket workbasket = new Workbasket();
|
||||
workbasket.setName("wb");
|
||||
workbasket.setId("1");
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(workbasket);
|
||||
|
||||
Classification classification = new Classification();
|
||||
taskanaEngine.getClassificationService().addClassification(classification);
|
||||
|
||||
taskServiceImpl.createManualTask(workbasket.getId(), "classification", "domain", null, null, null, null, null);
|
||||
}
|
||||
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void createManualTaskShouldThrowNotAuthorizedException() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
Workbasket workbasket = new Workbasket();
|
||||
workbasket.setName("wb");
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(workbasket);
|
||||
|
||||
Classification classification = new Classification();
|
||||
taskanaEngine.getClassificationService().addClassification(classification);
|
||||
|
||||
taskServiceImpl.createManualTask(workbasket.getId(), classification.getId(), "domain", null, null, null, null, null);
|
||||
Task test = this.generateDummyTask();
|
||||
test.setClassification(new Classification());
|
||||
taskServiceImpl.createTask(test);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -341,7 +331,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
try {
|
||||
Subject.doAs(subject, new PrivilegedExceptionAction<Object>() {
|
||||
@Override
|
||||
public Object run() throws WorkbasketNotFoundException, NotAuthorizedException, SQLException {
|
||||
public Object run() throws WorkbasketNotFoundException, NotAuthorizedException, SQLException, ClassificationNotFoundException {
|
||||
do_should_ReturnList_when_BuilderIsUsed();
|
||||
return null;
|
||||
}
|
||||
|
@ -351,20 +341,27 @@ public class TaskServiceImplIntExplicitTest {
|
|||
}
|
||||
}
|
||||
|
||||
public void do_should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException, WorkbasketNotFoundException {
|
||||
public void do_should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
Workbasket workbasket = new Workbasket();
|
||||
workbasket.setName("workbasket");
|
||||
Classification classification = new Classification();
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(workbasket);
|
||||
taskanaEngine.getClassificationService().addClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
task.setName("Unit Test Task");
|
||||
task.setWorkbasketId("1");
|
||||
task = taskServiceImpl.create(task);
|
||||
task.setWorkbasketId(workbasket.getId());
|
||||
task.setClassification(classification);
|
||||
task = taskServiceImpl.createTask(task);
|
||||
|
||||
Task task2 = new Task();
|
||||
task2.setName("Unit Test Task");
|
||||
task2.setWorkbasketId("2");
|
||||
task2 = taskServiceImpl.create(task2);
|
||||
task2 = taskServiceImpl.createTask(task2);
|
||||
|
||||
TaskanaEngineImpl taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
|
||||
ClassificationQuery classificationQuery = new ClassificationQueryImpl(taskanaEngineImpl)
|
||||
|
@ -384,6 +381,20 @@ public class TaskServiceImplIntExplicitTest {
|
|||
connection.commit();
|
||||
}
|
||||
|
||||
private Task generateDummyTask() {
|
||||
Workbasket workbasket = new Workbasket();
|
||||
workbasket.setName("wb");
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(workbasket);
|
||||
|
||||
Classification classification = new Classification();
|
||||
taskanaEngine.getClassificationService().addClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
task.setWorkbasketId(workbasket.getId());
|
||||
task.setClassification(classification);
|
||||
return task;
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanUp() {
|
||||
taskanaEngineImpl.setConnection(null);
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
package pro.taskana;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.Task;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Component
|
||||
@Transactional
|
||||
public class ExampleBootstrap {
|
||||
|
@ -18,12 +19,12 @@ public class ExampleBootstrap {
|
|||
private TaskService taskService;
|
||||
|
||||
@PostConstruct
|
||||
public void test() throws TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException {
|
||||
public void test() throws TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
System.out.println("---------------------------> Start App");
|
||||
Task task = new Task();
|
||||
task.setName("Spring example task");
|
||||
task.setWorkbasketId("1");
|
||||
task = taskService.create(task);
|
||||
task = taskService.createTask(task);
|
||||
System.out.println("---------------------------> Task started: " + task.getId());
|
||||
taskService.claim(task.getId(), "John Doe");
|
||||
System.out.println(
|
||||
|
|
|
@ -3,8 +3,10 @@ package pro.taskana;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.Classification;
|
||||
import pro.taskana.model.Task;
|
||||
|
||||
@Component
|
||||
|
@ -18,11 +20,11 @@ public class TaskanaComponent {
|
|||
return taskService;
|
||||
}
|
||||
|
||||
public void triggerRollback() throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
public void triggerRollback() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
Task task = new Task();
|
||||
task.setName("Unit Test Task");
|
||||
task.setWorkbasketId("1");
|
||||
task = taskService.create(task);
|
||||
task = taskService.createTask(task);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public class TaskController {
|
|||
@RequestMapping(method = RequestMethod.POST)
|
||||
public ResponseEntity<Task> createTask(@RequestBody Task task) {
|
||||
try {
|
||||
Task createdTask = taskService.create(task);
|
||||
Task createdTask = taskService.createTask(task);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdTask);
|
||||
} catch (Exception e) {
|
||||
logger.error("Something went wrong: ", e);
|
||||
|
|
Loading…
Reference in New Issue