TSK-137: Get all attachments of a Task.
This commit is contained in:
parent
98658ac8e8
commit
ad8aabb5de
|
@ -42,7 +42,7 @@ public class ExampleBootstrap {
|
|||
taskanaEjb.getTaskService().claim(task.getId());
|
||||
System.out.println(
|
||||
"---------------------------> Task claimed: "
|
||||
+ taskanaEjb.getTaskService().getTaskById(task.getId()).getOwner());
|
||||
+ taskanaEjb.getTaskService().getTask(task.getId()).getOwner());
|
||||
taskanaEjb.getTaskService().completeTask(task.getId());
|
||||
System.out.println("---------------------------> Task completed");
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ public interface TaskService {
|
|||
* @throws TaskNotFoundException
|
||||
* thrown of the {@link Task} with taskId is not found
|
||||
*/
|
||||
Task getTaskById(String taskId) throws TaskNotFoundException;
|
||||
Task getTask(String taskId) throws TaskNotFoundException;
|
||||
|
||||
/**
|
||||
* Transfer a task to another work basket. The transfer sets the transferred flag and resets the read flag.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package pro.taskana.impl;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import pro.taskana.Attachment;
|
||||
|
@ -20,12 +21,16 @@ public class AttachmentImpl implements Attachment {
|
|||
private Timestamp modified;
|
||||
private Classification classification;
|
||||
private ObjectReference objectReference;
|
||||
private String porCompany;
|
||||
private String porSystem;
|
||||
private String porSystemInstance;
|
||||
private String porType;
|
||||
private String porValue;
|
||||
private String channel;
|
||||
private Timestamp received;
|
||||
private Map<String, Object> customAttributes;
|
||||
private Map<String, Object> customAttributes = Collections.emptyMap();;
|
||||
|
||||
AttachmentImpl() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -114,6 +119,46 @@ public class AttachmentImpl implements Attachment {
|
|||
this.customAttributes = customAttributes;
|
||||
}
|
||||
|
||||
public String getPorCompany() {
|
||||
return porCompany;
|
||||
}
|
||||
|
||||
public void setPorCompany(String porCompany) {
|
||||
this.porCompany = porCompany;
|
||||
}
|
||||
|
||||
public String getPorSystem() {
|
||||
return porSystem;
|
||||
}
|
||||
|
||||
public void setPorSystem(String porSystem) {
|
||||
this.porSystem = porSystem;
|
||||
}
|
||||
|
||||
public String getPorSystemInstance() {
|
||||
return porSystemInstance;
|
||||
}
|
||||
|
||||
public void setPorSystemInstance(String porSystemInstance) {
|
||||
this.porSystemInstance = porSystemInstance;
|
||||
}
|
||||
|
||||
public String getPorType() {
|
||||
return porType;
|
||||
}
|
||||
|
||||
public void setPorType(String porType) {
|
||||
this.porType = porType;
|
||||
}
|
||||
|
||||
public String getPorValue() {
|
||||
return porValue;
|
||||
}
|
||||
|
||||
public void setPorValue(String porValue) {
|
||||
this.porValue = porValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
@ -127,6 +172,16 @@ public class AttachmentImpl implements Attachment {
|
|||
builder.append(modified);
|
||||
builder.append(", classification=");
|
||||
builder.append(classification);
|
||||
builder.append(", porCompany=");
|
||||
builder.append(porCompany);
|
||||
builder.append(", porSystem=");
|
||||
builder.append(porSystem);
|
||||
builder.append(", porSystemInstance=");
|
||||
builder.append(porSystemInstance);
|
||||
builder.append(", porType=");
|
||||
builder.append(porType);
|
||||
builder.append(", porValue=");
|
||||
builder.append(porValue);
|
||||
builder.append(", objectReference=");
|
||||
builder.append(objectReference);
|
||||
builder.append(", channel=");
|
||||
|
|
|
@ -82,7 +82,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
TaskImpl task = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
task = (TaskImpl) getTaskById(taskId);
|
||||
task = (TaskImpl) getTask(taskId);
|
||||
TaskState state = task.getState();
|
||||
if (state == TaskState.COMPLETED) {
|
||||
LOGGER.warn("Method claim() found that task {} is already completed. Throwing InvalidStateException",
|
||||
|
@ -123,7 +123,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
TaskImpl task = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
task = (TaskImpl) this.getTaskById(taskId);
|
||||
task = (TaskImpl) this.getTask(taskId);
|
||||
// check pre-conditions for non-forced invocation
|
||||
if (!isForced) {
|
||||
if (task.getClaimed() == null || task.getState() != TaskState.CLAIMED) {
|
||||
|
@ -191,7 +191,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Task getTaskById(String id) throws TaskNotFoundException {
|
||||
public Task getTask(String id) throws TaskNotFoundException {
|
||||
LOGGER.debug("entry to getTaskById(id = {})", id);
|
||||
Task result = null;
|
||||
try {
|
||||
|
@ -199,6 +199,9 @@ public class TaskServiceImpl implements TaskService {
|
|||
result = taskMapper.findById(id);
|
||||
if (result != null) {
|
||||
setPrimaryObjRef((TaskImpl) result);
|
||||
List<Attachment> attachments = setAttachmentObjRef(
|
||||
attachmentMapper.findAttachmentsByTaskId(result.getId()));
|
||||
((TaskImpl) result).setAttachments(attachments);
|
||||
return result;
|
||||
} else {
|
||||
LOGGER.warn("Method getTaskById() didn't find task with id {}. Throwing TaskNotFoundException", id);
|
||||
|
@ -217,7 +220,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
Task result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
TaskImpl task = (TaskImpl) getTaskById(taskId);
|
||||
TaskImpl task = (TaskImpl) getTask(taskId);
|
||||
|
||||
// transfer requires TRANSFER in source and APPEND on destination workbasket
|
||||
workbasketService.checkAuthorization(destinationWorkbasketKey, WorkbasketAuthorization.APPEND);
|
||||
|
@ -238,7 +241,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
task.setModified(Timestamp.valueOf(LocalDateTime.now()));
|
||||
taskMapper.update(task);
|
||||
|
||||
result = getTaskById(taskId);
|
||||
result = getTask(taskId);
|
||||
LOGGER.debug("Method transfer() transferred Task '{}' to destination workbasket {}", taskId,
|
||||
destinationWorkbasketKey);
|
||||
return result;
|
||||
|
@ -254,11 +257,11 @@ public class TaskServiceImpl implements TaskService {
|
|||
Task result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
TaskImpl task = (TaskImpl) getTaskById(taskId);
|
||||
TaskImpl task = (TaskImpl) getTask(taskId);
|
||||
task.setRead(true);
|
||||
task.setModified(Timestamp.valueOf(LocalDateTime.now()));
|
||||
taskMapper.update(task);
|
||||
result = getTaskById(taskId);
|
||||
result = getTask(taskId);
|
||||
LOGGER.debug("Method setTaskRead() set read property of Task '{}' to {} ", result, isRead);
|
||||
return result;
|
||||
} finally {
|
||||
|
@ -307,7 +310,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
TaskImpl oldTaskImpl = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
oldTaskImpl = (TaskImpl) getTaskById(newTaskImpl.getId());
|
||||
oldTaskImpl = (TaskImpl) getTask(newTaskImpl.getId());
|
||||
standardUpdateActions(oldTaskImpl, newTaskImpl);
|
||||
|
||||
taskMapper.update(newTaskImpl);
|
||||
|
@ -431,6 +434,23 @@ public class TaskServiceImpl implements TaskService {
|
|||
task.setPrimaryObjRef(objRef);
|
||||
}
|
||||
|
||||
private List<Attachment> setAttachmentObjRef(List<AttachmentImpl> attachments) {
|
||||
List<Attachment> results = new ArrayList<>();
|
||||
if (attachments != null && !attachments.isEmpty()) {
|
||||
for (AttachmentImpl attachment : attachments) {
|
||||
ObjectReference objRef = new ObjectReference();
|
||||
objRef.setCompany(attachment.getPorCompany());
|
||||
objRef.setSystem(attachment.getPorSystem());
|
||||
objRef.setSystemInstance(attachment.getPorSystemInstance());
|
||||
objRef.setType(attachment.getPorType());
|
||||
objRef.setValue(attachment.getPorValue());
|
||||
attachment.setObjectReference(objRef);
|
||||
results.add(attachment);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private void validateObjectReference(ObjectReference objRef, String objRefType, String objName)
|
||||
throws InvalidArgumentException {
|
||||
// check that all values in the ObjectReference are set correctly
|
||||
|
@ -465,7 +485,6 @@ public class TaskServiceImpl implements TaskService {
|
|||
throw new InvalidArgumentException("Classification of attachment " + attachment + " must not be null");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void standardUpdateActions(TaskImpl oldTaskImpl, TaskImpl newTaskImpl)
|
||||
|
|
|
@ -1,18 +1,51 @@
|
|||
package pro.taskana.model.mappings;
|
||||
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.One;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Result;
|
||||
import org.apache.ibatis.annotations.Results;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import pro.taskana.Classification;
|
||||
import pro.taskana.impl.AttachmentImpl;
|
||||
import pro.taskana.impl.persistence.MapTypeHandler;
|
||||
|
||||
/**
|
||||
* This class is the mybatis mapping of Attachment.
|
||||
*/
|
||||
public interface AttachmentMapper {
|
||||
|
||||
@Insert("INSERT INTO ATTACHMENT (ID, TASK_ID, CREATED, MODIFIED, CLASSIFICATION_KEY, REF_COMPANY, REF_SYSTEM, REF_INSTANCE, REF_TYPE, REF_VALUE, CHANNEL, RECEIVED, CUSTOM_ATTRIBUTES) "
|
||||
String CLASSIFICATION_FINDBYID = "pro.taskana.model.mappings.ClassificationMapper.findById";
|
||||
|
||||
@Insert("INSERT INTO ATTACHMENT (ID, TASK_ID, CREATED, MODIFIED, CLASSIFICATION_KEY, REF_COMPANY, REF_SYSTEM, REF_INSTANCE, REF_TYPE, REF_VALUE, CHANNEL, RECEIVED, CUSTOM_ATTRIBUTES) "
|
||||
+ "VALUES (#{att.id}, #{att.taskId}, #{att.created}, #{att.modified}, #{att.classification.key}, #{att.objectReference.company}, #{att.objectReference.system}, #{att.objectReference.systemInstance}, "
|
||||
+ " #{att.objectReference.type}, #{att.objectReference.value}, #{att.channel}, #{att.received}, #{att.customAttributes,jdbcType=BLOB,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler} )")
|
||||
void insert(@Param("att") AttachmentImpl att);
|
||||
|
||||
@Select("SELECT ID, TASK_ID, CREATED, MODIFIED, CLASSIFICATION_KEY, REF_COMPANY, REF_SYSTEM, REF_INSTANCE, REF_TYPE, REF_VALUE, CHANNEL, RECEIVED, CUSTOM_ATTRIBUTES "
|
||||
+ "FROM ATTACHMENT "
|
||||
+ "WHERE TASK_ID = #{taskId}")
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "ID"),
|
||||
@Result(property = "taskId", column = "TASK_ID"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "modified", column = "MODIFIED"),
|
||||
@Result(property = "classification", column = "CLASSIFICATION_KEY", javaType = Classification.class,
|
||||
one = @One(select = CLASSIFICATION_FINDBYID)),
|
||||
@Result(property = "porCompany", column = "REF_COMPANY"),
|
||||
@Result(property = "porSystem", column = "REF_SYSTEM"),
|
||||
@Result(property = "porSystemInstance", column = "REF_INSTANCE"),
|
||||
@Result(property = "porType", column = "REF_TYPE"),
|
||||
@Result(property = "porValue", column = "REF_VALUE"),
|
||||
@Result(property = "channel", column = "CHANNEL"),
|
||||
@Result(property = "received", column = "RECEIVED"),
|
||||
@Result(property = "customAttributes", column = "CUSTOM_ATTRIBUTES", jdbcType = JdbcType.BLOB,
|
||||
javaType = Map.class, typeHandler = MapTypeHandler.class),
|
||||
})
|
||||
List<AttachmentImpl> findAttachmentsByTaskId(@Param("taskId") String taskId);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import pro.taskana.model.ObjectReference;
|
|||
public interface QueryMapper {
|
||||
|
||||
String OBJECTREFERENCEMAPPER_FINDBYID = "pro.taskana.model.mappings.ObjectReferenceMapper.findById";
|
||||
String CLASSIFICATION_FINDBYIDANDDOMAIN = "pro.taskana.model.mappings.ClassificationMapper.findByKeyAndDomain";
|
||||
String CLASSIFICATION_FINDBYKEYANDDOMAIN = "pro.taskana.model.mappings.ClassificationMapper.findByKeyAndDomain";
|
||||
String CLASSIFICATION_FINDBYID = "pro.taskana.model.mappings.ClassificationMapper.findById";
|
||||
|
||||
@Select("<script>SELECT t.ID, t.CREATED, t.CLAIMED, t.COMPLETED, t.MODIFIED, t.PLANNED, t.DUE, t.NAME, t.DESCRIPTION, t.PRIORITY, t.STATE, t.CLASSIFICATION_KEY, t.WORKBASKET_KEY, t.OWNER, t.POR_COMPANY, t.POR_SYSTEM, t.POR_INSTANCE, t.POR_TYPE, t.POR_VALUE, t.IS_READ, t.IS_TRANSFERRED, t.CUSTOM_1, t.CUSTOM_2, t.CUSTOM_3, t.CUSTOM_4, t.CUSTOM_5, t.CUSTOM_6, t.CUSTOM_7, t.CUSTOM_8, t.CUSTOM_9, t.CUSTOM_10 "
|
||||
|
|
|
@ -71,13 +71,13 @@ public interface TaskMapper {
|
|||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10")})
|
||||
|
||||
@Result(property = "custom10", column = "CUSTOM_10")
|
||||
})
|
||||
TaskImpl findById(@Param("id") String id);
|
||||
|
||||
@Results({@Result(column = "DUE_DATE", property = "due"),
|
||||
@Results({ @Result(column = "DUE_DATE", property = "due"),
|
||||
@Result(column = "WORKBASKET_KEY", property = "workbasketKey"),
|
||||
@Result(column = "counter", property = "taskCounter")})
|
||||
@Result(column = "counter", property = "taskCounter") })
|
||||
List<DueWorkbasketCounter> getTaskCountByWorkbasketIdAndDaysInPastAndState(@Param("fromDate") Date fromDate,
|
||||
@Param("status") List<TaskState> states);
|
||||
|
||||
|
@ -131,8 +131,7 @@ public interface TaskMapper {
|
|||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10")})
|
||||
|
||||
@Result(property = "custom10", column = "CUSTOM_10") })
|
||||
List<TaskImpl> findTasksByWorkbasketIdAndState(@Param("workbasketKey") String workbasketKey,
|
||||
@Param("taskState") TaskState taskState);
|
||||
|
||||
|
@ -151,5 +150,4 @@ public interface TaskMapper {
|
|||
@Result(property = "classificationName", column = "classificationName")
|
||||
})
|
||||
List<TaskSummary> findTaskSummariesByWorkbasketKey(@Param("workbasketKey") String workbasketKey);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import pro.taskana.exceptions.InvalidArgumentException;
|
|||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskAlreadyExistException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.security.JAASRunner;
|
||||
|
@ -72,7 +73,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
@Test
|
||||
public void testCreateExternalTaskWithAttachment()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
|
||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task newTask = taskService.newTask();
|
||||
|
@ -87,15 +88,16 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
assertNotNull(createdTask.getId());
|
||||
|
||||
// rename getTaskById to getTask
|
||||
// Task readTask = taskService.getTask(createdTask.getId());
|
||||
Task readTask = taskService.getTask(createdTask.getId());
|
||||
|
||||
// assertNotNull(readTask);
|
||||
// assertNotNull(readTask.getAttachments());
|
||||
// assertEquals(1, readTask.getAttachments().size());
|
||||
// assertNotNull(readTask.getAttachments().get(0).getCreated());
|
||||
// assertNotNull(readTask.getAttachments().get(0).getModified());
|
||||
// assertEquals(readTask.getAttachments().get(0).getCreated(), readTask.getAttachments().get(0).getModified());
|
||||
assertNotNull(readTask);
|
||||
assertNotNull(readTask.getAttachments());
|
||||
assertEquals(1, readTask.getAttachments().size());
|
||||
assertNotNull(readTask.getAttachments().get(0).getCreated());
|
||||
assertNotNull(readTask.getAttachments().get(0).getModified());
|
||||
assertEquals(readTask.getAttachments().get(0).getCreated(), readTask.getAttachments().get(0).getModified());
|
||||
// assertNotNull(readTask.getAttachments().get(0).getClassification());
|
||||
assertNotNull(readTask.getAttachments().get(0).getObjectReference());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
|
@ -104,7 +106,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
@Test
|
||||
public void testCreateExternalTaskWithMultipleAttachments()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
|
||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task newTask = taskService.newTask();
|
||||
|
@ -123,15 +125,16 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
assertNotNull(createdTask.getId());
|
||||
|
||||
// rename getTaskById to getTask
|
||||
// Task readTask = taskService.getTask(createdTask.getId());
|
||||
Task readTask = taskService.getTask(createdTask.getId());
|
||||
|
||||
// assertNotNull(readTask);
|
||||
// assertNotNull(readTask.getAttachments());
|
||||
// assertEquals(2, readTask.getAttachments().size());
|
||||
// assertNotNull(readTask.getAttachments().get(1).getCreated());
|
||||
// assertNotNull(readTask.getAttachments().get(1).getModified());
|
||||
// assertEquals(readTask.getAttachments().get(0).getCreated(), readTask.getAttachments().get(1).getModified());
|
||||
assertNotNull(readTask);
|
||||
assertNotNull(readTask.getAttachments());
|
||||
assertEquals(2, readTask.getAttachments().size());
|
||||
assertNotNull(readTask.getAttachments().get(1).getCreated());
|
||||
assertNotNull(readTask.getAttachments().get(1).getModified());
|
||||
assertEquals(readTask.getAttachments().get(0).getCreated(), readTask.getAttachments().get(1).getModified());
|
||||
// assertNotNull(readTask.getAttachments().get(0).getClassification());
|
||||
assertNotNull(readTask.getAttachments().get(0).getObjectReference());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
|
|
|
@ -45,7 +45,7 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
ConcurrencyException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task task = taskService.getTaskById("TKI:000000000000000000000000000000000000");
|
||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "7654321"));
|
||||
Task updatedTask = taskService.updateTask(task);
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
ConcurrencyException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task task = taskService.getTaskById("TKI:000000000000000000000000000000000000");
|
||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
task.setPrimaryObjRef(null);
|
||||
Task updatedTask = null;
|
||||
try {
|
||||
|
@ -120,8 +120,8 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
ConcurrencyException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task task = taskService.getTaskById("TKI:000000000000000000000000000000000000");
|
||||
Task task2 = taskService.getTaskById("TKI:000000000000000000000000000000000000");
|
||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
Task task2 = taskService.getTask("TKI:000000000000000000000000000000000000");
|
||||
|
||||
task.setCustom1("willi");
|
||||
Task updatedTask = null;
|
||||
|
|
|
@ -51,6 +51,7 @@ import pro.taskana.model.ObjectReference;
|
|||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.TaskSummary;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
import pro.taskana.model.mappings.AttachmentMapper;
|
||||
import pro.taskana.model.mappings.ObjectReferenceMapper;
|
||||
import pro.taskana.model.mappings.TaskMapper;
|
||||
import pro.taskana.security.CurrentUserContext;
|
||||
|
@ -92,6 +93,9 @@ public class TaskServiceImplTest {
|
|||
@Mock
|
||||
private ClassificationService classificationServiceMock;
|
||||
|
||||
@Mock
|
||||
private AttachmentMapper attachmentMapperMock;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
@ -116,7 +120,7 @@ public class TaskServiceImplTest {
|
|||
wb.setId("1");
|
||||
wb.setKey("k1");
|
||||
wb.setName("workbasket");
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTaskById(expectedTask.getId());
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(expectedTask.getId());
|
||||
doReturn(wb).when(workbasketServiceMock).getWorkbasketByKey(wb.getKey());
|
||||
doNothing().when(taskMapperMock).insert(expectedTask);
|
||||
expectedTask.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
|
||||
|
@ -129,8 +133,8 @@ public class TaskServiceImplTest {
|
|||
verify(classificationServiceMock, times(1)).getClassification(any(), any());
|
||||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
|
||||
assertNull(actualTask.getOwner());
|
||||
|
@ -157,7 +161,7 @@ public class TaskServiceImplTest {
|
|||
TaskImpl expectedTask = createUnitTestTask("", "DUMMYTASK", wb.getKey());
|
||||
expectedTask.setPrimaryObjRef(expectedObjectReference);
|
||||
Classification classification = expectedTask.getClassification();
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTaskById(expectedTask.getId());
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(expectedTask.getId());
|
||||
doReturn(wb).when(workbasketServiceMock).getWorkbasketByKey(expectedTask.getWorkbasketKey());
|
||||
doReturn(expectedObjectReference).when(objectReferenceMapperMock)
|
||||
.findByObjectReference(expectedObjectReference);
|
||||
|
@ -171,8 +175,8 @@ public class TaskServiceImplTest {
|
|||
classification.getDomain());
|
||||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
assertNull(actualTask.getOwner());
|
||||
assertNotNull(actualTask.getCreated());
|
||||
|
@ -199,7 +203,7 @@ public class TaskServiceImplTest {
|
|||
TaskImpl expectedTask = createUnitTestTask("", "DUMMYTASK", "key1");
|
||||
expectedTask.setPrimaryObjRef(expectedObjectReference);
|
||||
Classification classification = expectedTask.getClassification();
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTaskById(expectedTask.getId());
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(expectedTask.getId());
|
||||
doReturn(classification).when(classificationServiceMock).getClassification(classification.getKey(),
|
||||
classification.getDomain());
|
||||
doNothing().when(taskMapperMock).insert(expectedTask);
|
||||
|
@ -217,8 +221,8 @@ public class TaskServiceImplTest {
|
|||
classification.getDomain());
|
||||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
assertNull(actualTask.getOwner());
|
||||
assertNotNull(actualTask.getCreated());
|
||||
|
@ -249,7 +253,7 @@ public class TaskServiceImplTest {
|
|||
task.setClassification(classification);
|
||||
task.setPrimaryObjRef(expectedObjectReference);
|
||||
task.setDescription("simply awesome task");
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTaskById(task.getId());
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(task.getId());
|
||||
doReturn(wb).when(workbasketServiceMock).getWorkbasketByKey(wb.getKey());
|
||||
doReturn(classification).when(classificationServiceMock).getClassification(classification.getKey(),
|
||||
classification.getDomain());
|
||||
|
@ -276,8 +280,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).insert(task);
|
||||
verify(taskMapperMock, times(1)).insert(task2);
|
||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
|
||||
assertNull(task.getOwner());
|
||||
|
@ -300,15 +304,15 @@ public class TaskServiceImplTest {
|
|||
InvalidWorkbasketException, InvalidArgumentException {
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
TaskImpl task = createUnitTestTask("12", "Task Name", "1");
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doReturn(task).when(cutSpy).getTask(task.getId());
|
||||
|
||||
try {
|
||||
cutSpy.createTask(task);
|
||||
} catch (TaskAlreadyExistException ex) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
throw ex;
|
||||
}
|
||||
|
@ -320,7 +324,7 @@ public class TaskServiceImplTest {
|
|||
TaskAlreadyExistException, TaskNotFoundException, InvalidWorkbasketException, InvalidArgumentException {
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
TaskImpl task = createUnitTestTask("", "dummyTask", "1");
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTaskById(task.getId());
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(task.getId());
|
||||
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(task.getWorkbasketKey(),
|
||||
WorkbasketAuthorization.APPEND);
|
||||
try {
|
||||
|
@ -331,8 +335,8 @@ public class TaskServiceImplTest {
|
|||
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getWorkbasketKey(),
|
||||
WorkbasketAuthorization.APPEND);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -344,7 +348,7 @@ public class TaskServiceImplTest {
|
|||
InvalidWorkbasketException, TaskAlreadyExistException, TaskNotFoundException, InvalidArgumentException {
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
TaskImpl task = createUnitTestTask("", "dumma-task", "1");
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTaskById(task.getId());
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(task.getId());
|
||||
doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock).getWorkbasketByKey(any());
|
||||
try {
|
||||
cutSpy.createTask(task);
|
||||
|
@ -352,8 +356,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(task.getWorkbasketKey());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -362,6 +366,7 @@ public class TaskServiceImplTest {
|
|||
@Test
|
||||
public void testClaimSuccessfulToOwner() throws Exception {
|
||||
TaskImpl expectedTask = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
doReturn(null).when(attachmentMapperMock).findAttachmentsByTaskId(expectedTask.getId());
|
||||
Mockito.doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
|
||||
|
||||
Thread.sleep(SLEEP_TIME); // to have different timestamps
|
||||
|
@ -375,10 +380,11 @@ public class TaskServiceImplTest {
|
|||
|
||||
verify(taskanaEngineImpl, times(2)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findById(expectedTask.getId());
|
||||
verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(expectedTask.getId());
|
||||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
|
||||
assertThat(acturalTask.getState(), equalTo(TaskState.CLAIMED));
|
||||
assertThat(acturalTask.getCreated(), not(equalTo(expectedTask.getModified())));
|
||||
|
@ -398,8 +404,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskanaEngineImpl, times(2)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findById(any());
|
||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -416,16 +422,18 @@ public class TaskServiceImplTest {
|
|||
task.setClaimed(new Timestamp(System.currentTimeMillis()));
|
||||
task.setOwner(CurrentUserContext.getUserid());
|
||||
doReturn(task).when(taskMapperMock).findById(task.getId());
|
||||
doReturn(null).when(attachmentMapperMock).findAttachmentsByTaskId(task.getId());
|
||||
doReturn(task).when(cutSpy).completeTask(task.getId(), isForced);
|
||||
|
||||
Task actualTask = cut.completeTask(task.getId());
|
||||
|
||||
verify(taskanaEngineImpl, times(2)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findById(task.getId());
|
||||
verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(task.getId());
|
||||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
|
||||
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
|
||||
assertThat(actualTask.getCreated(), not(equalTo(task.getModified())));
|
||||
|
@ -444,17 +452,17 @@ public class TaskServiceImplTest {
|
|||
task.setState(TaskState.CLAIMED);
|
||||
task.setClaimed(new Timestamp(System.currentTimeMillis()));
|
||||
task.setOwner(CurrentUserContext.getUserid());
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doReturn(task).when(cutSpy).getTask(task.getId());
|
||||
doNothing().when(taskMapperMock).update(task);
|
||||
|
||||
Task actualTask = cutSpy.completeTask(task.getId(), isForced);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTaskById(task.getId());
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(taskMapperMock, times(1)).update(task);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
|
||||
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
|
||||
assertThat(actualTask.getCreated(), not(equalTo(task.getModified())));
|
||||
|
@ -470,16 +478,16 @@ public class TaskServiceImplTest {
|
|||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
task.setState(TaskState.READY);
|
||||
task.setClaimed(null);
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doReturn(task).when(cutSpy).getTask(task.getId());
|
||||
|
||||
try {
|
||||
cutSpy.completeTask(task.getId(), isForced);
|
||||
} catch (InvalidStateException e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTaskById(task.getId());
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -493,16 +501,16 @@ public class TaskServiceImplTest {
|
|||
task.setOwner("Dummy-Owner-ID: 10");
|
||||
task.setState(TaskState.CLAIMED);
|
||||
task.setClaimed(new Timestamp(System.currentTimeMillis()));
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doReturn(task).when(cutSpy).getTask(task.getId());
|
||||
|
||||
try {
|
||||
cutSpy.completeTask(task.getId(), isForced);
|
||||
} catch (InvalidOwnerException e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTaskById(task.getId());
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -513,15 +521,15 @@ public class TaskServiceImplTest {
|
|||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
final boolean isForced = false;
|
||||
String taskId = "1";
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTaskById(taskId);
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(taskId);
|
||||
try {
|
||||
cutSpy.completeTask(taskId, isForced);
|
||||
} catch (InvalidOwnerException e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTaskById(taskId);
|
||||
verify(cutSpy, times(1)).getTask(taskId);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -537,17 +545,17 @@ public class TaskServiceImplTest {
|
|||
Thread.sleep(sleepTime);
|
||||
task.setState(TaskState.CLAIMED);
|
||||
task.setClaimed(new Timestamp(System.currentTimeMillis()));
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doReturn(task).when(cutSpy).getTask(task.getId());
|
||||
doNothing().when(taskMapperMock).update(task);
|
||||
|
||||
Task actualTask = cutSpy.completeTask(task.getId(), isForced);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTaskById(task.getId());
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(taskMapperMock, times(1)).update(task);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
|
||||
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
|
||||
assertThat(actualTask.getCreated(), not(equalTo(task.getModified())));
|
||||
|
@ -564,7 +572,7 @@ public class TaskServiceImplTest {
|
|||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
task.setState(TaskState.READY);
|
||||
task.setClaimed(null);
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doReturn(task).when(cutSpy).getTask(task.getId());
|
||||
TaskImpl claimedTask = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
// created and modify should be able to be different.
|
||||
Thread.sleep(sleepTime);
|
||||
|
@ -576,12 +584,12 @@ public class TaskServiceImplTest {
|
|||
Task actualTask = cutSpy.completeTask(task.getId(), isForced);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTaskById(task.getId());
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(cutSpy, times(1)).claim(task.getId(), isForced);
|
||||
verify(taskMapperMock, times(1)).update(claimedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
|
||||
assertThat(actualTask.getCreated(), not(equalTo(claimedTask.getModified())));
|
||||
assertThat(actualTask.getCompleted(), not(equalTo(null)));
|
||||
|
@ -599,7 +607,7 @@ public class TaskServiceImplTest {
|
|||
doReturn(destinationWorkbasket).when(workbasketServiceMock).getWorkbasketByKey(destinationWorkbasket.getKey());
|
||||
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
|
||||
doReturn(false).when(taskanaEngineConfigurationMock).isSecurityEnabled();
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doReturn(task).when(cutSpy).getTask(task.getId());
|
||||
doNothing().when(taskMapperMock).update(any());
|
||||
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasket.getKey(),
|
||||
WorkbasketAuthorization.APPEND);
|
||||
|
@ -618,8 +626,8 @@ public class TaskServiceImplTest {
|
|||
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(destinationWorkbasket.getKey());
|
||||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
|
||||
assertThat(actualTask.isRead(), equalTo(false));
|
||||
assertThat(actualTask.isTransferred(), equalTo(true));
|
||||
|
@ -636,7 +644,7 @@ public class TaskServiceImplTest {
|
|||
task.setRead(true);
|
||||
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
|
||||
doReturn(true).when(taskanaEngineConfigurationMock).isSecurityEnabled();
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doReturn(task).when(cutSpy).getTask(task.getId());
|
||||
doNothing().when(taskMapperMock).update(any());
|
||||
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasket.getKey(),
|
||||
WorkbasketAuthorization.APPEND);
|
||||
|
@ -654,8 +662,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
|
||||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
|
||||
assertThat(actualTask.isRead(), equalTo(false));
|
||||
assertThat(actualTask.isTransferred(), equalTo(true));
|
||||
|
@ -671,7 +679,7 @@ public class TaskServiceImplTest {
|
|||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock)
|
||||
.checkAuthorization(destinationWorkbasketKey, WorkbasketAuthorization.APPEND);
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doReturn(task).when(cutSpy).getTask(task.getId());
|
||||
|
||||
try {
|
||||
cutSpy.transfer(task.getId(), destinationWorkbasketKey);
|
||||
|
@ -680,8 +688,8 @@ public class TaskServiceImplTest {
|
|||
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketKey,
|
||||
WorkbasketAuthorization.APPEND);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -692,15 +700,15 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTaskById(task.getId());
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(task.getId());
|
||||
|
||||
try {
|
||||
cutSpy.transfer(task.getId(), "2");
|
||||
} catch (Exception e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -711,7 +719,7 @@ public class TaskServiceImplTest {
|
|||
String destinationWorkbasketKey = "2";
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doReturn(task).when(cutSpy).getTask(task.getId());
|
||||
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(destinationWorkbasketKey,
|
||||
WorkbasketAuthorization.APPEND);
|
||||
|
||||
|
@ -722,8 +730,8 @@ public class TaskServiceImplTest {
|
|||
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketKey,
|
||||
WorkbasketAuthorization.APPEND);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -734,7 +742,7 @@ public class TaskServiceImplTest {
|
|||
String destinationWorkbasketKey = "2";
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doReturn(task).when(cutSpy).getTask(task.getId());
|
||||
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasketKey,
|
||||
WorkbasketAuthorization.APPEND);
|
||||
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(task.getWorkbasketKey(),
|
||||
|
@ -749,8 +757,8 @@ public class TaskServiceImplTest {
|
|||
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getWorkbasketKey(),
|
||||
WorkbasketAuthorization.TRANSFER);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -760,7 +768,7 @@ public class TaskServiceImplTest {
|
|||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
task.setModified(null);
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doReturn(task).when(cutSpy).getTask(task.getId());
|
||||
doNothing().when(taskMapperMock).update(task);
|
||||
|
||||
Task actualTask = cutSpy.setTaskRead("1", true);
|
||||
|
@ -768,8 +776,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskMapperMock, times(1)).update(task);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
assertThat(actualTask.getModified(), not(equalTo(null)));
|
||||
assertThat(actualTask.isRead(), equalTo(true));
|
||||
}
|
||||
|
@ -779,14 +787,15 @@ public class TaskServiceImplTest {
|
|||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
task.setModified(null);
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTaskById(task.getId());
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(task.getId());
|
||||
|
||||
try {
|
||||
cutSpy.setTaskRead("1", true);
|
||||
} catch (Exception e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -796,14 +805,16 @@ public class TaskServiceImplTest {
|
|||
public void testGetTaskByIdWithExistingTask() throws TaskNotFoundException, ClassificationAlreadyExistException {
|
||||
Task expectedTask = createUnitTestTask("1", "DUMMY-TASK", "1");
|
||||
doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
|
||||
doReturn(null).when(attachmentMapperMock).findAttachmentsByTaskId(expectedTask.getId());
|
||||
|
||||
Task actualTask = cut.getTaskById(expectedTask.getId());
|
||||
Task actualTask = cut.getTask(expectedTask.getId());
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findById(expectedTask.getId());
|
||||
verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(expectedTask.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
assertThat(actualTask, equalTo(expectedTask));
|
||||
}
|
||||
|
||||
|
@ -813,13 +824,13 @@ public class TaskServiceImplTest {
|
|||
doThrow(TaskNotFoundException.class).when(taskMapperMock).findById(task.getId());
|
||||
|
||||
try {
|
||||
cut.getTaskById(task.getId());
|
||||
cut.getTask(task.getId());
|
||||
} catch (Exception e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findById(task.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -844,8 +855,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).findTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(any());
|
||||
|
||||
verifyNoMoreInteractions(taskMapperMock, taskanaEngineImpl, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
assertThat(actualResultList, equalTo(expectedResultList));
|
||||
}
|
||||
|
||||
|
@ -865,7 +876,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskMapperMock, taskanaEngineImpl, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
assertThat(actualResultList, equalTo(expectedResultList));
|
||||
assertThat(actualResultList.size(), equalTo(expectedResultList.size()));
|
||||
}
|
||||
|
@ -886,7 +898,7 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).findTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(any());
|
||||
verifyNoMoreInteractions(taskMapperMock, taskanaEngineImpl, workbasketServiceMock);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskMapperMock, taskanaEngineImpl, workbasketServiceMock);
|
||||
|
||||
assertThat(actualResultList, equalTo(expectedResultList));
|
||||
assertThat(actualResultList.size(), equalTo(expectedResultList.size()));
|
||||
|
|
|
@ -124,7 +124,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
|
||||
TaskanaEngine te2 = taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
|
||||
Task resultTask = taskServiceImpl2.getTaskById(task.getId());
|
||||
Task resultTask = taskServiceImpl2.getTask(task.getId());
|
||||
Assert.assertNotNull(resultTask);
|
||||
}
|
||||
|
||||
|
@ -151,11 +151,11 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
task.setClassification(classification);
|
||||
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
|
||||
taskServiceImpl.createTask(task);
|
||||
taskServiceImpl.getTaskById(task.getId());
|
||||
taskServiceImpl.getTask(task.getId());
|
||||
|
||||
TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
|
||||
taskServiceImpl2.getTaskById(wb.getId());
|
||||
taskServiceImpl2.getTask(wb.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -498,7 +498,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
|
||||
task = taskServiceImpl.createTask(task);
|
||||
|
||||
Task task2 = taskServiceImpl.getTaskById(task.getId());
|
||||
Task task2 = taskServiceImpl.getTask(task.getId());
|
||||
// skanaEngineImpl.getSqlSession().commit(); // needed so that the change is visible in the other session
|
||||
|
||||
Assert.assertNotNull(task2);
|
||||
|
|
|
@ -136,11 +136,11 @@ public class TaskServiceImplIntExplicitTest {
|
|||
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
|
||||
task = taskServiceImpl.createTask(task);
|
||||
connection.commit();
|
||||
taskServiceImpl.getTaskById(workbasket.getId());
|
||||
taskServiceImpl.getTask(workbasket.getId());
|
||||
|
||||
TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
|
||||
taskServiceImpl2.getTaskById(workbasket.getId());
|
||||
taskServiceImpl2.getTask(workbasket.getId());
|
||||
connection.commit();
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
|
||||
TaskanaEngine te2 = taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
|
||||
Task resultTask = taskServiceImpl2.getTaskById(task.getId());
|
||||
Task resultTask = taskServiceImpl2.getTask(task.getId());
|
||||
Assert.assertNotNull(resultTask);
|
||||
connection.commit();
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ExampleBootstrap {
|
|||
System.out.println("---------------------------> Task started: " + task.getId());
|
||||
taskService.claim(task.getId());
|
||||
System.out.println(
|
||||
"---------------------------> Task claimed: " + taskService.getTaskById(task.getId()).getOwner());
|
||||
"---------------------------> Task claimed: " + taskService.getTask(task.getId()).getOwner());
|
||||
taskService.completeTask(task.getId(), true);
|
||||
System.out.println("---------------------------> Task completed");
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class TaskController {
|
|||
@RequestMapping(value = "/{taskId}")
|
||||
public ResponseEntity<Task> getTask(@PathVariable(value = "taskId") String taskId) {
|
||||
try {
|
||||
Task task = taskService.getTaskById(taskId);
|
||||
Task task = taskService.getTask(taskId);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(task);
|
||||
} catch (TaskNotFoundException e) {
|
||||
logger.error("The searched Task couldn´t be found or does not exist.", e);
|
||||
|
@ -89,7 +89,7 @@ public class TaskController {
|
|||
// TODO verify user
|
||||
try {
|
||||
taskService.claim(taskId);
|
||||
Task updatedTask = taskService.getTaskById(taskId);
|
||||
Task updatedTask = taskService.getTask(taskId);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(updatedTask);
|
||||
} catch (TaskNotFoundException e) {
|
||||
logger.error("The given Task coundn´t be found/claimd or does not Exist.", e);
|
||||
|
@ -107,7 +107,7 @@ public class TaskController {
|
|||
public ResponseEntity<Task> completeTask(@PathVariable String taskId) {
|
||||
try {
|
||||
taskService.completeTask(taskId, true);
|
||||
Task updatedTask = taskService.getTaskById(taskId);
|
||||
Task updatedTask = taskService.getTask(taskId);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(updatedTask);
|
||||
} catch (TaskNotFoundException e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
|
||||
|
|
Loading…
Reference in New Issue