TSK-141: Get Classification by Key+Domain in extra Query.
This commit is contained in:
parent
d116b138d1
commit
fff74f974c
|
@ -24,6 +24,14 @@ public interface Attachment {
|
|||
*/
|
||||
String getTaskId();
|
||||
|
||||
/**
|
||||
* Sets the taskId of the attachment where it should be appended to.
|
||||
*
|
||||
* @param taskId
|
||||
* id of the reference task
|
||||
*/
|
||||
void setTaskId(String taskId);
|
||||
|
||||
/**
|
||||
* Returns the time when the attachment was created.
|
||||
*
|
||||
|
@ -39,19 +47,26 @@ public interface Attachment {
|
|||
Timestamp getModified();
|
||||
|
||||
/**
|
||||
* Returns the classification of the attachment.
|
||||
* Returns the classificationKey for the mapping.
|
||||
*
|
||||
* @return the {@link Classification} of this attachment
|
||||
* @return classificationKey key for the correct mapping.
|
||||
*/
|
||||
Classification getClassification();
|
||||
String getClassificationKey();
|
||||
|
||||
/**
|
||||
* Set the classification for this attachment.
|
||||
* Sets the classificationKey for the mapping.
|
||||
*
|
||||
* @param classification
|
||||
* the {@link Classification} for this attachment
|
||||
* @param classificationKey
|
||||
* key for the correct mapping.
|
||||
*/
|
||||
void setClassification(Classification classification);
|
||||
void setClassificationKey(String classificationKey);
|
||||
|
||||
/**
|
||||
* Returns the classificationsummary of the attachment.
|
||||
*
|
||||
* @return the {@link ClassificationSummary} of this attachment
|
||||
*/
|
||||
ClassificationSummary getClassificationSummary();
|
||||
|
||||
/**
|
||||
* Returns the {@link ObjectReference primaryObjectReference} of the attachment.
|
||||
|
@ -112,5 +127,4 @@ public interface Attachment {
|
|||
* a {@link Map} that contains the custom attributes of the attachment as key, value pairs
|
||||
*/
|
||||
void setCustomAttributes(Map<String, Object> customAttributes);
|
||||
|
||||
}
|
||||
|
|
|
@ -174,9 +174,11 @@ public interface TaskService {
|
|||
* 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 work basket.
|
||||
* @throws ClassificationNotFoundException
|
||||
* if a single Classification can not be found for a task which is returned
|
||||
*/
|
||||
List<Task> getTasksByWorkbasketKeyAndState(String workbasketKey, TaskState taskState)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException;
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException;
|
||||
|
||||
/**
|
||||
* Getting a short summary of all tasks in a specific work basket.
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Collections;
|
|||
import java.util.Map;
|
||||
|
||||
import pro.taskana.Attachment;
|
||||
import pro.taskana.Classification;
|
||||
import pro.taskana.ClassificationSummary;
|
||||
import pro.taskana.model.ObjectReference;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,8 @@ public class AttachmentImpl implements Attachment {
|
|||
private String taskId;
|
||||
private Timestamp created;
|
||||
private Timestamp modified;
|
||||
private Classification classification;
|
||||
private String classificationKey;
|
||||
private ClassificationSummary classificationSummary;
|
||||
private ObjectReference objectReference;
|
||||
private String channel;
|
||||
private Timestamp received;
|
||||
|
@ -42,6 +43,7 @@ public class AttachmentImpl implements Attachment {
|
|||
return taskId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTaskId(String taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
@ -65,13 +67,22 @@ public class AttachmentImpl implements Attachment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Classification getClassification() {
|
||||
return classification;
|
||||
public String getClassificationKey() {
|
||||
return classificationKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClassification(Classification classification) {
|
||||
this.classification = classification;
|
||||
public void setClassificationKey(String classificationKey) {
|
||||
this.classificationKey = classificationKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassificationSummary getClassificationSummary() {
|
||||
return classificationSummary;
|
||||
}
|
||||
|
||||
public void setClassificationSummary(ClassificationSummary classificationSummary) {
|
||||
this.classificationSummary = classificationSummary;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -125,8 +136,8 @@ public class AttachmentImpl implements Attachment {
|
|||
builder.append(created);
|
||||
builder.append(", modified=");
|
||||
builder.append(modified);
|
||||
builder.append(", classification=");
|
||||
builder.append(classification);
|
||||
builder.append(", classificationKey=");
|
||||
builder.append(classificationKey);
|
||||
builder.append(", objectReference=");
|
||||
builder.append(objectReference);
|
||||
builder.append(", channel=");
|
||||
|
@ -138,5 +149,4 @@ public class AttachmentImpl implements Attachment {
|
|||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,12 +5,14 @@ import java.time.Duration;
|
|||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.Attachment;
|
||||
import pro.taskana.Classification;
|
||||
import pro.taskana.ClassificationSummary;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskQuery;
|
||||
import pro.taskana.TaskService;
|
||||
|
@ -45,7 +47,6 @@ import pro.taskana.security.CurrentUserContext;
|
|||
public class TaskServiceImpl implements TaskService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskServiceImpl.class);
|
||||
private static final String ID_PREFIX_OBJECT_REFERENCE = "ORI";
|
||||
private static final String ID_PREFIX_ATTACHMENT = "TAI";
|
||||
private static final String ID_PREFIX_TASK = "TKI";
|
||||
private static final String ID_PREFIX_BUSINESS_PROCESS = "BPI";
|
||||
|
@ -54,7 +55,6 @@ public class TaskServiceImpl implements TaskService {
|
|||
private WorkbasketService workbasketService;
|
||||
private ClassificationServiceImpl classificationService;
|
||||
private TaskMapper taskMapper;
|
||||
private ObjectReferenceMapper objectReferenceMapper;
|
||||
private AttachmentMapper attachmentMapper;
|
||||
|
||||
public TaskServiceImpl(TaskanaEngine taskanaEngine, TaskMapper taskMapper,
|
||||
|
@ -63,7 +63,6 @@ public class TaskServiceImpl implements TaskService {
|
|||
this.taskanaEngine = taskanaEngine;
|
||||
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
|
||||
this.taskMapper = taskMapper;
|
||||
this.objectReferenceMapper = objectReferenceMapper;
|
||||
this.workbasketService = taskanaEngineImpl.getWorkbasketService();
|
||||
this.attachmentMapper = attachmentMapper;
|
||||
this.classificationService = (ClassificationServiceImpl) taskanaEngineImpl.getClassificationService();
|
||||
|
@ -195,17 +194,20 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Task getTask(String id) throws TaskNotFoundException {
|
||||
public Task getTask(String id) throws TaskNotFoundException, SystemException {
|
||||
LOGGER.debug("entry to getTaskById(id = {})", id);
|
||||
TaskImpl result = null;
|
||||
TaskImpl resultTask = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
result = taskMapper.findById(id);
|
||||
if (result != null) {
|
||||
setAttachments(result);
|
||||
Classification classification;
|
||||
resultTask = taskMapper.findById(id);
|
||||
if (resultTask != null) {
|
||||
organizeAttachments(resultTask);
|
||||
|
||||
// TODO - DELETE getting task-Classification and enable it in
|
||||
// organizeTaskAttachmentClassificationSummaries();
|
||||
try {
|
||||
classification = this.classificationService.getClassificationByTask(result);
|
||||
Classification classification = this.classificationService.getClassificationByTask(resultTask);
|
||||
resultTask.setClassification(classification);
|
||||
} catch (ClassificationNotFoundException e) {
|
||||
LOGGER.debug(
|
||||
"getTask(taskId = {}) caught a ClassificationNotFoundException when attemptin to get "
|
||||
|
@ -214,16 +216,15 @@ public class TaskServiceImpl implements TaskService {
|
|||
throw new SystemException(
|
||||
"TaskService.getTask could not find the classification associated to " + id);
|
||||
}
|
||||
|
||||
result.setClassification(classification);
|
||||
return result;
|
||||
organizeTaskAttachmentClassificationSummaries(resultTask);
|
||||
return resultTask;
|
||||
} else {
|
||||
LOGGER.warn("Method getTaskById() didn't find task with id {}. Throwing TaskNotFoundException", id);
|
||||
throw new TaskNotFoundException(id);
|
||||
}
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
LOGGER.debug("exit from getTaskById(). Returning result {} ", result);
|
||||
LOGGER.debug("exit from getTaskById(). Returning result {} ", resultTask);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,7 +294,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
|
||||
@Override
|
||||
public List<Task> getTasksByWorkbasketKeyAndState(String workbasketKey, TaskState taskState)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException {
|
||||
LOGGER.debug("entry to getTasksByWorkbasketKeyAndState(workbasketKey = {}, taskState = {})", workbasketKey,
|
||||
taskState);
|
||||
List<Task> results = new ArrayList<>();
|
||||
|
@ -301,9 +302,12 @@ public class TaskServiceImpl implements TaskService {
|
|||
taskanaEngineImpl.openConnection();
|
||||
workbasketService.checkAuthorization(workbasketKey, WorkbasketAuthorization.READ);
|
||||
List<TaskImpl> tasks = taskMapper.findTasksByWorkbasketIdAndState(workbasketKey, taskState);
|
||||
tasks.stream().forEach(t -> {
|
||||
results.add(t);
|
||||
});
|
||||
for (TaskImpl taskImpl : tasks) {
|
||||
Classification classification = classificationService.getClassification(taskImpl.getClassificationKey(),
|
||||
taskImpl.getDomain());
|
||||
taskImpl.setClassification(classification);
|
||||
results.add(taskImpl);
|
||||
}
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
@ -440,15 +444,62 @@ public class TaskServiceImpl implements TaskService {
|
|||
return new AttachmentImpl();
|
||||
}
|
||||
|
||||
private void setAttachments(TaskImpl result) {
|
||||
List<AttachmentImpl> attachmentImpls = attachmentMapper.findAttachmentsByTaskId(result.getId());
|
||||
List<Attachment> attachments = new ArrayList<>();
|
||||
if (attachmentImpls != null && !attachmentImpls.isEmpty()) {
|
||||
for (AttachmentImpl attImpl : attachmentImpls) {
|
||||
attachments.add(attImpl);
|
||||
private void organizeTaskAttachmentClassificationSummaries(TaskImpl taskImpl) {
|
||||
List<Attachment> attachments = taskImpl.getAttachments();
|
||||
List<ClassificationSummary> classificationSummaries;
|
||||
List<String> classificationKeyList = new ArrayList<>();
|
||||
String[] classificationKeys;
|
||||
String domain = taskImpl.getDomain();
|
||||
|
||||
if (attachments != null && !attachments.isEmpty()) {
|
||||
for (Attachment attachment : attachments) {
|
||||
if (!classificationKeyList.contains(attachment.getClassificationKey())) {
|
||||
classificationKeyList.add(attachment.getClassificationKey());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
attachments = new ArrayList<>();
|
||||
}
|
||||
result.setAttachments(attachments);
|
||||
classificationKeyList.add(taskImpl.getClassificationKey());
|
||||
classificationKeys = classificationKeyList.toArray(new String[0]);
|
||||
|
||||
try {
|
||||
classificationSummaries = classificationService.createClassificationQuery()
|
||||
.domain(domain)
|
||||
.key(classificationKeys)
|
||||
.list();
|
||||
for (Attachment attachment : attachments) {
|
||||
Optional<ClassificationSummary> summary = classificationSummaries.stream()
|
||||
.filter(cs -> cs.getKey().equals(attachment.getClassificationKey()))
|
||||
.findFirst();
|
||||
if (summary.isPresent()) {
|
||||
((AttachmentImpl) attachment).setClassificationSummary(summary.get());
|
||||
}
|
||||
}
|
||||
|
||||
// TODO - Change Task.Classification to ClassificationSummary and enable this snippet.
|
||||
// Optional<ClassificationSummary> summary = classificationSummaries.stream()
|
||||
// .filter(cs -> cs.getKey().equals(taskImpl.getClassificationKey()))
|
||||
// .findFirst();
|
||||
// if (summary.isPresent()) {
|
||||
// taskImpl.setClassification(summary.get());
|
||||
// }
|
||||
} catch (NotAuthorizedException e) {
|
||||
LOGGER.warn(
|
||||
"Throwing NotAuthorizedException when getting Classifications of the Task-Attachments. TaskId={}",
|
||||
taskImpl.getId());
|
||||
}
|
||||
}
|
||||
|
||||
private void organizeAttachments(TaskImpl taskImpl) {
|
||||
List<Attachment> attachments = new ArrayList<>();
|
||||
List<AttachmentImpl> attachmentImpls;
|
||||
|
||||
attachmentImpls = attachmentMapper.findAttachmentsByTaskId(taskImpl.getId());
|
||||
if (attachmentImpls != null && !attachmentImpls.isEmpty()) {
|
||||
attachments.addAll(attachmentImpls);
|
||||
}
|
||||
taskImpl.setAttachments(attachments);
|
||||
}
|
||||
|
||||
private void validateObjectReference(ObjectReference objRef, String objRefType, String objName)
|
||||
|
@ -481,7 +532,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
for (Attachment attachment : attachments) {
|
||||
ObjectReference objRef = attachment.getObjectReference();
|
||||
validateObjectReference(objRef, "ObjectReference", "Attachment");
|
||||
if (attachment.getClassification() == null) {
|
||||
if (attachment.getClassificationSummary() == null) {
|
||||
throw new InvalidArgumentException("Classification of attachment " + attachment + " must not be null");
|
||||
}
|
||||
}
|
||||
|
@ -548,5 +599,4 @@ public class TaskServiceImpl implements TaskService {
|
|||
Timestamp now = new Timestamp(System.currentTimeMillis());
|
||||
newTaskImpl.setModified(now);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,14 +4,12 @@ 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;
|
||||
|
||||
|
@ -20,10 +18,8 @@ import pro.taskana.impl.persistence.MapTypeHandler;
|
|||
*/
|
||||
public interface AttachmentMapper {
|
||||
|
||||
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}, "
|
||||
+ "VALUES (#{att.id}, #{att.taskId}, #{att.created}, #{att.modified}, #{att.classificationSummary.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);
|
||||
|
||||
|
@ -35,8 +31,7 @@ public interface AttachmentMapper {
|
|||
@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 = "classificationKey", column = "CLASSIFICATION_KEY"),
|
||||
@Result(property = "objectReference.company", column = "REF_COMPANY"),
|
||||
@Result(property = "objectReference.system", column = "REF_SYSTEM"),
|
||||
@Result(property = "objectReference.systemInstance", column = "REF_INSTANCE"),
|
||||
|
|
|
@ -18,7 +18,7 @@ import pro.taskana.impl.ClassificationSummaryImpl;
|
|||
*/
|
||||
public interface ClassificationMapper {
|
||||
|
||||
String VALID_UNTIL = "9999-12-31";
|
||||
String VALID_UNTIL_MAX = "9999-12-31";
|
||||
|
||||
@Select("SELECT ID, KEY, PARENT_CLASSIFICATION_KEY, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, APPLICATION_ENTRY_POINT, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL "
|
||||
+ "FROM CLASSIFICATION "
|
||||
|
@ -51,34 +51,6 @@ public interface ClassificationMapper {
|
|||
ClassificationImpl findByKeyAndDomain(@Param("key") String key, @Param("domain") String domain,
|
||||
@Param("valid_until") Date validUntil);
|
||||
|
||||
@Select("SELECT ID, KEY, PARENT_CLASSIFICATION_KEY, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, APPLICATION_ENTRY_POINT, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL "
|
||||
+ "FROM CLASSIFICATION "
|
||||
+ "WHERE ID = #{id} ")
|
||||
@Results({ @Result(property = "id", column = "ID"),
|
||||
@Result(property = "key", column = "KEY"),
|
||||
@Result(property = "parentClassificationKey", column = "PARENT_CLASSIFICATION_KEY"),
|
||||
@Result(property = "category", column = "CATEGORY"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "isValidInDomain", column = "VALID_IN_DOMAIN"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "priority", column = "PRIORITY"),
|
||||
@Result(property = "serviceLevel", column = "SERVICE_LEVEL"),
|
||||
@Result(property = "applicationEntryPoint", column = "APPLICATION_ENTRY_POINT"),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "validFrom", column = "VALID_FROM"),
|
||||
@Result(property = "validUntil", column = "VALID_UNTIL") })
|
||||
ClassificationImpl findById(@Param("id") String id);
|
||||
|
||||
@Insert("INSERT INTO CLASSIFICATION (ID, KEY, PARENT_CLASSIFICATION_KEY, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, APPLICATION_ENTRY_POINT, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL) VALUES (#{classification.id}, #{classification.key}, #{classification.parentClassificationKey}, #{classification.category}, #{classification.type}, #{classification.domain}, #{classification.isValidInDomain}, #{classification.created}, #{classification.name}, #{classification.description}, #{classification.priority}, #{classification.serviceLevel}, #{classification.applicationEntryPoint}, #{classification.custom1}, #{classification.custom2}, #{classification.custom3}, #{classification.custom4}, #{classification.custom5}, #{classification.custom6}, #{classification.custom7}, #{classification.custom8}, #{classification.validFrom}, #{classification.validUntil})")
|
||||
void insert(@Param("classification") ClassificationImpl classification);
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.util.Map;
|
|||
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.One;
|
||||
import org.apache.ibatis.annotations.Options;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Result;
|
||||
|
@ -15,7 +14,6 @@ import org.apache.ibatis.annotations.Select;
|
|||
import org.apache.ibatis.annotations.Update;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import pro.taskana.Classification;
|
||||
import pro.taskana.impl.TaskImpl;
|
||||
import pro.taskana.impl.persistence.MapTypeHandler;
|
||||
import pro.taskana.model.DueWorkbasketCounter;
|
||||
|
@ -27,10 +25,6 @@ import pro.taskana.model.TaskSummary;
|
|||
*/
|
||||
public interface TaskMapper {
|
||||
|
||||
String OBJECTREFERENCEMAPPER_FINDBYID = "pro.taskana.model.mappings.ObjectReferenceMapper.findById";
|
||||
String CLASSIFICATION_FINDBYKEYANDDOMAIN = "pro.taskana.model.mappings.ClassificationMapper.findByKeyAndDomain";
|
||||
String CLASSIFICATION_FINDBYID = "pro.taskana.model.mappings.ClassificationMapper.findById";
|
||||
|
||||
@Select("SELECT ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, NOTE, PRIORITY, STATE, CLASSIFICATION_KEY, WORKBASKET_KEY, DOMAIN, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, OWNER, POR_COMPANY, POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 "
|
||||
+ "FROM TASK "
|
||||
+ "WHERE ID = #{id}")
|
||||
|
@ -75,9 +69,9 @@ public interface TaskMapper {
|
|||
})
|
||||
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);
|
||||
|
||||
|
@ -111,8 +105,6 @@ public interface TaskMapper {
|
|||
@Result(property = "priority", column = "PRIORITY"),
|
||||
@Result(property = "state", column = "STATE"),
|
||||
@Result(property = "workbasketKey", column = "WORKBASKET_KEY"),
|
||||
@Result(property = "classification", column = "CLASSIFICATION_KEY", javaType = Classification.class,
|
||||
one = @One(select = CLASSIFICATION_FINDBYKEYANDDOMAIN)),
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "owner", column = "OWNER"),
|
||||
@Result(property = "primaryObjRef.company", column = "POR_COMPANY"),
|
||||
|
@ -133,7 +125,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);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public interface WorkbasketMapper {
|
|||
@Result(property = "orgLevel1", column = "ORG_LEVEL_1"),
|
||||
@Result(property = "orgLevel2", column = "ORG_LEVEL_2"),
|
||||
@Result(property = "orgLevel3", column = "ORG_LEVEL_3"),
|
||||
@Result(property = "orgLevel4", column = "ORG_LEVEL_4")})
|
||||
@Result(property = "orgLevel4", column = "ORG_LEVEL_4") })
|
||||
WorkbasketImpl findById(@Param("id") String id);
|
||||
|
||||
@Select("SELECT ID, KEY, CREATED, MODIFIED, NAME, DOMAIN, TYPE, DESCRIPTION, OWNER, CUSTOM_1 ,CUSTOM_2 ,CUSTOM_3 ,CUSTOM_4 ,ORG_LEVEL_1 ,ORG_LEVEL_2 ,ORG_LEVEL_3 ,ORG_LEVEL_4 FROM WORKBASKET WHERE KEY = #{key}")
|
||||
|
@ -64,7 +64,7 @@ public interface WorkbasketMapper {
|
|||
@Result(property = "orgLevel1", column = "ORG_LEVEL_1"),
|
||||
@Result(property = "orgLevel2", column = "ORG_LEVEL_2"),
|
||||
@Result(property = "orgLevel3", column = "ORG_LEVEL_3"),
|
||||
@Result(property = "orgLevel4", column = "ORG_LEVEL_4")})
|
||||
@Result(property = "orgLevel4", column = "ORG_LEVEL_4") })
|
||||
WorkbasketImpl findByKey(@Param("key") String key);
|
||||
|
||||
@Select("SELECT * FROM WORKBASKET WHERE id IN (SELECT TARGET_ID FROM DISTRIBUTION_TARGETS WHERE SOURCE_ID = #{id})")
|
||||
|
@ -80,8 +80,7 @@ public interface WorkbasketMapper {
|
|||
@Result(property = "orgLevel1", column = "ORG_LEVEL_1"),
|
||||
@Result(property = "orgLevel2", column = "ORG_LEVEL_2"),
|
||||
@Result(property = "orgLevel3", column = "ORG_LEVEL_3"),
|
||||
@Result(property = "orgLevel4", column = "ORG_LEVEL_4")})
|
||||
|
||||
@Result(property = "orgLevel4", column = "ORG_LEVEL_4") })
|
||||
List<WorkbasketSummary> findByDistributionTargets(@Param("id") String id);
|
||||
|
||||
@Select("SELECT * FROM WORKBASKET ORDER BY id")
|
||||
|
@ -96,7 +95,7 @@ public interface WorkbasketMapper {
|
|||
@Result(property = "orgLevel1", column = "ORG_LEVEL_1"),
|
||||
@Result(property = "orgLevel2", column = "ORG_LEVEL_2"),
|
||||
@Result(property = "orgLevel3", column = "ORG_LEVEL_3"),
|
||||
@Result(property = "orgLevel4", column = "ORG_LEVEL_4")})
|
||||
@Result(property = "orgLevel4", column = "ORG_LEVEL_4") })
|
||||
List<WorkbasketSummary> findAll();
|
||||
|
||||
@Select("<script>SELECT W.ID, W.KEY, W.NAME, W.DESCRIPTION, W.OWNER, W.DOMAIN, W.TYPE, W.ORG_LEVEL_1, W.ORG_LEVEL_2, W.ORG_LEVEL_3, W.ORG_LEVEL_4 FROM WORKBASKET AS W "
|
||||
|
@ -130,7 +129,7 @@ public interface WorkbasketMapper {
|
|||
@Result(property = "orgLevel1", column = "ORG_LEVEL_1"),
|
||||
@Result(property = "orgLevel2", column = "ORG_LEVEL_2"),
|
||||
@Result(property = "orgLevel3", column = "ORG_LEVEL_3"),
|
||||
@Result(property = "orgLevel4", column = "ORG_LEVEL_4")})
|
||||
@Result(property = "orgLevel4", column = "ORG_LEVEL_4") })
|
||||
List<WorkbasketSummary> findByPermission(@Param("authorizations") List<WorkbasketAuthorization> authorizations,
|
||||
@Param("accessId") String accessId);
|
||||
|
||||
|
@ -143,5 +142,4 @@ public interface WorkbasketMapper {
|
|||
|
||||
@Delete("DELETE FROM WORKBASKET where id = #{id}")
|
||||
void delete(@Param("id") String id);
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ import pro.taskana.TaskanaEngine.ConnectionManagementMode;
|
|||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.database.TestDataGenerator;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.impl.AttachmentImpl;
|
||||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
import pro.taskana.impl.configuration.DBCleaner;
|
||||
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
||||
|
@ -68,10 +70,15 @@ public abstract class AbstractAccTest {
|
|||
|
||||
protected Attachment createAttachment(String classificationKey, ObjectReference objRef,
|
||||
String channel, String receivedDate, Map<String, Object> customAttributes)
|
||||
throws ClassificationNotFoundException {
|
||||
throws ClassificationNotFoundException, NotAuthorizedException {
|
||||
Attachment attachment = taskanaEngine.getTaskService().newAttachment();
|
||||
attachment.setClassification(
|
||||
taskanaEngine.getClassificationService().getClassification(classificationKey, "DOMAIN_A"));
|
||||
((AttachmentImpl) attachment).setClassificationSummary(
|
||||
taskanaEngine.getClassificationService()
|
||||
.createClassificationQuery()
|
||||
.key(classificationKey)
|
||||
.domain("DOMAIN_A")
|
||||
.single());
|
||||
attachment.setClassificationKey(classificationKey);
|
||||
attachment.setObjectReference(objRef);
|
||||
attachment.setChannel(channel);
|
||||
Timestamp receivedTimestamp = null;
|
||||
|
|
|
@ -16,6 +16,7 @@ import pro.taskana.TaskService;
|
|||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.ConcurrencyException;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
|
@ -38,7 +39,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testCreateSimpleManualTask()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
|
@ -70,21 +71,22 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testCreateExternalTaskWithAttachment()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
|
||||
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||
ConcurrencyException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task newTask = taskService.newTask();
|
||||
newTask.setClassificationKey("L12010");
|
||||
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||
newTask.setWorkbasketKey("USER_1_1");
|
||||
newTask.addAttachment(createAttachment("DOKTYP_DEFAULT",
|
||||
createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId",
|
||||
"12345678901234567890123456789012345678901234567890"),
|
||||
"E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
|
||||
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||
newTask.setWorkbasketKey("USER_1_1");
|
||||
Task createdTask = taskService.createTask(newTask);
|
||||
|
||||
assertNotNull(createdTask.getId());
|
||||
|
@ -97,13 +99,13 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
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).getClassificationSummary());
|
||||
assertNotNull(readTask.getAttachments().get(0).getObjectReference());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testCreateExternalTaskWithMultipleAttachments()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
|
@ -140,7 +142,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testThrowsExceptionIfAttachmentIsInvalid()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
|
@ -222,7 +224,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testUseCustomNameIfSetForNewTask()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
|
@ -242,7 +244,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testUseClassificationMetadataFromCorrectDomainForNewTask()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
|
@ -262,7 +264,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void testGetExceptionIfWorkbasketDoesNotExist()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
|
@ -278,7 +280,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testGetExceptionIfAppendIsNotPermitted()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
|
@ -294,7 +296,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testThrowsExceptionIfMandatoryPrimaryObjectReferenceIsNotSetOrIncomplete()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
|
@ -381,7 +383,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = { "group_1" })
|
||||
@Test
|
||||
public void testSetDomainFromWorkbasket()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
|
@ -27,6 +28,7 @@ import pro.taskana.model.TaskState;
|
|||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TaskQueryImplTest {
|
||||
|
||||
@InjectMocks
|
||||
private TaskQueryImpl taskQueryImpl;
|
||||
|
||||
@Mock
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -95,6 +96,12 @@ public class TaskServiceImplTest {
|
|||
@Mock
|
||||
private AttachmentMapper attachmentMapperMock;
|
||||
|
||||
@Mock
|
||||
private ClassificationQueryImpl classificationQueryImplMock;
|
||||
|
||||
@Mock
|
||||
private SqlSession sqlSessionMock;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
@ -133,7 +140,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock,
|
||||
classificationServiceMock);
|
||||
|
||||
assertNull(actualTask.getOwner());
|
||||
|
@ -175,7 +183,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock,
|
||||
classificationServiceMock);
|
||||
assertNull(actualTask.getOwner());
|
||||
assertNotNull(actualTask.getCreated());
|
||||
|
@ -221,7 +230,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock,
|
||||
classificationServiceMock);
|
||||
assertNull(actualTask.getOwner());
|
||||
assertNotNull(actualTask.getCreated());
|
||||
|
@ -282,7 +292,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).insert(task2);
|
||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock,
|
||||
classificationServiceMock);
|
||||
|
||||
assertNull(task.getOwner());
|
||||
|
@ -313,7 +324,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock,
|
||||
classificationServiceMock);
|
||||
throw ex;
|
||||
}
|
||||
|
@ -337,7 +349,8 @@ public class TaskServiceImplTest {
|
|||
WorkbasketAuthorization.APPEND);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock,
|
||||
classificationServiceMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -358,7 +371,8 @@ public class TaskServiceImplTest {
|
|||
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(task.getWorkbasketKey());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock,
|
||||
classificationServiceMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -369,12 +383,14 @@ public class TaskServiceImplTest {
|
|||
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
|
||||
String expectedOwner = "John Does";
|
||||
|
||||
PowerMockito.mockStatic(CurrentUserContext.class);
|
||||
Mockito.when(CurrentUserContext.getUserid()).thenReturn(expectedOwner);
|
||||
doReturn(classificationQueryImplMock).when(classificationServiceMock).createClassificationQuery();
|
||||
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).domain(any());
|
||||
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).key(any());
|
||||
doReturn(new ArrayList<>()).when(classificationQueryImplMock).list();
|
||||
|
||||
// Mockito.doReturn(expectedOwner).when(currentUserContext).getUserid();
|
||||
Task acturalTask = cut.claim(expectedTask.getId(), true);
|
||||
|
@ -382,10 +398,15 @@ public class TaskServiceImplTest {
|
|||
verify(taskanaEngineImpl, times(2)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findById(expectedTask.getId());
|
||||
verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(expectedTask.getId());
|
||||
verify(classificationServiceMock, times(1)).createClassificationQuery();
|
||||
verify(classificationQueryImplMock, times(1)).domain(any());
|
||||
verify(classificationQueryImplMock, times(1)).key(any());
|
||||
verify(classificationQueryImplMock, times(1)).list();
|
||||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
|
||||
assertThat(acturalTask.getState(), equalTo(TaskState.CLAIMED));
|
||||
assertThat(acturalTask.getCreated(), not(equalTo(expectedTask.getModified())));
|
||||
|
@ -406,7 +427,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).findById(any());
|
||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -426,16 +448,25 @@ public class TaskServiceImplTest {
|
|||
doReturn(task).when(taskMapperMock).findById(task.getId());
|
||||
doReturn(null).when(attachmentMapperMock).findAttachmentsByTaskId(task.getId());
|
||||
doReturn(task).when(cutSpy).completeTask(task.getId(), isForced);
|
||||
doReturn(classificationQueryImplMock).when(classificationServiceMock).createClassificationQuery();
|
||||
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).domain(any());
|
||||
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).key(any());
|
||||
doReturn(new ArrayList<>()).when(classificationQueryImplMock).list();
|
||||
|
||||
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(classificationServiceMock, times(1)).createClassificationQuery();
|
||||
verify(classificationQueryImplMock, times(1)).domain(any());
|
||||
verify(classificationQueryImplMock, times(1)).key(any());
|
||||
verify(classificationQueryImplMock, times(1)).list();
|
||||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
|
||||
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
|
||||
assertThat(actualTask.getCreated(), not(equalTo(task.getModified())));
|
||||
|
@ -465,7 +496,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).update(task);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
|
||||
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
|
||||
assertThat(actualTask.getCreated(), not(equalTo(task.getModified())));
|
||||
|
@ -490,7 +522,8 @@ public class TaskServiceImplTest {
|
|||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -513,7 +546,8 @@ public class TaskServiceImplTest {
|
|||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -532,7 +566,8 @@ public class TaskServiceImplTest {
|
|||
verify(cutSpy, times(1)).getTask(taskId);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -559,7 +594,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).update(task);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
|
||||
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
|
||||
assertThat(actualTask.getCreated(), not(equalTo(task.getModified())));
|
||||
|
@ -594,7 +630,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).update(claimedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
|
||||
assertThat(actualTask.getCreated(), not(equalTo(claimedTask.getModified())));
|
||||
assertThat(actualTask.getCompleted(), not(equalTo(null)));
|
||||
|
@ -632,7 +669,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
|
||||
assertThat(actualTask.isRead(), equalTo(false));
|
||||
assertThat(actualTask.isTransferred(), equalTo(true));
|
||||
|
@ -670,7 +708,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
|
||||
assertThat(actualTask.isRead(), equalTo(false));
|
||||
assertThat(actualTask.isTransferred(), equalTo(true));
|
||||
|
@ -696,7 +735,8 @@ public class TaskServiceImplTest {
|
|||
WorkbasketAuthorization.APPEND);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -715,7 +755,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -738,7 +779,8 @@ public class TaskServiceImplTest {
|
|||
WorkbasketAuthorization.APPEND);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -765,7 +807,8 @@ public class TaskServiceImplTest {
|
|||
WorkbasketAuthorization.TRANSFER);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -785,7 +828,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).update(task);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
assertThat(actualTask.getModified(), not(equalTo(null)));
|
||||
assertThat(actualTask.isRead(), equalTo(true));
|
||||
}
|
||||
|
@ -804,7 +848,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -815,15 +860,24 @@ public class TaskServiceImplTest {
|
|||
Task expectedTask = createUnitTestTask("1", "DUMMY-TASK", "1");
|
||||
doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
|
||||
doReturn(null).when(attachmentMapperMock).findAttachmentsByTaskId(expectedTask.getId());
|
||||
doReturn(classificationQueryImplMock).when(classificationServiceMock).createClassificationQuery();
|
||||
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).domain(any());
|
||||
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).key(any());
|
||||
doReturn(new ArrayList<>()).when(classificationQueryImplMock).list();
|
||||
|
||||
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(classificationServiceMock, times(1)).createClassificationQuery();
|
||||
verify(classificationQueryImplMock, times(1)).domain(any());
|
||||
verify(classificationQueryImplMock, times(1)).key(any());
|
||||
verify(classificationQueryImplMock, times(1)).list();
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
assertThat(actualTask, equalTo(expectedTask));
|
||||
}
|
||||
|
||||
|
@ -839,7 +893,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).findById(task.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -865,7 +920,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(any());
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
assertThat(actualResultList, equalTo(expectedResultList));
|
||||
}
|
||||
|
||||
|
@ -886,7 +942,8 @@ public class TaskServiceImplTest {
|
|||
verify(taskMapperMock, times(1)).findTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
assertThat(actualResultList, equalTo(expectedResultList));
|
||||
assertThat(actualResultList.size(), equalTo(expectedResultList.size()));
|
||||
}
|
||||
|
@ -918,6 +975,8 @@ public class TaskServiceImplTest {
|
|||
task.setId(id);
|
||||
task.setName(name);
|
||||
task.setWorkbasketKey(workbasketKey);
|
||||
task.setDomain("");
|
||||
task.setAttachments(new ArrayList<>());
|
||||
Timestamp now = new Timestamp(System.currentTimeMillis());
|
||||
task.setCreated(now);
|
||||
task.setModified(now);
|
||||
|
|
Loading…
Reference in New Issue