TSK-22_start_working_on_a_task
This commit is contained in:
parent
4d94684bf0
commit
600c4aa281
|
@ -32,7 +32,7 @@ public class TaskanaProducersTest {
|
||||||
deployment.addAllDependencies();
|
deployment.addAllDependencies();
|
||||||
deployment.addDependency("org.mybatis:mybatis:3.4.2");
|
deployment.addDependency("org.mybatis:mybatis:3.4.2");
|
||||||
deployment.addDependency("org.mybatis:mybatis-cdi:1.0.0");
|
deployment.addDependency("org.mybatis:mybatis-cdi:1.0.0");
|
||||||
deployment.addDependency("pro.taskana:taskana-core:0.0.1-SNAPSHOT");
|
deployment.addDependency("pro.taskana:taskana-core:0.0.3-SNAPSHOT");
|
||||||
deployment.addAsResource("META-INF/beans.xml");
|
deployment.addAsResource("META-INF/beans.xml");
|
||||||
deployment.addAsResource("taskana.properties");
|
deployment.addAsResource("taskana.properties");
|
||||||
deployment.addAsResource("project-defaults.yml");
|
deployment.addAsResource("project-defaults.yml");
|
||||||
|
@ -68,7 +68,6 @@ public class TaskanaProducersTest {
|
||||||
Assert.assertEquals(1, resultCount);
|
Assert.assertEquals(1, resultCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRollback() throws SQLException, ClassNotFoundException, NamingException {
|
public void testRollback() throws SQLException, ClassNotFoundException, NamingException {
|
||||||
Client client = ClientBuilder.newClient();
|
Client client = ClientBuilder.newClient();
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<powermock.version>1.7.1</powermock.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
@ -141,6 +142,18 @@
|
||||||
<version>2.8.47</version>
|
<version>2.8.47</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.powermock</groupId>
|
||||||
|
<artifactId>powermock-module-junit4</artifactId>
|
||||||
|
<version>${powermock.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.powermock</groupId>
|
||||||
|
<artifactId>powermock-api-mockito2</artifactId>
|
||||||
|
<version>${powermock.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package pro.taskana;
|
package pro.taskana;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||||
import pro.taskana.exceptions.InvalidOwnerException;
|
import pro.taskana.exceptions.InvalidOwnerException;
|
||||||
import pro.taskana.exceptions.InvalidStateException;
|
import pro.taskana.exceptions.InvalidStateException;
|
||||||
|
@ -12,8 +14,6 @@ import pro.taskana.model.TaskState;
|
||||||
import pro.taskana.model.TaskStateCounter;
|
import pro.taskana.model.TaskStateCounter;
|
||||||
import pro.taskana.model.TaskSummary;
|
import pro.taskana.model.TaskSummary;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Task Service manages all operations on tasks.
|
* The Task Service manages all operations on tasks.
|
||||||
*/
|
*/
|
||||||
|
@ -21,102 +21,146 @@ public interface TaskService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Claim an existing task for the current user.
|
* Claim an existing task for the current user.
|
||||||
* @param id
|
*
|
||||||
* task id
|
* @param taskId
|
||||||
* @return modified claimed Task
|
* the id of the task to be claimed
|
||||||
* @throws TaskNotFoundException if the task with id was not found
|
* @return claimed Task
|
||||||
* @throws InvalidStateException if the task state is not ready
|
* @throws TaskNotFoundException
|
||||||
* @throws InvalidOwnerException if the task is claimed by another user
|
* if the task with taskId was not found
|
||||||
|
* @throws InvalidStateException
|
||||||
|
* if the state of the task with taskId is not {@link TaskState#READY}
|
||||||
|
* @throws InvalidOwnerException
|
||||||
|
* if the task with taskId is claimed by some else
|
||||||
*/
|
*/
|
||||||
Task claim(String id) throws TaskNotFoundException, InvalidStateException, InvalidOwnerException;
|
Task claim(String taskId) throws TaskNotFoundException, InvalidStateException, InvalidOwnerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Claim an existing task for the current user.
|
* Claim an existing task for the current user. Enable forced claim.
|
||||||
* @param id
|
*
|
||||||
* task id
|
* @param taskId
|
||||||
|
* the id of the task to be claimed
|
||||||
* @param forceClaim
|
* @param forceClaim
|
||||||
* if true, claim is performed even if the task is already claimed by someone else
|
* if true, claim is performed even if the task is already claimed by someone else
|
||||||
* @return modified claimed Task
|
* @return claimed Task
|
||||||
* @throws TaskNotFoundException if the task with id was not found
|
* @throws TaskNotFoundException
|
||||||
* @throws InvalidStateException if the task state is not ready
|
* if the task with taskId was not found
|
||||||
* @throws InvalidOwnerException if the task is claimed by another user
|
* @throws InvalidStateException
|
||||||
|
* if the state of the task with taskId is not {@link TaskState#READY}
|
||||||
|
* @throws InvalidOwnerException
|
||||||
|
* if the task with taskId is claimed by someone else
|
||||||
*/
|
*/
|
||||||
Task claim(String id, boolean forceClaim) throws TaskNotFoundException, InvalidStateException, InvalidOwnerException;
|
Task claim(String taskId, boolean forceClaim)
|
||||||
|
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set task to completed.
|
* Set task to completed.
|
||||||
|
*
|
||||||
* @param taskId
|
* @param taskId
|
||||||
* the task id
|
* the task id
|
||||||
* @return changed Task after update.
|
* @return changed Task after update.
|
||||||
* @throws TaskNotFoundException TODO
|
* @throws TaskNotFoundException
|
||||||
|
* thrown if the task with taskId is not found.
|
||||||
*/
|
*/
|
||||||
Task complete(String taskId) throws TaskNotFoundException;
|
Task complete(String taskId) throws TaskNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a task by a task object.
|
* Create and persist a task.
|
||||||
* @param task TODO
|
*
|
||||||
* @return the created task
|
* @param task
|
||||||
* @throws NotAuthorizedException TODO
|
* the transient task object to be persisted
|
||||||
* @throws WorkbasketNotFoundException TODO
|
* @return the created and persisted task
|
||||||
* @throws ClassificationNotFoundException TODO
|
* @throws NotAuthorizedException
|
||||||
|
* thrown if the current user is not authorized to create that task
|
||||||
|
* @throws WorkbasketNotFoundException
|
||||||
|
* thrown if the work basket referenced by the task is not found
|
||||||
|
* @throws ClassificationNotFoundException
|
||||||
|
* thrown if the {@link Classification} referenced by the task is not found
|
||||||
*/
|
*/
|
||||||
Task createTask(Task task) throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException;
|
Task createTask(Task task)
|
||||||
|
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the details of a task.
|
* Get the details of a task by Id.
|
||||||
|
*
|
||||||
* @param taskId
|
* @param taskId
|
||||||
* the id of the task
|
* the id of the task
|
||||||
* @return the Task
|
* @return the Task
|
||||||
* @throws TaskNotFoundException TODO
|
* @throws TaskNotFoundException
|
||||||
|
* thrown of the {@link Task} with taskId is not found
|
||||||
*/
|
*/
|
||||||
Task getTaskById(String taskId) throws TaskNotFoundException;
|
Task getTaskById(String taskId) throws TaskNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method counts all tasks with a given state.
|
* This method counts all tasks with a given state.
|
||||||
|
*
|
||||||
* @param states
|
* @param states
|
||||||
* the countable states
|
* the countable states
|
||||||
* @return a List of {@link TaskStateCounter}
|
* @return a List of {@link TaskStateCounter} objects that specifies how many tasks in the specified states exist in
|
||||||
|
* the available work baskets
|
||||||
*/
|
*/
|
||||||
List<TaskStateCounter> getTaskCountForState(List<TaskState> states);
|
List<TaskStateCounter> getTaskCountForState(List<TaskState> states);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count all Tasks in a given workbasket with daysInPast as Days from today in
|
* Count all Tasks in a given work basket where the due date is after "daysInPast" days from today in the past and
|
||||||
* the past and a specific state.
|
* the tasks are in specified states.
|
||||||
* @param workbasketId TODO
|
*
|
||||||
* @param daysInPast TODO
|
* @param workbasketId
|
||||||
* @param states TODO
|
* the id of the work basket
|
||||||
* @return TODO
|
* @param daysInPast
|
||||||
|
* identifies the days in the past from today
|
||||||
|
* @param states
|
||||||
|
* {@link List} of {@link TaskState} that identifies the states of the tasks to be searched for
|
||||||
|
* @return the number of {@link Task} objects in the given work basket that match the query parameters
|
||||||
*/
|
*/
|
||||||
long getTaskCountForWorkbasketByDaysInPastAndState(String workbasketId, long daysInPast, List<TaskState> states);
|
long getTaskCountForWorkbasketByDaysInPastAndState(String workbasketId, long daysInPast, List<TaskState> states);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count all Tasks for all work basket objects where the due date is after "daysInPast" days from today in the past
|
||||||
|
* and the tasks are in specified states.
|
||||||
|
*
|
||||||
|
* @param daysInPast
|
||||||
|
* identifies the days in the past from today
|
||||||
|
* @param states
|
||||||
|
* {@link List} of {@link TaskState} objects that identifies the states of the tasks searched
|
||||||
|
* @return a list of of {@link DueWorkbasketCounter} objects that specifies how many tasks in the requested states
|
||||||
|
* with appropriate due date exist in the various work baskets
|
||||||
|
*/
|
||||||
List<DueWorkbasketCounter> getTaskCountByWorkbasketAndDaysInPastAndState(long daysInPast, List<TaskState> states);
|
List<DueWorkbasketCounter> getTaskCountByWorkbasketAndDaysInPastAndState(long daysInPast, List<TaskState> states);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transfer task to another workbasket. The transfer set the transferred flag
|
* Transfer a task to another work basket. The transfer sets the transferred flag and resets the read flag.
|
||||||
* and resets the read flag.
|
*
|
||||||
* @param taskId TODO
|
* @param taskId
|
||||||
* @param workbasketId TODO
|
* The id of the {@link Task} to be transferred
|
||||||
* @return the updated task
|
* @param workbasketId
|
||||||
* @throws TaskNotFoundException TODO
|
* The id of the target work basket
|
||||||
* @throws WorkbasketNotFoundException TODO
|
* @return the transferred task
|
||||||
* @throws NotAuthorizedException TODO
|
* @throws TaskNotFoundException
|
||||||
|
* Thrown if the {@link Task} with taskId was not found.
|
||||||
|
* @throws WorkbasketNotFoundException
|
||||||
|
* Thrown if the target work basket was not found.
|
||||||
|
* @throws NotAuthorizedException
|
||||||
|
* Thrown if the current user is not authorized to transfer this {@link Task} to the target work basket
|
||||||
*/
|
*/
|
||||||
Task transfer(String taskId, String workbasketId)
|
Task transfer(String taskId, String workbasketId)
|
||||||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException;
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks a task as read.
|
* Marks a task as read.
|
||||||
|
*
|
||||||
* @param taskId
|
* @param taskId
|
||||||
* the id of the task to be updated
|
* the id of the task to be updated
|
||||||
* @param isRead
|
* @param isRead
|
||||||
* the new status of the read flag.
|
* the new status of the read flag.
|
||||||
* @return Task the updated Task
|
* @return the updated Task
|
||||||
* @throws TaskNotFoundException TODO
|
* @throws TaskNotFoundException
|
||||||
|
* Thrown if the {@link Task} with taskId was not found
|
||||||
*/
|
*/
|
||||||
Task setTaskRead(String taskId, boolean isRead) throws TaskNotFoundException;
|
Task setTaskRead(String taskId, boolean isRead) throws TaskNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method provides a query builder for quering the database.
|
* This method provides a query builder for quering the database.
|
||||||
|
*
|
||||||
* @return a {@link TaskQuery}
|
* @return a {@link TaskQuery}
|
||||||
*/
|
*/
|
||||||
TaskQuery createTaskQuery();
|
TaskQuery createTaskQuery();
|
||||||
|
@ -124,21 +168,27 @@ public interface TaskService {
|
||||||
/**
|
/**
|
||||||
* Getting a list of all Tasks which got matching workbasketIds and states.
|
* Getting a list of all Tasks which got matching workbasketIds and states.
|
||||||
*
|
*
|
||||||
* @param workbasketId where the tasks need to be in.
|
* @param workbasketId
|
||||||
* @param taskState which is required for the request,
|
* where the tasks need to be in.
|
||||||
|
* @param taskState
|
||||||
|
* which is required for the request,
|
||||||
* @return a filled/empty list of tasks with attributes which are matching given params.
|
* @return a filled/empty list of tasks with attributes which are matching given params.
|
||||||
*
|
* @throws WorkbasketNotFoundException
|
||||||
* @throws WorkbasketNotFoundException if the workbasketId can´t be resolved to a existing workbasket.
|
* if the workbasketId can´t be resolved to a existing work basket.
|
||||||
* @throws NotAuthorizedException if the current user got no rights for reading on this workbasket.
|
* @throws NotAuthorizedException
|
||||||
* @throws Exception if no result can be found by @{link TaskMapper}.
|
* if the current user got no rights for reading on this work basket.
|
||||||
*/
|
*/
|
||||||
List<Task> getTasksByWorkbasketIdAndState(String workbasketId, TaskState taskState) throws WorkbasketNotFoundException, NotAuthorizedException, Exception;
|
List<Task> getTasksByWorkbasketIdAndState(String workbasketId, TaskState taskState)
|
||||||
|
throws WorkbasketNotFoundException, NotAuthorizedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getting a short summary of all tasks in a specific workbasket.
|
* Getting a short summary of all tasks in a specific work basket.
|
||||||
* @param workbasketId ID of workbasket where tasks are located.
|
*
|
||||||
* @return TaskSummaryList with all TaskSummaries of a workbasket
|
* @param workbasketId
|
||||||
* @throws WorkbasketNotFoundException if a Workbasket can´t be located.
|
* ID of work basket where tasks are located.
|
||||||
|
* @return TaskSummaryList with all TaskSummaries of a work basket
|
||||||
|
* @throws WorkbasketNotFoundException
|
||||||
|
* if a Work basket can´t be located.
|
||||||
*/
|
*/
|
||||||
List<TaskSummary> getTaskSummariesByWorkbasketId(String workbasketId) throws WorkbasketNotFoundException;
|
List<TaskSummary> getTaskSummariesByWorkbasketId(String workbasketId) throws WorkbasketNotFoundException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,14 +42,20 @@ public class TaskServiceImpl implements TaskService {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskServiceImpl.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(TaskServiceImpl.class);
|
||||||
|
|
||||||
private static final String ID_PREFIX_OBJECTR_EFERENCE = "ORI";
|
private static final String ID_PREFIX_OBJECT_REFERENCE = "ORI";
|
||||||
|
|
||||||
private static final String ID_PREFIX_TASK = "TKI";
|
private static final String ID_PREFIX_TASK = "TKI";
|
||||||
|
|
||||||
private static final String ID_PREFIX_BUSINESS_PROCESS = "BPI";
|
private static final String ID_PREFIX_BUSINESS_PROCESS = "BPI";
|
||||||
|
|
||||||
private TaskanaEngine taskanaEngine;
|
private TaskanaEngine taskanaEngine;
|
||||||
|
|
||||||
private TaskanaEngineImpl taskanaEngineImpl;
|
private TaskanaEngineImpl taskanaEngineImpl;
|
||||||
|
|
||||||
private WorkbasketService workbasketService;
|
private WorkbasketService workbasketService;
|
||||||
|
|
||||||
private TaskMapper taskMapper;
|
private TaskMapper taskMapper;
|
||||||
|
|
||||||
private ObjectReferenceMapper objectReferenceMapper;
|
private ObjectReferenceMapper objectReferenceMapper;
|
||||||
|
|
||||||
public TaskServiceImpl(TaskanaEngine taskanaEngine, TaskMapper taskMapper,
|
public TaskServiceImpl(TaskanaEngine taskanaEngine, TaskMapper taskMapper,
|
||||||
|
@ -63,43 +69,39 @@ public class TaskServiceImpl implements TaskService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task claim(String id) throws TaskNotFoundException, InvalidStateException, InvalidOwnerException {
|
public Task claim(String taskId) throws TaskNotFoundException, InvalidStateException, InvalidOwnerException {
|
||||||
return claim(id, false);
|
return claim(taskId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task claim(String id, boolean forceClaim) throws TaskNotFoundException, InvalidStateException, InvalidOwnerException {
|
public Task claim(String taskId, boolean forceClaim)
|
||||||
String userName = CurrentUserContext.getUserid();
|
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException {
|
||||||
return claim(id, userName, forceClaim);
|
String userId = CurrentUserContext.getUserid();
|
||||||
}
|
LOGGER.debug("entry to claim(id = {}, forceClaim = {}, userId = {})", taskId, forceClaim, userId);
|
||||||
|
|
||||||
public Task claim(String id, String userName, boolean forceClaim) throws TaskNotFoundException, InvalidStateException, InvalidOwnerException {
|
|
||||||
LOGGER.debug("entry to claim(id = {}, userName = {})", id, userName);
|
|
||||||
Task task = null;
|
Task task = null;
|
||||||
try {
|
try {
|
||||||
taskanaEngineImpl.openConnection();
|
taskanaEngineImpl.openConnection();
|
||||||
task = taskMapper.findById(id);
|
task = getTaskById(taskId);
|
||||||
if (task == null) {
|
|
||||||
LOGGER.warn("Method claim() didn't find task with id {}. Throwing TaskNotFoundException", id);
|
|
||||||
throw new TaskNotFoundException(id);
|
|
||||||
}
|
|
||||||
TaskState state = task.getState();
|
TaskState state = task.getState();
|
||||||
if (state == TaskState.COMPLETED) {
|
if (state == TaskState.COMPLETED) {
|
||||||
LOGGER.warn("Method claim() found that task {} is already completed. Throwing InvalidStateException", id);
|
LOGGER.warn("Method claim() found that task {} is already completed. Throwing InvalidStateException",
|
||||||
|
taskId);
|
||||||
throw new InvalidStateException("Task is already completed");
|
throw new InvalidStateException("Task is already completed");
|
||||||
}
|
}
|
||||||
if (state == TaskState.CLAIMED && !forceClaim) {
|
if (state == TaskState.CLAIMED && !forceClaim) {
|
||||||
LOGGER.warn("Method claim() found that task {} is claimed by {} and forceClaim is false. Throwing InvalidOwnerException", id, task.getOwner());
|
LOGGER.warn(
|
||||||
|
"Method claim() found that task {} is claimed by {} and forceClaim is false. Throwing InvalidOwnerException",
|
||||||
|
taskId, task.getOwner());
|
||||||
throw new InvalidOwnerException("Task is already claimed by user " + task.getOwner());
|
throw new InvalidOwnerException("Task is already claimed by user " + task.getOwner());
|
||||||
}
|
}
|
||||||
Timestamp now = new Timestamp(System.currentTimeMillis());
|
Timestamp now = new Timestamp(System.currentTimeMillis());
|
||||||
task.setOwner(userName);
|
task.setOwner(userId);
|
||||||
task.setModified(now);
|
task.setModified(now);
|
||||||
task.setClaimed(now);
|
task.setClaimed(now);
|
||||||
task.setRead(true);
|
task.setRead(true);
|
||||||
task.setState(TaskState.CLAIMED);
|
task.setState(TaskState.CLAIMED);
|
||||||
taskMapper.update(task);
|
taskMapper.update(task);
|
||||||
LOGGER.debug("Method claim() claimed task '{}' for user '{}'.", id, userName);
|
LOGGER.debug("Method claim() claimed task '{}' for user '{}'.", taskId, userId);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
taskanaEngineImpl.returnConnection();
|
taskanaEngineImpl.returnConnection();
|
||||||
|
@ -134,12 +136,13 @@ public class TaskServiceImpl implements TaskService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task createTask(Task task) throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
public Task createTask(Task task)
|
||||||
|
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||||
LOGGER.debug("entry to createTask(task = {})", task);
|
LOGGER.debug("entry to createTask(task = {})", task);
|
||||||
try {
|
try {
|
||||||
taskanaEngineImpl.openConnection();
|
taskanaEngineImpl.openConnection();
|
||||||
taskanaEngine.getWorkbasketService().getWorkbasket(task.getWorkbasketId());
|
workbasketService.getWorkbasket(task.getWorkbasketId());
|
||||||
taskanaEngine.getWorkbasketService().checkAuthorization(task.getWorkbasketId(), WorkbasketAuthorization.APPEND);
|
workbasketService.checkAuthorization(task.getWorkbasketId(), WorkbasketAuthorization.APPEND);
|
||||||
Classification classification = task.getClassification();
|
Classification classification = task.getClassification();
|
||||||
if (classification == null) {
|
if (classification == null) {
|
||||||
throw new ClassificationNotFoundException(null);
|
throw new ClassificationNotFoundException(null);
|
||||||
|
@ -191,15 +194,18 @@ public class TaskServiceImpl implements TaskService {
|
||||||
taskanaEngineImpl.returnConnection();
|
taskanaEngineImpl.returnConnection();
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||||
LOGGER.debug("exit from getTaskCountForState(). Returning {} resulting Objects: {} ", numberOfResultObjects, LoggerUtils.listToString(result));
|
LOGGER.debug("exit from getTaskCountForState(). Returning {} resulting Objects: {} ",
|
||||||
|
numberOfResultObjects, LoggerUtils.listToString(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getTaskCountForWorkbasketByDaysInPastAndState(String workbasketId, long daysInPast, List<TaskState> states) {
|
public long getTaskCountForWorkbasketByDaysInPastAndState(String workbasketId, long daysInPast,
|
||||||
|
List<TaskState> states) {
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("entry to getTaskCountForWorkbasketByDaysInPastAndState(workbasketId {}, daysInPast={}, states = {})",
|
LOGGER.debug(
|
||||||
|
"entry to getTaskCountForWorkbasketByDaysInPastAndState(workbasketId {}, daysInPast={}, states = {})",
|
||||||
workbasketId, daysInPast, LoggerUtils.listToString(states));
|
workbasketId, daysInPast, LoggerUtils.listToString(states));
|
||||||
}
|
}
|
||||||
long result = -1;
|
long result = -1;
|
||||||
|
@ -226,13 +232,13 @@ public class TaskServiceImpl implements TaskService {
|
||||||
Task task = getTaskById(taskId);
|
Task task = getTaskById(taskId);
|
||||||
|
|
||||||
// transfer requires TRANSFER in source and APPEND on destination workbasket
|
// transfer requires TRANSFER in source and APPEND on destination workbasket
|
||||||
taskanaEngine.getWorkbasketService().checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
workbasketService.checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
||||||
taskanaEngine.getWorkbasketService().checkAuthorization(task.getWorkbasketId(), WorkbasketAuthorization.TRANSFER);
|
workbasketService.checkAuthorization(task.getWorkbasketId(), WorkbasketAuthorization.TRANSFER);
|
||||||
|
|
||||||
// if security is disabled, the implicit existance check on the
|
// if security is disabled, the implicit existance check on the
|
||||||
// destination workbasket has been skipped and needs to be performed
|
// destination workbasket has been skipped and needs to be performed
|
||||||
if (!taskanaEngine.getConfiguration().isSecurityEnabled()) {
|
if (!taskanaEngine.getConfiguration().isSecurityEnabled()) {
|
||||||
taskanaEngine.getWorkbasketService().getWorkbasket(destinationWorkbasketId);
|
workbasketService.getWorkbasket(destinationWorkbasketId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset read flag and set transferred flag
|
// reset read flag and set transferred flag
|
||||||
|
@ -245,7 +251,8 @@ public class TaskServiceImpl implements TaskService {
|
||||||
taskMapper.update(task);
|
taskMapper.update(task);
|
||||||
|
|
||||||
result = getTaskById(taskId);
|
result = getTaskById(taskId);
|
||||||
LOGGER.debug("Method transfer() transferred Task '{}' to destination workbasket {}", taskId, destinationWorkbasketId);
|
LOGGER.debug("Method transfer() transferred Task '{}' to destination workbasket {}", taskId,
|
||||||
|
destinationWorkbasketId);
|
||||||
return result;
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
taskanaEngineImpl.returnConnection();
|
taskanaEngineImpl.returnConnection();
|
||||||
|
@ -257,7 +264,8 @@ public class TaskServiceImpl implements TaskService {
|
||||||
public List<DueWorkbasketCounter> getTaskCountByWorkbasketAndDaysInPastAndState(long daysInPast,
|
public List<DueWorkbasketCounter> getTaskCountByWorkbasketAndDaysInPastAndState(long daysInPast,
|
||||||
List<TaskState> states) {
|
List<TaskState> states) {
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("entry to getTaskCountByWorkbasketAndDaysInPastAndState(daysInPast = {}, states = {})", daysInPast, LoggerUtils.listToString(states));
|
LOGGER.debug("entry to getTaskCountByWorkbasketAndDaysInPastAndState(daysInPast = {}, states = {})",
|
||||||
|
daysInPast, LoggerUtils.listToString(states));
|
||||||
}
|
}
|
||||||
List<DueWorkbasketCounter> result = null;
|
List<DueWorkbasketCounter> result = null;
|
||||||
try {
|
try {
|
||||||
|
@ -271,7 +279,8 @@ public class TaskServiceImpl implements TaskService {
|
||||||
taskanaEngineImpl.returnConnection();
|
taskanaEngineImpl.returnConnection();
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||||
LOGGER.debug("exit from getTaskCountByWorkbasketAndDaysInPastAndState(daysInPast,states). Returning {} resulting Objects: {} ",
|
LOGGER.debug(
|
||||||
|
"exit from getTaskCountByWorkbasketAndDaysInPastAndState(daysInPast,states). Returning {} resulting Objects: {} ",
|
||||||
numberOfResultObjects, LoggerUtils.listToString(result));
|
numberOfResultObjects, LoggerUtils.listToString(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,18 +311,21 @@ public class TaskServiceImpl implements TaskService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Task> getTasksByWorkbasketIdAndState(String workbasketId, TaskState taskState) throws WorkbasketNotFoundException, NotAuthorizedException, Exception {
|
public List<Task> getTasksByWorkbasketIdAndState(String workbasketId, TaskState taskState)
|
||||||
LOGGER.debug("entry to getTasksByWorkbasketIdAndState(workbasketId = {}, taskState = {})", workbasketId, taskState);
|
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||||
|
LOGGER.debug("entry to getTasksByWorkbasketIdAndState(workbasketId = {}, taskState = {})", workbasketId,
|
||||||
|
taskState);
|
||||||
List<Task> result = null;
|
List<Task> result = null;
|
||||||
try {
|
try {
|
||||||
taskanaEngineImpl.openConnection();
|
taskanaEngineImpl.openConnection();
|
||||||
taskanaEngine.getWorkbasketService().checkAuthorization(workbasketId, WorkbasketAuthorization.READ);
|
workbasketService.checkAuthorization(workbasketId, WorkbasketAuthorization.READ);
|
||||||
result = taskMapper.findTasksByWorkbasketIdAndState(workbasketId, taskState);
|
result = taskMapper.findTasksByWorkbasketIdAndState(workbasketId, taskState);
|
||||||
} finally {
|
} finally {
|
||||||
taskanaEngineImpl.returnConnection();
|
taskanaEngineImpl.returnConnection();
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||||
LOGGER.debug("exit from getTasksByWorkbasketIdAndState(workbasketId, taskState). Returning {} resulting Objects: {} ",
|
LOGGER.debug(
|
||||||
|
"exit from getTasksByWorkbasketIdAndState(workbasketId, taskState). Returning {} resulting Objects: {} ",
|
||||||
numberOfResultObjects, LoggerUtils.listToString(result));
|
numberOfResultObjects, LoggerUtils.listToString(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -365,7 +377,7 @@ public class TaskServiceImpl implements TaskService {
|
||||||
ObjectReference objectReference = this.objectReferenceMapper.findByObjectReference(task.getPrimaryObjRef());
|
ObjectReference objectReference = this.objectReferenceMapper.findByObjectReference(task.getPrimaryObjRef());
|
||||||
if (objectReference == null) {
|
if (objectReference == null) {
|
||||||
objectReference = task.getPrimaryObjRef();
|
objectReference = task.getPrimaryObjRef();
|
||||||
objectReference.setId(IdGenerator.generateWithPrefix(ID_PREFIX_OBJECTR_EFERENCE));
|
objectReference.setId(IdGenerator.generateWithPrefix(ID_PREFIX_OBJECT_REFERENCE));
|
||||||
this.objectReferenceMapper.insert(objectReference);
|
this.objectReferenceMapper.insert(objectReference);
|
||||||
}
|
}
|
||||||
task.setPrimaryObjRef(objectReference);
|
task.setPrimaryObjRef(objectReference);
|
||||||
|
@ -376,7 +388,7 @@ public class TaskServiceImpl implements TaskService {
|
||||||
public List<TaskSummary> getTaskSummariesByWorkbasketId(String workbasketId) throws WorkbasketNotFoundException {
|
public List<TaskSummary> getTaskSummariesByWorkbasketId(String workbasketId) throws WorkbasketNotFoundException {
|
||||||
LOGGER.debug("entry to getTaskSummariesByWorkbasketId(workbasketId = {}", workbasketId);
|
LOGGER.debug("entry to getTaskSummariesByWorkbasketId(workbasketId = {}", workbasketId);
|
||||||
List<TaskSummary> taskSummaries = new ArrayList<>();
|
List<TaskSummary> taskSummaries = new ArrayList<>();
|
||||||
taskanaEngineImpl.getWorkbasketService().getWorkbasket(workbasketId);
|
workbasketService.getWorkbasket(workbasketId);
|
||||||
try {
|
try {
|
||||||
taskanaEngineImpl.openConnection();
|
taskanaEngineImpl.openConnection();
|
||||||
taskSummaries = taskMapper.findTaskSummariesByWorkbasketId(workbasketId);
|
taskSummaries = taskMapper.findTaskSummariesByWorkbasketId(workbasketId);
|
||||||
|
@ -389,12 +401,12 @@ public class TaskServiceImpl implements TaskService {
|
||||||
taskanaEngineImpl.returnConnection();
|
taskanaEngineImpl.returnConnection();
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
int numberOfResultObjects = taskSummaries.size();
|
int numberOfResultObjects = taskSummaries.size();
|
||||||
LOGGER.debug("exit from getTaskSummariesByWorkbasketId(workbasketId). Returning {} resulting Objects: {} ",
|
LOGGER.debug(
|
||||||
|
"exit from getTaskSummariesByWorkbasketId(workbasketId). Returning {} resulting Objects: {} ",
|
||||||
numberOfResultObjects, LoggerUtils.listToString(taskSummaries));
|
numberOfResultObjects, LoggerUtils.listToString(taskSummaries));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return taskSummaries;
|
return taskSummaries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,10 @@ import org.mockito.InjectMocks;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.powermock.api.mockito.PowerMockito;
|
||||||
|
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
import pro.taskana.Classification;
|
import pro.taskana.Classification;
|
||||||
import pro.taskana.ClassificationService;
|
import pro.taskana.ClassificationService;
|
||||||
|
@ -49,12 +52,17 @@ import pro.taskana.model.Workbasket;
|
||||||
import pro.taskana.model.WorkbasketAuthorization;
|
import pro.taskana.model.WorkbasketAuthorization;
|
||||||
import pro.taskana.model.mappings.ObjectReferenceMapper;
|
import pro.taskana.model.mappings.ObjectReferenceMapper;
|
||||||
import pro.taskana.model.mappings.TaskMapper;
|
import pro.taskana.model.mappings.TaskMapper;
|
||||||
|
import pro.taskana.security.CurrentUserContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit Test for TaskServiceImpl.
|
* Unit Test for TaskServiceImpl.
|
||||||
|
*
|
||||||
* @author EH
|
* @author EH
|
||||||
*/
|
*/
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
// @RunWith(MockitoJUnitRunner.class)
|
||||||
|
@RunWith(PowerMockRunner.class)
|
||||||
|
@PrepareForTest(CurrentUserContext.class)
|
||||||
|
@PowerMockIgnore("javax.management.*")
|
||||||
public class TaskServiceImplTest {
|
public class TaskServiceImplTest {
|
||||||
|
|
||||||
private static final int SLEEP_TIME = 100;
|
private static final int SLEEP_TIME = 100;
|
||||||
|
@ -98,7 +106,8 @@ public class TaskServiceImplTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateSimpleTask() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
public void testCreateSimpleTask() throws NotAuthorizedException, WorkbasketNotFoundException,
|
||||||
|
ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||||
Mockito.doNothing().when(taskMapperMock).insert(any());
|
Mockito.doNothing().when(taskMapperMock).insert(any());
|
||||||
Task expectedTask = createUnitTestTask("1", "DUMMYTASK", "1");
|
Task expectedTask = createUnitTestTask("1", "DUMMYTASK", "1");
|
||||||
Workbasket wb = new Workbasket();
|
Workbasket wb = new Workbasket();
|
||||||
|
@ -109,7 +118,6 @@ public class TaskServiceImplTest {
|
||||||
Task actualTask = cut.createTask(expectedTask);
|
Task actualTask = cut.createTask(expectedTask);
|
||||||
|
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||||
verify(taskanaEngineMock, times(2)).getWorkbasketService();
|
|
||||||
verify(taskanaEngineMock, times(1)).getClassificationService();
|
verify(taskanaEngineMock, times(1)).getClassificationService();
|
||||||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||||
|
@ -131,7 +139,8 @@ public class TaskServiceImplTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateSimpleTaskWithObjectReference() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
public void testCreateSimpleTaskWithObjectReference() throws NotAuthorizedException, WorkbasketNotFoundException,
|
||||||
|
ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||||
ObjectReference expectedObjectReference = new ObjectReference();
|
ObjectReference expectedObjectReference = new ObjectReference();
|
||||||
expectedObjectReference.setId("1");
|
expectedObjectReference.setId("1");
|
||||||
expectedObjectReference.setType("DUMMY");
|
expectedObjectReference.setType("DUMMY");
|
||||||
|
@ -149,7 +158,6 @@ public class TaskServiceImplTest {
|
||||||
Task actualTask = cut.createTask(expectedTask);
|
Task actualTask = cut.createTask(expectedTask);
|
||||||
|
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||||
verify(taskanaEngineMock, times(2)).getWorkbasketService();
|
|
||||||
verify(taskanaEngineMock, times(1)).getClassificationService();
|
verify(taskanaEngineMock, times(1)).getClassificationService();
|
||||||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||||
|
@ -174,7 +182,8 @@ public class TaskServiceImplTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateSimpleTaskWithObjectReferenceIsNull() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
public void testCreateSimpleTaskWithObjectReferenceIsNull() throws NotAuthorizedException,
|
||||||
|
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||||
ObjectReference expectedObjectReference = new ObjectReference();
|
ObjectReference expectedObjectReference = new ObjectReference();
|
||||||
expectedObjectReference.setId("1");
|
expectedObjectReference.setId("1");
|
||||||
expectedObjectReference.setType("DUMMY");
|
expectedObjectReference.setType("DUMMY");
|
||||||
|
@ -193,7 +202,6 @@ public class TaskServiceImplTest {
|
||||||
expectedTask.getPrimaryObjRef().setId(actualTask.getPrimaryObjRef().getId()); // get only new ID
|
expectedTask.getPrimaryObjRef().setId(actualTask.getPrimaryObjRef().getId()); // get only new ID
|
||||||
|
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||||
verify(taskanaEngineMock, times(2)).getWorkbasketService();
|
|
||||||
verify(taskanaEngineMock, times(1)).getClassificationService();
|
verify(taskanaEngineMock, times(1)).getClassificationService();
|
||||||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||||
|
@ -218,7 +226,8 @@ public class TaskServiceImplTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateTaskWithPlanned() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
public void testCreateTaskWithPlanned()
|
||||||
|
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||||
ObjectReference expectedObjectReference = new ObjectReference();
|
ObjectReference expectedObjectReference = new ObjectReference();
|
||||||
expectedObjectReference.setId("1");
|
expectedObjectReference.setId("1");
|
||||||
expectedObjectReference.setType("DUMMY");
|
expectedObjectReference.setType("DUMMY");
|
||||||
|
@ -252,7 +261,6 @@ public class TaskServiceImplTest {
|
||||||
cut.createTask(test2);
|
cut.createTask(test2);
|
||||||
|
|
||||||
verify(taskanaEngineImpl, times(2)).openConnection();
|
verify(taskanaEngineImpl, times(2)).openConnection();
|
||||||
verify(taskanaEngineMock, times(2 + 2)).getWorkbasketService();
|
|
||||||
verify(taskanaEngineMock, times(2)).getClassificationService();
|
verify(taskanaEngineMock, times(2)).getClassificationService();
|
||||||
verify(workbasketServiceMock, times(2)).checkAuthorization(any(), any());
|
verify(workbasketServiceMock, times(2)).checkAuthorization(any(), any());
|
||||||
verify(workbasketServiceMock, times(2)).getWorkbasket(any());
|
verify(workbasketServiceMock, times(2)).getWorkbasket(any());
|
||||||
|
@ -282,7 +290,8 @@ public class TaskServiceImplTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NotAuthorizedException.class)
|
@Test(expected = NotAuthorizedException.class)
|
||||||
public void testCreateThrowingAuthorizedOnWorkbasket() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
public void testCreateThrowingAuthorizedOnWorkbasket()
|
||||||
|
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||||
try {
|
try {
|
||||||
Mockito.doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(any(), any());
|
Mockito.doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(any(), any());
|
||||||
Task task = new Task();
|
Task task = new Task();
|
||||||
|
@ -293,7 +302,6 @@ public class TaskServiceImplTest {
|
||||||
cut.createTask(task);
|
cut.createTask(task);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||||
verify(taskanaEngineMock, times(2)).getWorkbasketService();
|
|
||||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||||
|
@ -305,7 +313,8 @@ public class TaskServiceImplTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = WorkbasketNotFoundException.class)
|
@Test(expected = WorkbasketNotFoundException.class)
|
||||||
public void testCreateThrowsWorkbasketNotFoundException() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
public void testCreateThrowsWorkbasketNotFoundException()
|
||||||
|
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||||
try {
|
try {
|
||||||
Mockito.doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock).getWorkbasket(any());
|
Mockito.doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock).getWorkbasket(any());
|
||||||
Task task = new Task();
|
Task task = new Task();
|
||||||
|
@ -314,7 +323,6 @@ public class TaskServiceImplTest {
|
||||||
cut.createTask(task);
|
cut.createTask(task);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||||
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
|
||||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||||
|
@ -328,15 +336,20 @@ public class TaskServiceImplTest {
|
||||||
public void testClaimSuccessfulToOwner() throws Exception {
|
public void testClaimSuccessfulToOwner() throws Exception {
|
||||||
Task expectedTask = createUnitTestTask("1", "Unit Test Task 1", "1");
|
Task expectedTask = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||||
Mockito.doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
|
Mockito.doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
|
||||||
|
|
||||||
Thread.sleep(SLEEP_TIME); // to have different timestamps
|
Thread.sleep(SLEEP_TIME); // to have different timestamps
|
||||||
String expectedOwner = "John Does";
|
String expectedOwner = "John Does";
|
||||||
|
|
||||||
Task acturalTask = cut.claim(expectedTask.getId(), expectedOwner, true);
|
PowerMockito.mockStatic(CurrentUserContext.class);
|
||||||
|
Mockito.when(CurrentUserContext.getUserid()).thenReturn(expectedOwner);
|
||||||
|
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
// Mockito.doReturn(expectedOwner).when(currentUserContext).getUserid();
|
||||||
|
Task acturalTask = cut.claim(expectedTask.getId(), true);
|
||||||
|
|
||||||
|
verify(taskanaEngineImpl, times(2)).openConnection();
|
||||||
verify(taskMapperMock, times(1)).findById(expectedTask.getId());
|
verify(taskMapperMock, times(1)).findById(expectedTask.getId());
|
||||||
verify(taskMapperMock, times(1)).update(any());
|
verify(taskMapperMock, times(1)).update(any());
|
||||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||||
|
|
||||||
|
@ -351,12 +364,13 @@ public class TaskServiceImplTest {
|
||||||
try {
|
try {
|
||||||
Task expectedTask = null;
|
Task expectedTask = null;
|
||||||
Mockito.doReturn(expectedTask).when(taskMapperMock).findById(any());
|
Mockito.doReturn(expectedTask).when(taskMapperMock).findById(any());
|
||||||
|
// Mockito.doReturn("OWNER").when(currentUserContext).getUserid();
|
||||||
|
|
||||||
cut.claim("1", "OWNER", true);
|
cut.claim("1", true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(2)).openConnection();
|
||||||
verify(taskMapperMock, times(1)).findById(any());
|
verify(taskMapperMock, times(1)).findById(any());
|
||||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -364,7 +378,8 @@ public class TaskServiceImplTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteTask() throws TaskNotFoundException, InterruptedException, ClassificationAlreadyExistException {
|
public void testCompleteTask()
|
||||||
|
throws TaskNotFoundException, InterruptedException, ClassificationAlreadyExistException {
|
||||||
Task expectedTask = createUnitTestTask("1", "Unit Test Task 1", "1");
|
Task expectedTask = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||||
Thread.sleep(SLEEP_TIME); // to have different timestamps
|
Thread.sleep(SLEEP_TIME); // to have different timestamps
|
||||||
Mockito.doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
|
Mockito.doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
|
||||||
|
@ -400,7 +415,8 @@ public class TaskServiceImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTransferTaskToDestinationWorkbasketWithoutSecurity()
|
public void testTransferTaskToDestinationWorkbasketWithoutSecurity()
|
||||||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException {
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
|
||||||
|
ClassificationAlreadyExistException {
|
||||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||||
Workbasket destinationWorkbasket = createWorkbasket("2");
|
Workbasket destinationWorkbasket = createWorkbasket("2");
|
||||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||||
|
@ -411,14 +427,15 @@ public class TaskServiceImplTest {
|
||||||
doReturn(false).when(taskanaEngineConfigurationMock).isSecurityEnabled();
|
doReturn(false).when(taskanaEngineConfigurationMock).isSecurityEnabled();
|
||||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||||
doNothing().when(taskMapperMock).update(any());
|
doNothing().when(taskMapperMock).update(any());
|
||||||
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasket.getId(), WorkbasketAuthorization.APPEND);
|
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasket.getId(),
|
||||||
|
WorkbasketAuthorization.APPEND);
|
||||||
doNothing().when(workbasketServiceMock).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
doNothing().when(workbasketServiceMock).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
||||||
|
|
||||||
Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId());
|
Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId());
|
||||||
|
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||||
verify(taskanaEngineMock, times(workServiceMockCalls)).getWorkbasketService();
|
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasket.getId(),
|
||||||
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasket.getId(), WorkbasketAuthorization.APPEND);
|
WorkbasketAuthorization.APPEND);
|
||||||
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
||||||
verify(taskanaEngineMock, times(1)).getConfiguration();
|
verify(taskanaEngineMock, times(1)).getConfiguration();
|
||||||
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
|
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
|
||||||
|
@ -435,7 +452,8 @@ public class TaskServiceImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTransferTaskToDestinationWorkbasketUsingSecurityTrue()
|
public void testTransferTaskToDestinationWorkbasketUsingSecurityTrue()
|
||||||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException {
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
|
||||||
|
ClassificationAlreadyExistException {
|
||||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||||
Workbasket destinationWorkbasket = createWorkbasket("2");
|
Workbasket destinationWorkbasket = createWorkbasket("2");
|
||||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||||
|
@ -444,14 +462,15 @@ public class TaskServiceImplTest {
|
||||||
doReturn(true).when(taskanaEngineConfigurationMock).isSecurityEnabled();
|
doReturn(true).when(taskanaEngineConfigurationMock).isSecurityEnabled();
|
||||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||||
doNothing().when(taskMapperMock).update(any());
|
doNothing().when(taskMapperMock).update(any());
|
||||||
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasket.getId(), WorkbasketAuthorization.APPEND);
|
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasket.getId(),
|
||||||
|
WorkbasketAuthorization.APPEND);
|
||||||
doNothing().when(workbasketServiceMock).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
doNothing().when(workbasketServiceMock).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
||||||
|
|
||||||
Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId());
|
Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId());
|
||||||
|
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||||
verify(taskanaEngineMock, times(2)).getWorkbasketService();
|
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasket.getId(),
|
||||||
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasket.getId(), WorkbasketAuthorization.APPEND);
|
WorkbasketAuthorization.APPEND);
|
||||||
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
||||||
verify(taskanaEngineMock, times(1)).getConfiguration();
|
verify(taskanaEngineMock, times(1)).getConfiguration();
|
||||||
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
|
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
|
||||||
|
@ -467,20 +486,22 @@ public class TaskServiceImplTest {
|
||||||
|
|
||||||
@Test(expected = WorkbasketNotFoundException.class)
|
@Test(expected = WorkbasketNotFoundException.class)
|
||||||
public void testTransferDestinationWorkbasketDoesNotExist()
|
public void testTransferDestinationWorkbasketDoesNotExist()
|
||||||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException {
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
|
||||||
|
ClassificationAlreadyExistException {
|
||||||
|
|
||||||
String destinationWorkbasketId = "2";
|
String destinationWorkbasketId = "2";
|
||||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||||
doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock).checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock)
|
||||||
|
.checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
||||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cutSpy.transfer(task.getId(), destinationWorkbasketId);
|
cutSpy.transfer(task.getId(), destinationWorkbasketId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||||
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId,
|
||||||
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
WorkbasketAuthorization.APPEND);
|
||||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||||
|
@ -490,7 +511,8 @@ public class TaskServiceImplTest {
|
||||||
|
|
||||||
@Test(expected = TaskNotFoundException.class)
|
@Test(expected = TaskNotFoundException.class)
|
||||||
public void testTransferTaskDoesNotExist()
|
public void testTransferTaskDoesNotExist()
|
||||||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException {
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
|
||||||
|
ClassificationAlreadyExistException {
|
||||||
|
|
||||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||||
|
@ -509,19 +531,21 @@ public class TaskServiceImplTest {
|
||||||
|
|
||||||
@Test(expected = NotAuthorizedException.class)
|
@Test(expected = NotAuthorizedException.class)
|
||||||
public void testTransferNotAuthorizationOnWorkbasketAppend()
|
public void testTransferNotAuthorizationOnWorkbasketAppend()
|
||||||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException {
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
|
||||||
|
ClassificationAlreadyExistException {
|
||||||
String destinationWorkbasketId = "2";
|
String destinationWorkbasketId = "2";
|
||||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||||
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(destinationWorkbasketId,
|
||||||
|
WorkbasketAuthorization.APPEND);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cutSpy.transfer(task.getId(), destinationWorkbasketId);
|
cutSpy.transfer(task.getId(), destinationWorkbasketId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||||
verify(taskanaEngineMock, times(1)).getWorkbasketService();
|
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId,
|
||||||
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
WorkbasketAuthorization.APPEND);
|
||||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||||
|
@ -531,20 +555,23 @@ public class TaskServiceImplTest {
|
||||||
|
|
||||||
@Test(expected = NotAuthorizedException.class)
|
@Test(expected = NotAuthorizedException.class)
|
||||||
public void testTransferNotAuthorizationOnWorkbasketTransfer()
|
public void testTransferNotAuthorizationOnWorkbasketTransfer()
|
||||||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException {
|
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
|
||||||
|
ClassificationAlreadyExistException {
|
||||||
String destinationWorkbasketId = "2";
|
String destinationWorkbasketId = "2";
|
||||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||||
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasketId,
|
||||||
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(task.getWorkbasketId(), WorkbasketAuthorization.TRANSFER);
|
WorkbasketAuthorization.APPEND);
|
||||||
|
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(task.getWorkbasketId(),
|
||||||
|
WorkbasketAuthorization.TRANSFER);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cutSpy.transfer(task.getId(), destinationWorkbasketId);
|
cutSpy.transfer(task.getId(), destinationWorkbasketId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||||
verify(taskanaEngineMock, times(2)).getWorkbasketService();
|
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId,
|
||||||
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
WorkbasketAuthorization.APPEND);
|
||||||
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getId(), WorkbasketAuthorization.TRANSFER);
|
||||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||||
|
@ -575,7 +602,8 @@ public class TaskServiceImplTest {
|
||||||
final long daysInPast = 10L;
|
final long daysInPast = 10L;
|
||||||
final long expectedResult = 5L;
|
final long expectedResult = 5L;
|
||||||
String workbasketId = "1";
|
String workbasketId = "1";
|
||||||
doReturn(expectedResult).when(taskMapperMock).getTaskCountForWorkbasketByDaysInPastAndState(any(), any(), any());
|
doReturn(expectedResult).when(taskMapperMock).getTaskCountForWorkbasketByDaysInPastAndState(any(), any(),
|
||||||
|
any());
|
||||||
|
|
||||||
long actualResult = cut.getTaskCountForWorkbasketByDaysInPastAndState(workbasketId, daysInPast, taskStates);
|
long actualResult = cut.getTaskCountForWorkbasketByDaysInPastAndState(workbasketId, daysInPast, taskStates);
|
||||||
|
|
||||||
|
@ -592,9 +620,11 @@ public class TaskServiceImplTest {
|
||||||
final long daysInPast = 10L;
|
final long daysInPast = 10L;
|
||||||
List<TaskState> taskStates = Arrays.asList(TaskState.CLAIMED, TaskState.COMPLETED);
|
List<TaskState> taskStates = Arrays.asList(TaskState.CLAIMED, TaskState.COMPLETED);
|
||||||
List<DueWorkbasketCounter> expectedResult = new ArrayList<>();
|
List<DueWorkbasketCounter> expectedResult = new ArrayList<>();
|
||||||
doReturn(expectedResult).when(taskMapperMock).getTaskCountByWorkbasketIdAndDaysInPastAndState(any(Date.class), any());
|
doReturn(expectedResult).when(taskMapperMock).getTaskCountByWorkbasketIdAndDaysInPastAndState(any(Date.class),
|
||||||
|
any());
|
||||||
|
|
||||||
List<DueWorkbasketCounter> actualResult = cut.getTaskCountByWorkbasketAndDaysInPastAndState(daysInPast, taskStates);
|
List<DueWorkbasketCounter> actualResult = cut.getTaskCountByWorkbasketAndDaysInPastAndState(daysInPast,
|
||||||
|
taskStates);
|
||||||
|
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||||
verify(taskMapperMock, times(1)).getTaskCountByWorkbasketIdAndDaysInPastAndState(any(Date.class), any());
|
verify(taskMapperMock, times(1)).getTaskCountByWorkbasketIdAndDaysInPastAndState(any(Date.class), any());
|
||||||
|
@ -679,9 +709,9 @@ public class TaskServiceImplTest {
|
||||||
String workbasketId = "1";
|
String workbasketId = "1";
|
||||||
List<TaskSummary> expectedResultList = new ArrayList<>();
|
List<TaskSummary> expectedResultList = new ArrayList<>();
|
||||||
doNothing().when(taskanaEngineImpl).openConnection();
|
doNothing().when(taskanaEngineImpl).openConnection();
|
||||||
doThrow(new IllegalArgumentException("Invalid ID: " + workbasketId)).when(taskMapperMock).findTaskSummariesByWorkbasketId(workbasketId);
|
doThrow(new IllegalArgumentException("Invalid ID: " + workbasketId)).when(taskMapperMock)
|
||||||
|
.findTaskSummariesByWorkbasketId(workbasketId);
|
||||||
doNothing().when(taskanaEngineImpl).returnConnection();
|
doNothing().when(taskanaEngineImpl).returnConnection();
|
||||||
doReturn(workbasketServiceMock).when(taskanaEngineImpl).getWorkbasketService();
|
|
||||||
doReturn(new Workbasket()).when(workbasketServiceMock).getWorkbasket(any());
|
doReturn(new Workbasket()).when(workbasketServiceMock).getWorkbasket(any());
|
||||||
|
|
||||||
// when - make the call
|
// when - make the call
|
||||||
|
@ -691,7 +721,6 @@ public class TaskServiceImplTest {
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||||
verify(taskMapperMock, times(1)).findTaskSummariesByWorkbasketId(workbasketId);
|
verify(taskMapperMock, times(1)).findTaskSummariesByWorkbasketId(workbasketId);
|
||||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||||
verify(taskanaEngineImpl, times(1)).getWorkbasketService();
|
|
||||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||||
|
|
||||||
verifyNoMoreInteractions(taskMapperMock, taskanaEngineImpl, workbasketServiceMock);
|
verifyNoMoreInteractions(taskMapperMock, taskanaEngineImpl, workbasketServiceMock);
|
||||||
|
@ -704,13 +733,11 @@ public class TaskServiceImplTest {
|
||||||
List<TaskSummary> expectedResultList = Arrays.asList(new TaskSummary(), new TaskSummary());
|
List<TaskSummary> expectedResultList = Arrays.asList(new TaskSummary(), new TaskSummary());
|
||||||
doNothing().when(taskanaEngineImpl).openConnection();
|
doNothing().when(taskanaEngineImpl).openConnection();
|
||||||
doNothing().when(taskanaEngineImpl).returnConnection();
|
doNothing().when(taskanaEngineImpl).returnConnection();
|
||||||
doReturn(workbasketServiceMock).when(taskanaEngineImpl).getWorkbasketService();
|
|
||||||
doReturn(new Workbasket()).when(workbasketServiceMock).getWorkbasket(any());
|
doReturn(new Workbasket()).when(workbasketServiceMock).getWorkbasket(any());
|
||||||
doReturn(expectedResultList).when(taskMapperMock).findTaskSummariesByWorkbasketId(workbasketId);
|
doReturn(expectedResultList).when(taskMapperMock).findTaskSummariesByWorkbasketId(workbasketId);
|
||||||
|
|
||||||
List<TaskSummary> actualResultList = cut.getTaskSummariesByWorkbasketId(workbasketId);
|
List<TaskSummary> actualResultList = cut.getTaskSummariesByWorkbasketId(workbasketId);
|
||||||
|
|
||||||
verify(taskanaEngineImpl, times(1)).getWorkbasketService();
|
|
||||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||||
verify(taskMapperMock, times(1)).findTaskSummariesByWorkbasketId(workbasketId);
|
verify(taskMapperMock, times(1)).findTaskSummariesByWorkbasketId(workbasketId);
|
||||||
|
@ -727,7 +754,6 @@ public class TaskServiceImplTest {
|
||||||
doNothing().when(taskanaEngineImpl).openConnection();
|
doNothing().when(taskanaEngineImpl).openConnection();
|
||||||
doNothing().when(taskanaEngineImpl).returnConnection();
|
doNothing().when(taskanaEngineImpl).returnConnection();
|
||||||
doReturn(null).when(taskMapperMock).findTaskSummariesByWorkbasketId(workbasketId);
|
doReturn(null).when(taskMapperMock).findTaskSummariesByWorkbasketId(workbasketId);
|
||||||
doReturn(workbasketServiceMock).when(taskanaEngineImpl).getWorkbasketService();
|
|
||||||
doReturn(new Workbasket()).when(workbasketServiceMock).getWorkbasket(any());
|
doReturn(new Workbasket()).when(workbasketServiceMock).getWorkbasket(any());
|
||||||
|
|
||||||
List<TaskSummary> actualResultList = cut.getTaskSummariesByWorkbasketId(workbasketId);
|
List<TaskSummary> actualResultList = cut.getTaskSummariesByWorkbasketId(workbasketId);
|
||||||
|
@ -735,7 +761,6 @@ public class TaskServiceImplTest {
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||||
verify(taskMapperMock, times(1)).findTaskSummariesByWorkbasketId(workbasketId);
|
verify(taskMapperMock, times(1)).findTaskSummariesByWorkbasketId(workbasketId);
|
||||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||||
verify(taskanaEngineImpl, times(1)).getWorkbasketService();
|
|
||||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||||
verifyNoMoreInteractions(taskMapperMock, taskanaEngineImpl, workbasketServiceMock);
|
verifyNoMoreInteractions(taskMapperMock, taskanaEngineImpl, workbasketServiceMock);
|
||||||
|
|
||||||
|
@ -743,7 +768,8 @@ public class TaskServiceImplTest {
|
||||||
assertThat(actualResultList.size(), equalTo(expectedResultList.size()));
|
assertThat(actualResultList.size(), equalTo(expectedResultList.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task createUnitTestTask(String id, String name, String workbasketId) throws ClassificationAlreadyExistException {
|
private Task createUnitTestTask(String id, String name, String workbasketId)
|
||||||
|
throws ClassificationAlreadyExistException {
|
||||||
Task task = new Task();
|
Task task = new Task();
|
||||||
task.setId(id);
|
task.setId(id);
|
||||||
task.setName(name);
|
task.setName(name);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<groupId>pro.taskana</groupId>
|
<groupId>pro.taskana</groupId>
|
||||||
<artifactId>rest</artifactId>
|
<artifactId>rest</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>rest</name>
|
<name>rest</name>
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>pro.taskana</groupId>
|
<groupId>pro.taskana</groupId>
|
||||||
<artifactId>taskana-core</artifactId>
|
<artifactId>taskana-core</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.3-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
Loading…
Reference in New Issue