TSK-39: Introduced an interface for 'Task', added Methods, solved conflicts, fixed some test issues.
This commit is contained in:
parent
75e35a7593
commit
f750dcf94d
|
@ -1,18 +1,17 @@
|
|||
package pro.taskana;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.EJB;
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
import javax.enterprise.context.Initialized;
|
||||
import javax.enterprise.event.Observes;
|
||||
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidOwnerException;
|
||||
import pro.taskana.exceptions.InvalidStateException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.Task;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.EJB;
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
import javax.enterprise.context.Initialized;
|
||||
import javax.enterprise.event.Observes;
|
||||
|
||||
@ApplicationScoped
|
||||
public class ExampleBootstrap {
|
||||
|
@ -23,14 +22,14 @@ public class ExampleBootstrap {
|
|||
@PostConstruct
|
||||
public void init(@Observes @Initialized(ApplicationScoped.class) Object init) throws TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, InvalidStateException, InvalidOwnerException {
|
||||
System.out.println("---------------------------> Start App");
|
||||
Task task = taskanaEjb.getTaskService().createTask(new Task());
|
||||
Task task = taskanaEjb.getTaskService().newTask();
|
||||
task = taskanaEjb.getTaskService().createTask(task);
|
||||
System.out.println("---------------------------> Task started: " + task.getId());
|
||||
taskanaEjb.getTaskService().claim(task.getId());
|
||||
System.out.println(
|
||||
"---------------------------> Task claimed: "
|
||||
+ taskanaEjb.getTaskService().getTaskById(task.getId()).getOwner());
|
||||
// taskService.complete(task.getId());
|
||||
// System.out.println("---------------------------> Task completed");
|
||||
taskanaEjb.getTaskService().completeTask(task.getId());
|
||||
System.out.println("---------------------------> Task completed");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package pro.taskana;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.Task;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.inject.Inject;
|
||||
|
||||
@Stateless
|
||||
public class TaskanaEjb {
|
||||
|
@ -33,8 +32,9 @@ public class TaskanaEjb {
|
|||
}
|
||||
|
||||
public void triggerRollback() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
Task t = taskService.createTask(new Task());
|
||||
System.out.println("---------------->" + t.getId());
|
||||
Task task = taskService.newTask();
|
||||
taskService.createTask(task);
|
||||
System.out.println("---------------->" + task.getId());
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import pro.taskana.exceptions.InvalidStateException;
|
|||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.Workbasket;
|
||||
|
||||
@Path("/test")
|
||||
|
@ -42,14 +41,14 @@ public class TaskanaRestTest {
|
|||
classification.setKey("TEST");
|
||||
taskanaEjb.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
Task task = taskanaEjb.getTaskService().newTask();
|
||||
task.setClassification(classification);
|
||||
task.setWorkbasketId(workbasket.getId());
|
||||
|
||||
Task result = taskanaEjb.getTaskService().createTask(task);
|
||||
Task resultTask = taskanaEjb.getTaskService().createTask(task);
|
||||
|
||||
logger.info(result.getId() + ":" + result.getOwner());
|
||||
return Response.status(200).entity(result.getId()).build();
|
||||
logger.info(resultTask.getId() + ":" + resultTask.getOwner());
|
||||
return Response.status(200).entity(resultTask.getId()).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
|
|
|
@ -0,0 +1,295 @@
|
|||
package pro.taskana;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Map;
|
||||
|
||||
import pro.taskana.model.ObjectReference;
|
||||
import pro.taskana.model.TaskState;
|
||||
|
||||
/**
|
||||
* task-Interface to specify attribute interactions.
|
||||
*/
|
||||
public interface Task {
|
||||
|
||||
/**
|
||||
* Returns the current id of the task.
|
||||
* @return taskId
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Returns the time when the task was {@link TaskState#READY}.
|
||||
* @return created as exact {@link Timestamp}
|
||||
*/
|
||||
Timestamp getCreated();
|
||||
|
||||
/**
|
||||
* Returns the time when the task was set to {@link TaskState#CLAIMED} by/to a user.
|
||||
* @return claimed as exact {@link Timestamp}
|
||||
*/
|
||||
Timestamp getClaimed();
|
||||
|
||||
/**
|
||||
* Returns the time when the task was set into {@link TaskState#COMPLETED}.
|
||||
* @return completed as exact {@link Timestamp}
|
||||
*/
|
||||
Timestamp getCompleted();
|
||||
|
||||
/**
|
||||
* Returns the time when the task was modified the last time.
|
||||
* @return modified as exact {@link Timestamp}
|
||||
*/
|
||||
Timestamp getModified();
|
||||
|
||||
/**
|
||||
* Returns the time when the work on this task was planned to be started.
|
||||
* @return planned as exact {@link Timestamp}
|
||||
*/
|
||||
Timestamp getPlanned();
|
||||
|
||||
/**
|
||||
* Sets the time when the work on this task should be started.
|
||||
* @param planned as exact {@link Timestamp}
|
||||
*/
|
||||
void setPlanned(Timestamp planned);
|
||||
|
||||
/**
|
||||
* Returns the time when this task should be finished.
|
||||
* @return due as exact {@link Timestamp}
|
||||
*/
|
||||
Timestamp getDue();
|
||||
|
||||
/**
|
||||
* Return the name of the current task.
|
||||
* @return name of the task
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Sets the name of the current task.
|
||||
* @param name of the task
|
||||
*/
|
||||
void setName(String name);
|
||||
|
||||
/**
|
||||
* Return the task-description.
|
||||
* @return description of a task
|
||||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Sets the description of the task.
|
||||
* @param description of the task
|
||||
*/
|
||||
void setDescription(String description);
|
||||
|
||||
/**
|
||||
* Returns the numeric priority of a task.
|
||||
* @return priority of the task
|
||||
*/
|
||||
int getPriority();
|
||||
|
||||
/**
|
||||
* Returns the current {@link TaskState} of the task.
|
||||
* @return taskState
|
||||
*/
|
||||
TaskState getState();
|
||||
|
||||
/**
|
||||
* Returns the {@link Classification} of the task.
|
||||
* @return classification for specification
|
||||
*/
|
||||
Classification getClassification();
|
||||
|
||||
/**
|
||||
* Sets the {@link Classification} to specify this kind of task.
|
||||
* @param classification of the task
|
||||
*/
|
||||
void setClassification(Classification classification);
|
||||
|
||||
/**
|
||||
* Returns the id of the Workbasket where the task is stored in.
|
||||
* @return workbasketId
|
||||
*/
|
||||
String getWorkbasketId();
|
||||
|
||||
/**
|
||||
* Sets the id of the Workbasket where the task should be stored in.
|
||||
* @param workbasketId
|
||||
*/
|
||||
void setWorkbasketId(String workbasketId);
|
||||
|
||||
/**
|
||||
* Returns the businessProcessId of a task.
|
||||
* @return businessProcessId
|
||||
*/
|
||||
String getBusinessProcessId();
|
||||
|
||||
/**
|
||||
* Returns the parentBusinessProcessId of a task.
|
||||
* @return parentBusinessProcessId
|
||||
*/
|
||||
String getParentBusinessProcessId();
|
||||
|
||||
/**
|
||||
* Return the id of the task-owner.
|
||||
* @return taskOwnerId
|
||||
*/
|
||||
String getOwner();
|
||||
|
||||
/**
|
||||
* Sets the ownerId of this task.
|
||||
* @param taskOwnerId
|
||||
*/
|
||||
void setOwner(String taskOwnerId);
|
||||
|
||||
/**
|
||||
* Returns the {@link ObjectReference primaryObjectReference} of the task.
|
||||
* @return primaryObjRef to task main-subject
|
||||
*/
|
||||
ObjectReference getPrimaryObjRef();
|
||||
|
||||
/**
|
||||
* Sets the {@link ObjectReference primaryObjectReference} of the task.
|
||||
* @param primaryObjRef to task main-subject
|
||||
*/
|
||||
void setPrimaryObjRef(ObjectReference primaryObjRef);
|
||||
|
||||
/**
|
||||
* Return the isRead-flag, which flags a task as viewed at least one time.
|
||||
* @return isRead-flag
|
||||
*/
|
||||
boolean isRead();
|
||||
|
||||
/**
|
||||
* Return the isTransferred-flag, which flags a task as transfered into an other workbasket.
|
||||
* @return isTransferred-flag
|
||||
*/
|
||||
boolean isTransferred();
|
||||
|
||||
/**
|
||||
* Returns a collection of customAttributes with a max. amount of 10 entries.
|
||||
* @return customAttributes as {@link Map}
|
||||
*/
|
||||
Map<String, Object> getCustomAttributes();
|
||||
|
||||
/**
|
||||
* Return the key for the 1. customAttribute.
|
||||
* @return custom1
|
||||
*/
|
||||
String getCustom1();
|
||||
|
||||
/**
|
||||
* Sets the key for customAttribute1.
|
||||
* @param custom1
|
||||
*/
|
||||
void setCustom1(String custom1);
|
||||
|
||||
/**
|
||||
* Return the key for the 2. customAttribute.
|
||||
* @return custom2
|
||||
*/
|
||||
String getCustom2();
|
||||
|
||||
/**
|
||||
* Sets the key for customAttribute2.
|
||||
* @param custom2
|
||||
*/
|
||||
void setCustom2(String custom2);
|
||||
|
||||
/**
|
||||
* Return the key for the 3. customAttribute.
|
||||
* @return custom3
|
||||
*/
|
||||
String getCustom3();
|
||||
|
||||
/**
|
||||
* Sets the key for customAttribute3.
|
||||
* @param custom3
|
||||
*/
|
||||
void setCustom3(String custom3);
|
||||
|
||||
/**
|
||||
* Return the key for the 4. customAttribute.
|
||||
* @return custom4
|
||||
*/
|
||||
String getCustom4();
|
||||
|
||||
/**
|
||||
* Sets the key for customAttribute4.
|
||||
* @param custom4
|
||||
*/
|
||||
void setCustom4(String custom4);
|
||||
|
||||
/**
|
||||
* Return the key for the 5. customAttribute.
|
||||
* @return custom5
|
||||
*/
|
||||
String getCustom5();
|
||||
|
||||
/**
|
||||
* Sets the key for customAttribute25.
|
||||
* @param custom5
|
||||
*/
|
||||
void setCustom5(String custom5);
|
||||
|
||||
/**
|
||||
* Return the key for the 6. customAttribute.
|
||||
* @return custom6
|
||||
*/
|
||||
String getCustom6();
|
||||
|
||||
/**
|
||||
* Sets the key for customAttribute6.
|
||||
* @param custom6
|
||||
*/
|
||||
void setCustom6(String custom6);
|
||||
|
||||
/**
|
||||
* Return the key for the 7. customAttribute.
|
||||
* @return custom7
|
||||
*/
|
||||
String getCustom7();
|
||||
|
||||
/**
|
||||
* Sets the key for customAttribute7.
|
||||
* @param custom7
|
||||
*/
|
||||
void setCustom7(String custom7);
|
||||
|
||||
/**
|
||||
* Return the key for the 8. customAttribute.
|
||||
* @return custom8
|
||||
*/
|
||||
String getCustom8();
|
||||
|
||||
/**
|
||||
* Sets the key for customAttribute8.
|
||||
* @param custom8
|
||||
*/
|
||||
void setCustom8(String custom8);
|
||||
|
||||
/**
|
||||
* Return the key for the 9. customAttribute.
|
||||
* @return custom9
|
||||
*/
|
||||
String getCustom9();
|
||||
|
||||
/**
|
||||
* Sets the key for customAttribute9.
|
||||
* @param custom9
|
||||
*/
|
||||
void setCustom9(String custom9);
|
||||
|
||||
/**
|
||||
* Return the key for the 10. customAttribute.
|
||||
* @return custom10
|
||||
*/
|
||||
String getCustom10();
|
||||
|
||||
/**
|
||||
* Sets the key for customAttribute10.
|
||||
* @param custom10
|
||||
*/
|
||||
void setCustom10(String custom10);
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package pro.taskana;
|
||||
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.TaskState;
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,6 @@ import pro.taskana.exceptions.InvalidStateException;
|
|||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.TaskSummary;
|
||||
|
||||
|
@ -86,7 +85,7 @@ public interface TaskService {
|
|||
/**
|
||||
* Create and persist a task.
|
||||
*
|
||||
* @param task
|
||||
* @param taskToCreate
|
||||
* the transient task object to be persisted
|
||||
* @return the created and persisted task
|
||||
* @throws NotAuthorizedException
|
||||
|
@ -96,7 +95,7 @@ public interface TaskService {
|
|||
* @throws ClassificationNotFoundException
|
||||
* thrown if the {@link Classification} referenced by the task is not found
|
||||
*/
|
||||
Task createTask(Task task)
|
||||
Task createTask(Task taskToCreate)
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException;
|
||||
|
||||
/**
|
||||
|
@ -174,4 +173,10 @@ public interface TaskService {
|
|||
* if a Work basket can´t be located.
|
||||
*/
|
||||
List<TaskSummary> getTaskSummariesByWorkbasketId(String workbasketId) throws WorkbasketNotFoundException;
|
||||
|
||||
/**
|
||||
* Returns a not persisted instance of {@link Task}.
|
||||
* @return task - with default values
|
||||
*/
|
||||
Task newTask();
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
classificationMapper.insert(classificationImpl);
|
||||
LOGGER.debug("Method createClassification created classification {}.", classification);
|
||||
if (classificationImpl.getDomain() != "") {
|
||||
classificationImpl.setId(UUID.randomUUID().toString());
|
||||
classificationImpl.setDomain("");
|
||||
classificationMapper.insert(classificationImpl);
|
||||
LOGGER.debug("Method createClassification created classification {}.", classification);
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
package pro.taskana.model;
|
||||
package pro.taskana.impl;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import pro.taskana.Classification;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.model.ObjectReference;
|
||||
import pro.taskana.model.TaskState;
|
||||
|
||||
/**
|
||||
* Task entity.
|
||||
*/
|
||||
public class Task {
|
||||
public class TaskImpl implements Task {
|
||||
|
||||
private String id;
|
||||
private Timestamp created;
|
||||
|
@ -43,6 +46,9 @@ public class Task {
|
|||
private String custom9;
|
||||
private String custom10;
|
||||
|
||||
TaskImpl() { }
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -51,6 +57,7 @@ public class Task {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Timestamp getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
@ -59,6 +66,7 @@ public class Task {
|
|||
this.created = created;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Timestamp getClaimed() {
|
||||
return claimed;
|
||||
}
|
||||
|
@ -67,6 +75,7 @@ public class Task {
|
|||
this.claimed = claimed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Timestamp getCompleted() {
|
||||
return completed;
|
||||
}
|
||||
|
@ -75,22 +84,27 @@ public class Task {
|
|||
this.completed = completed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Timestamp getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
public void setModified(Timestamp modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Timestamp getPlanned() {
|
||||
return planned;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlanned(Timestamp planned) {
|
||||
this.planned = planned;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Timestamp getDue() {
|
||||
return due;
|
||||
}
|
||||
|
@ -99,22 +113,27 @@ public class Task {
|
|||
this.due = due;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
@ -123,6 +142,7 @@ public class Task {
|
|||
this.priority = priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskState getState() {
|
||||
return state;
|
||||
}
|
||||
|
@ -131,30 +151,37 @@ public class Task {
|
|||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Classification getClassification() {
|
||||
return classification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClassification(Classification classification) {
|
||||
this.classification = classification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorkbasketId() {
|
||||
return workbasketId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorkbasketId(String workbasketId) {
|
||||
this.workbasketId = workbasketId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBusinessProcessId() {
|
||||
return businessProcessId;
|
||||
}
|
||||
|
||||
|
||||
public void setBusinessProcessId(String businessProcessId) {
|
||||
this.businessProcessId = businessProcessId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentBusinessProcessId() {
|
||||
return parentBusinessProcessId;
|
||||
}
|
||||
|
@ -163,22 +190,27 @@ public class Task {
|
|||
this.parentBusinessProcessId = parentBusinessProcessId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectReference getPrimaryObjRef() {
|
||||
return primaryObjRef;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryObjRef(ObjectReference primaryObjRef) {
|
||||
this.primaryObjRef = primaryObjRef;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRead() {
|
||||
return isRead;
|
||||
}
|
||||
|
@ -187,6 +219,7 @@ public class Task {
|
|||
this.isRead = isRead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTransferred() {
|
||||
return isTransferred;
|
||||
}
|
||||
|
@ -195,6 +228,7 @@ public class Task {
|
|||
this.isTransferred = isTransferred;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getCustomAttributes() {
|
||||
return customAttributes;
|
||||
}
|
||||
|
@ -203,82 +237,102 @@ public class Task {
|
|||
this.customAttributes = customAttributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom1() {
|
||||
return custom1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom1(String custom1) {
|
||||
this.custom1 = custom1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom2() {
|
||||
return custom2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom2(String custom2) {
|
||||
this.custom2 = custom2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom3() {
|
||||
return custom3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom3(String custom3) {
|
||||
this.custom3 = custom3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom4() {
|
||||
return custom4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom4(String custom4) {
|
||||
this.custom4 = custom4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom5() {
|
||||
return custom5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom5(String custom5) {
|
||||
this.custom5 = custom5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom6() {
|
||||
return custom6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom6(String custom6) {
|
||||
this.custom6 = custom6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom7() {
|
||||
return custom7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom7(String custom7) {
|
||||
this.custom7 = custom7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom8() {
|
||||
return custom8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom8(String custom8) {
|
||||
this.custom8 = custom8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom9() {
|
||||
return custom9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom9(String custom9) {
|
||||
this.custom9 = custom9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom10() {
|
||||
return custom10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom10(String custom10) {
|
||||
this.custom10 = custom10;
|
||||
}
|
||||
|
@ -349,5 +403,4 @@ public class Task {
|
|||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -9,11 +9,11 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import pro.taskana.ClassificationQuery;
|
||||
import pro.taskana.ObjectReferenceQuery;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskQuery;
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.impl.util.LoggerUtils;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
|
||||
|
@ -152,9 +152,9 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Task single() throws NotAuthorizedException {
|
||||
public TaskImpl single() throws NotAuthorizedException {
|
||||
LOGGER.debug("entry to single(), this = {}", this);
|
||||
Task result = null;
|
||||
TaskImpl result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
checkAuthorization();
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.Classification;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskQuery;
|
||||
import pro.taskana.TaskService;
|
||||
import pro.taskana.TaskanaEngine;
|
||||
|
@ -23,7 +24,6 @@ import pro.taskana.exceptions.WorkbasketNotFoundException;
|
|||
import pro.taskana.impl.util.IdGenerator;
|
||||
import pro.taskana.impl.util.LoggerUtils;
|
||||
import pro.taskana.model.ObjectReference;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.TaskSummary;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
|
@ -74,10 +74,10 @@ public class TaskServiceImpl implements TaskService {
|
|||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException {
|
||||
String userId = CurrentUserContext.getUserid();
|
||||
LOGGER.debug("entry to claim(id = {}, forceClaim = {}, userId = {})", taskId, forceClaim, userId);
|
||||
Task task = null;
|
||||
TaskImpl task = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
task = getTaskById(taskId);
|
||||
task = (TaskImpl) getTaskById(taskId);
|
||||
TaskState state = task.getState();
|
||||
if (state == TaskState.COMPLETED) {
|
||||
LOGGER.warn("Method claim() found that task {} is already completed. Throwing InvalidStateException",
|
||||
|
@ -115,10 +115,10 @@ public class TaskServiceImpl implements TaskService {
|
|||
public Task completeTask(String taskId, boolean isForced)
|
||||
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException {
|
||||
LOGGER.debug("entry to completeTask(id = {}, isForced {})", taskId, isForced);
|
||||
Task task = null;
|
||||
TaskImpl task = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
task = this.getTaskById(taskId);
|
||||
task = (TaskImpl) this.getTaskById(taskId);
|
||||
// check pre-conditions for non-forced invocation
|
||||
if (!isForced) {
|
||||
if (task.getClaimed() == null || task.getState() != TaskState.CLAIMED) {
|
||||
|
@ -135,7 +135,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
} else {
|
||||
// CLAIM-forced, if task was not already claimed before.
|
||||
if (task.getClaimed() == null || task.getState() != TaskState.CLAIMED) {
|
||||
task = this.claim(taskId, true);
|
||||
task = (TaskImpl) this.claim(taskId, true);
|
||||
}
|
||||
}
|
||||
Timestamp now = new Timestamp(System.currentTimeMillis());
|
||||
|
@ -152,18 +152,19 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Task createTask(Task task)
|
||||
public Task createTask(Task taskToCreate)
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
LOGGER.debug("entry to createTask(task = {})", task);
|
||||
LOGGER.debug("entry to createTask(task = {})", taskToCreate);
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
TaskImpl task = (TaskImpl) taskToCreate;
|
||||
workbasketService.getWorkbasket(task.getWorkbasketId());
|
||||
workbasketService.checkAuthorization(task.getWorkbasketId(), WorkbasketAuthorization.APPEND);
|
||||
Classification classification = task.getClassification();
|
||||
if (classification == null) {
|
||||
throw new ClassificationNotFoundException(null);
|
||||
}
|
||||
taskanaEngine.getClassificationService().getClassification(classification.getKey(), "");
|
||||
taskanaEngine.getClassificationService().getClassification(classification.getKey(), classification.getDomain());
|
||||
|
||||
standardSettings(task);
|
||||
|
||||
|
@ -203,7 +204,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
Task result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
Task task = getTaskById(taskId);
|
||||
TaskImpl task = (TaskImpl) getTaskById(taskId);
|
||||
|
||||
// transfer requires TRANSFER in source and APPEND on destination workbasket
|
||||
workbasketService.checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
||||
|
@ -240,7 +241,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
Task result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
Task task = getTaskById(taskId);
|
||||
TaskImpl task = (TaskImpl) getTaskById(taskId);
|
||||
task.setRead(true);
|
||||
task.setModified(Timestamp.valueOf(LocalDateTime.now()));
|
||||
taskMapper.update(task);
|
||||
|
@ -263,24 +264,25 @@ public class TaskServiceImpl implements TaskService {
|
|||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
LOGGER.debug("entry to getTasksByWorkbasketIdAndState(workbasketId = {}, taskState = {})", workbasketId,
|
||||
taskState);
|
||||
List<Task> result = null;
|
||||
List<Task> results = new ArrayList<>();
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
workbasketService.checkAuthorization(workbasketId, WorkbasketAuthorization.READ);
|
||||
result = taskMapper.findTasksByWorkbasketIdAndState(workbasketId, taskState);
|
||||
List<TaskImpl> tasks = taskMapper.findTasksByWorkbasketIdAndState(workbasketId, taskState);
|
||||
tasks.stream().forEach(t -> results.add((Task) t));
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||
int numberOfResultObjects = results == null ? 0 : results.size();
|
||||
LOGGER.debug(
|
||||
"exit from getTasksByWorkbasketIdAndState(workbasketId, taskState). Returning {} resulting Objects: {} ",
|
||||
numberOfResultObjects, LoggerUtils.listToString(result));
|
||||
numberOfResultObjects, LoggerUtils.listToString(results));
|
||||
}
|
||||
}
|
||||
return (result == null) ? new ArrayList<>() : result;
|
||||
return (results == null) ? new ArrayList<>() : results;
|
||||
}
|
||||
|
||||
private void standardSettings(Task task) {
|
||||
private void standardSettings(TaskImpl task) {
|
||||
Timestamp now = new Timestamp(System.currentTimeMillis());
|
||||
task.setId(IdGenerator.generateWithPrefix(ID_PREFIX_TASK));
|
||||
task.setState(TaskState.READY);
|
||||
|
@ -357,4 +359,8 @@ public class TaskServiceImpl implements TaskService {
|
|||
return taskSummaries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task newTask() {
|
||||
return new TaskImpl();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@ import org.apache.ibatis.annotations.Select;
|
|||
|
||||
import pro.taskana.impl.ClassificationQueryImpl;
|
||||
import pro.taskana.impl.ObjectReferenceQueryImpl;
|
||||
import pro.taskana.impl.TaskImpl;
|
||||
import pro.taskana.impl.TaskQueryImpl;
|
||||
import pro.taskana.model.ClassificationImpl;
|
||||
import pro.taskana.impl.WorkbasketQueryImpl;
|
||||
import pro.taskana.model.ObjectReference;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.Workbasket;
|
||||
|
||||
/**
|
||||
|
@ -95,7 +95,7 @@ public interface QueryMapper {
|
|||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10") })
|
||||
List<Task> queryTasks(TaskQueryImpl taskQuery);
|
||||
List<TaskImpl> queryTasks(TaskQueryImpl taskQuery);
|
||||
|
||||
@Select("<script>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 "
|
||||
|
|
|
@ -15,10 +15,10 @@ 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.ClassificationImpl;
|
||||
import pro.taskana.model.ObjectReference;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.TaskSummary;
|
||||
|
||||
|
@ -69,16 +69,16 @@ public interface TaskMapper {
|
|||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10")
|
||||
})
|
||||
Task findById(@Param("id") String id);
|
||||
TaskImpl findById(@Param("id") String id);
|
||||
|
||||
@Insert("INSERT INTO TASK(ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, PRIORITY, STATE, CLASSIFICATION_KEY, WORKBASKETID, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, OWNER, PRIMARY_OBJ_REF_ID, 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) "
|
||||
+ "VALUES(#{id}, #{created}, #{claimed}, #{completed}, #{modified}, #{planned}, #{due}, #{name}, #{description}, #{priority}, #{state}, #{classification.key}, #{workbasketId}, #{businessProcessId}, #{parentBusinessProcessId}, #{owner}, #{primaryObjRef.id}, #{isRead}, #{isTransferred}, #{customAttributes,jdbcType=BLOB,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler}, #{custom1}, #{custom2}, #{custom3}, #{custom4}, #{custom5}, #{custom6}, #{custom7}, #{custom8}, #{custom9}, #{custom10})")
|
||||
@Options(keyProperty = "id", keyColumn = "ID")
|
||||
void insert(Task task);
|
||||
void insert(TaskImpl task);
|
||||
|
||||
@Update("UPDATE TASK SET CLAIMED = #{claimed}, COMPLETED = #{completed}, MODIFIED = #{modified}, PLANNED = #{planned}, DUE = #{due}, NAME = #{name}, DESCRIPTION = #{description}, PRIORITY = #{priority}, STATE = #{state}, CLASSIFICATION_KEY = #{classification.key}, WORKBASKETID = #{workbasketId}, BUSINESS_PROCESS_ID = #{businessProcessId}, PARENT_BUSINESS_PROCESS_ID = #{parentBusinessProcessId}, OWNER = #{owner}, PRIMARY_OBJ_REF_ID = #{primaryObjRef.id}, IS_READ = #{isRead}, IS_TRANSFERRED = #{isTransferred}, CUSTOM_ATTRIBUTES = #{customAttributes,jdbcType=BLOB,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler}, CUSTOM_1 = #{custom1}, CUSTOM_2 = #{custom2}, CUSTOM_3 = #{custom3}, CUSTOM_4 = #{custom4}, CUSTOM_5 = #{custom5}, CUSTOM_6 = #{custom6}, CUSTOM_7 = #{custom7}, CUSTOM_8 = #{custom8}, CUSTOM_9 = #{custom9}, CUSTOM_10 = #{custom10} "
|
||||
+ "WHERE ID = #{id}")
|
||||
void update(Task task);
|
||||
void update(TaskImpl task);
|
||||
|
||||
@Delete("DELETE FROM TASK WHERE ID = #{id}")
|
||||
void delete(String id);
|
||||
|
@ -120,7 +120,7 @@ public interface TaskMapper {
|
|||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10")
|
||||
})
|
||||
List<Task> findTasksByWorkbasketIdAndState(@Param("workbasketId") String workbasketId,
|
||||
List<TaskImpl> findTasksByWorkbasketIdAndState(@Param("workbasketId") String workbasketId,
|
||||
@Param("taskState") TaskState taskState);
|
||||
|
||||
@Select("SELECT TASK.ID AS taskId, TASK.NAME AS taskName, TASK.WORKBASKETID AS workId, TASK.CLASSIFICATION_KEY AS classificationKey, "
|
||||
|
|
|
@ -246,22 +246,6 @@ public class ClassificationServiceImplTest {
|
|||
cutSpy.createClassificationQuery();
|
||||
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
|
||||
}
|
||||
//
|
||||
// @Test
|
||||
// public void testNewClassification() {
|
||||
// Classification actualResult = cutSpy.newClassification();
|
||||
//
|
||||
// verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
|
||||
// assertThat(actualResult.getId(), not(equalTo(null)));
|
||||
// assertThat(actualResult.getKey(), not(equalTo(null)));
|
||||
// assertThat(actualResult.getKey(), startsWith(idPrefixClassification));
|
||||
// assertThat(actualResult.getCreated(), equalTo(today));
|
||||
// assertThat(actualResult.getParentClassificationKey(), equalTo(""));
|
||||
// assertThat(actualResult.getDomain(), equalTo(""));
|
||||
// assertThat(actualResult.getValidFrom(), equalTo(today));
|
||||
// assertThat(actualResult.getValidUntil(),
|
||||
// equalTo(ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL));
|
||||
// }
|
||||
|
||||
private Classification createDummyCLassification() {
|
||||
ClassificationImpl classificationImpl = new ClassificationImpl();
|
||||
|
|
|
@ -14,8 +14,8 @@ import org.junit.runner.RunWith;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.TaskState;
|
||||
|
||||
/**
|
||||
|
@ -61,7 +61,7 @@ public class TaskQueryImplTest {
|
|||
@Test
|
||||
public void should_ReturnOneItem_when_BuilderIsUsed() throws NotAuthorizedException {
|
||||
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
|
||||
when(sqlSession.selectOne(any(), any())).thenReturn(new Task());
|
||||
when(sqlSession.selectOne(any(), any())).thenReturn(new TaskImpl());
|
||||
|
||||
Task result = taskQueryImpl.name("test", "asd", "blubber").customFields("cool", "bla").priority(1, 2)
|
||||
.state(TaskState.CLAIMED, TaskState.COMPLETED).single();
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
|
|||
|
||||
import pro.taskana.Classification;
|
||||
import pro.taskana.ClassificationService;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.exceptions.ClassificationAlreadyExistException;
|
||||
|
@ -44,7 +45,6 @@ import pro.taskana.exceptions.TaskNotFoundException;
|
|||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.ClassificationImpl;
|
||||
import pro.taskana.model.ObjectReference;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.TaskSummary;
|
||||
import pro.taskana.model.Workbasket;
|
||||
|
@ -107,22 +107,22 @@ public class TaskServiceImplTest {
|
|||
@Test
|
||||
public void testCreateSimpleTask() throws NotAuthorizedException, WorkbasketNotFoundException,
|
||||
ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||
Mockito.doNothing().when(taskMapperMock).insert(any());
|
||||
Task expectedTask = createUnitTestTask("1", "DUMMYTASK", "1");
|
||||
TaskImpl expectedTask = createUnitTestTask("1", "DUMMYTASK", "1");
|
||||
Workbasket wb = new Workbasket();
|
||||
wb.setId("1");
|
||||
wb.setName("workbasket");
|
||||
doReturn(wb).when(workbasketServiceMock).getWorkbasket(wb.getId());
|
||||
doNothing().when(taskMapperMock).insert(any());
|
||||
|
||||
Task actualTask = cut.createTask(expectedTask);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).getClassificationService();
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||
verify(taskanaEngineMock, times(1)).getClassificationService();
|
||||
verify(classificationServiceMock, times(1)).getClassification(any(), any());
|
||||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(classificationServiceMock, times(1)).getClassification(any(), any());
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
|
@ -145,29 +145,26 @@ public class TaskServiceImplTest {
|
|||
Workbasket wb = new Workbasket();
|
||||
wb.setId("1");
|
||||
wb.setName("workbasket");
|
||||
TaskImpl expectedTask = createUnitTestTask("1", "DUMMYTASK", wb.getId());
|
||||
expectedTask.setPrimaryObjRef(expectedObjectReference);
|
||||
Classification classification = expectedTask.getClassification();
|
||||
doReturn(wb).when(workbasketServiceMock).getWorkbasket(wb.getId());
|
||||
|
||||
Task expectedTask = createUnitTestTask("1", "DUMMYTASK", "1");
|
||||
expectedTask.setPrimaryObjRef(new ObjectReference());
|
||||
|
||||
Mockito.doNothing().when(taskMapperMock).insert(any());
|
||||
Mockito.doReturn(expectedObjectReference).when(objectReferenceMapperMock).findByObjectReference(any());
|
||||
doReturn(expectedObjectReference).when(objectReferenceMapperMock).findByObjectReference(expectedObjectReference);
|
||||
doNothing().when(taskMapperMock).insert(expectedTask);
|
||||
|
||||
Task actualTask = cut.createTask(expectedTask);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(wb.getId());
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(wb.getId(), WorkbasketAuthorization.APPEND);
|
||||
verify(taskanaEngineMock, times(1)).getClassificationService();
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||
verify(objectReferenceMapperMock, times(1)).findByObjectReference(any());
|
||||
verify(classificationServiceMock, times(1)).getClassification(classification.getKey(), classification.getDomain());
|
||||
verify(objectReferenceMapperMock, times(1)).findByObjectReference(expectedObjectReference);
|
||||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(classificationServiceMock, times(1)).getClassification(any(),
|
||||
any());
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
|
||||
assertNull(actualTask.getOwner());
|
||||
assertNotNull(actualTask.getCreated());
|
||||
assertNotNull(actualTask.getModified());
|
||||
|
@ -181,7 +178,6 @@ public class TaskServiceImplTest {
|
|||
@Test
|
||||
public void testCreateSimpleTaskWithObjectReferenceIsNull() throws NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
ObjectReference expectedObjectReference = new ObjectReference();
|
||||
expectedObjectReference.setId("1");
|
||||
expectedObjectReference.setType("DUMMY");
|
||||
|
@ -189,29 +185,29 @@ public class TaskServiceImplTest {
|
|||
wb.setId("1");
|
||||
wb.setName("workbasket");
|
||||
doReturn(wb).when(workbasketServiceMock).getWorkbasket(wb.getId());
|
||||
Task expectedTask = createUnitTestTask("1", "DUMMYTASK", "1");
|
||||
TaskImpl expectedTask = createUnitTestTask("1", "DUMMYTASK", "1");
|
||||
expectedTask.setPrimaryObjRef(expectedObjectReference);
|
||||
Classification classification = expectedTask.getClassification();
|
||||
doReturn(classification).when(classificationServiceMock).getClassification(classification.getKey(), classification.getDomain());
|
||||
doNothing().when(taskMapperMock).insert(expectedTask);
|
||||
doNothing().when(objectReferenceMapperMock).insert(expectedObjectReference);
|
||||
doReturn(null).when(objectReferenceMapperMock).findByObjectReference(expectedTask.getPrimaryObjRef());
|
||||
|
||||
Mockito.doNothing().when(taskMapperMock).insert(any());
|
||||
Mockito.doNothing().when(objectReferenceMapperMock).insert(any());
|
||||
Mockito.doReturn(null).when(objectReferenceMapperMock).findByObjectReference(any());
|
||||
|
||||
Task actualTask = cutSpy.createTask(expectedTask);
|
||||
Task actualTask = cut.createTask(expectedTask);
|
||||
expectedTask.getPrimaryObjRef().setId(actualTask.getPrimaryObjRef().getId()); // get only new ID
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(expectedTask.getWorkbasketId());
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(expectedTask.getWorkbasketId(), WorkbasketAuthorization.APPEND);
|
||||
verify(taskanaEngineMock, times(1)).getClassificationService();
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||
verify(classificationServiceMock, times(1)).getClassification(any(), any());
|
||||
verify(objectReferenceMapperMock, times(1)).findByObjectReference(any());
|
||||
verify(objectReferenceMapperMock, times(1)).insert(any());
|
||||
verify(classificationServiceMock, times(1)).getClassification(classification.getKey(), classification.getDomain());
|
||||
verify(objectReferenceMapperMock, times(1)).findByObjectReference(expectedObjectReference);
|
||||
verify(objectReferenceMapperMock, times(1)).insert(expectedObjectReference);
|
||||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
|
||||
assertNull(actualTask.getOwner());
|
||||
assertNotNull(actualTask.getCreated());
|
||||
assertNotNull(actualTask.getModified());
|
||||
|
@ -228,79 +224,71 @@ public class TaskServiceImplTest {
|
|||
ObjectReference expectedObjectReference = new ObjectReference();
|
||||
expectedObjectReference.setId("1");
|
||||
expectedObjectReference.setType("DUMMY");
|
||||
|
||||
Classification classification = new ClassificationImpl();
|
||||
Classification classification = (Classification) new ClassificationImpl();
|
||||
classification.setName("Name");
|
||||
classification.setCategory("MANUAL");
|
||||
Workbasket wb = new Workbasket();
|
||||
wb.setId("workbasketId");
|
||||
wb.setName("workbasket");
|
||||
TaskImpl task = new TaskImpl();
|
||||
task.setWorkbasketId(wb.getId());
|
||||
task.setClassification(classification);
|
||||
task.setPrimaryObjRef(expectedObjectReference);
|
||||
task.setDescription("simply awesome task");
|
||||
doReturn(wb).when(workbasketServiceMock).getWorkbasket(wb.getId());
|
||||
Mockito.doReturn(classification).when(classificationServiceMock).getClassification(any(), any());
|
||||
Mockito.doNothing().when(taskMapperMock).insert(any());
|
||||
Mockito.doNothing().when(objectReferenceMapperMock).insert(any());
|
||||
doReturn(classification).when(classificationServiceMock).getClassification(classification.getKey(), classification.getDomain());
|
||||
doReturn(expectedObjectReference).when(objectReferenceMapperMock).findByObjectReference(expectedObjectReference);
|
||||
doNothing().when(taskMapperMock).insert(task);
|
||||
|
||||
Task test = new Task();
|
||||
test.setWorkbasketId("workbasketId");
|
||||
test.setClassification(classification);
|
||||
test.setPrimaryObjRef(expectedObjectReference);
|
||||
test.setDescription("simply awesome task");
|
||||
cut.createTask(task);
|
||||
|
||||
cut.createTask(test);
|
||||
TaskImpl task2 = new TaskImpl();
|
||||
task2.setWorkbasketId(wb.getId());
|
||||
task2.setClassification(classification);
|
||||
task2.setPrimaryObjRef(expectedObjectReference);
|
||||
task2.setPlanned(Timestamp.valueOf(LocalDateTime.now().minusHours(1)));
|
||||
task2.setName("Task2");
|
||||
|
||||
Task test2 = new Task();
|
||||
test2.setWorkbasketId("workbasketId");
|
||||
test2.setClassification(classification);
|
||||
test2.setPrimaryObjRef(expectedObjectReference);
|
||||
test2.setPlanned(Timestamp.valueOf(LocalDateTime.now().minusHours(1)));
|
||||
test2.setName("Task2");
|
||||
|
||||
cut.createTask(test2);
|
||||
cut.createTask(task2);
|
||||
|
||||
verify(taskanaEngineImpl, times(2)).openConnection();
|
||||
verify(taskanaEngineMock, times(2)).getClassificationService();
|
||||
verify(workbasketServiceMock, times(2)).checkAuthorization(any(), any());
|
||||
verify(workbasketServiceMock, times(2)).getWorkbasket(any());
|
||||
verify(taskanaEngineMock, times(2)).getClassificationService();
|
||||
verify(classificationServiceMock, times(2)).getClassification(any(), any());
|
||||
verify(objectReferenceMapperMock, times(2)).findByObjectReference(any());
|
||||
verify(objectReferenceMapperMock, times(2)).insert(any());
|
||||
verify(taskMapperMock, times(1)).insert(test);
|
||||
verify(taskMapperMock, times(1)).insert(test2);
|
||||
verify(objectReferenceMapperMock, times(2)).findByObjectReference(expectedObjectReference);
|
||||
verify(taskMapperMock, times(1)).insert(task);
|
||||
verify(taskMapperMock, times(1)).insert(task2);
|
||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
classificationServiceMock);
|
||||
|
||||
assertNull(test.getOwner());
|
||||
assertNotNull(test.getCreated());
|
||||
assertNotNull(test.getModified());
|
||||
assertNull(test.getCompleted());
|
||||
assertNull(test.getDue());
|
||||
assertThat(test.getWorkbasketId(), equalTo(test2.getWorkbasketId()));
|
||||
assertThat(test.getName(), equalTo(classification.getName()));
|
||||
assertThat(test.getState(), equalTo(TaskState.READY));
|
||||
assertThat(test.getPrimaryObjRef(), equalTo(expectedObjectReference));
|
||||
assertThat(test.getName(), not(test2.getName()));
|
||||
assertThat(test.getPlanned(), not(test2.getPlanned()));
|
||||
assertThat(test2.getPlanned(), not(test2.getCreated()));
|
||||
|
||||
assertNull(task.getOwner());
|
||||
assertNotNull(task.getCreated());
|
||||
assertNotNull(task.getModified());
|
||||
assertNull(task.getCompleted());
|
||||
assertNull(task.getDue());
|
||||
assertThat(task.getWorkbasketId(), equalTo(task2.getWorkbasketId()));
|
||||
assertThat(task.getName(), equalTo(classification.getName()));
|
||||
assertThat(task.getState(), equalTo(TaskState.READY));
|
||||
assertThat(task.getPrimaryObjRef(), equalTo(expectedObjectReference));
|
||||
assertThat(task.getName(), not(task2.getName()));
|
||||
assertThat(task.getPlanned(), not(task2.getPlanned()));
|
||||
assertThat(task2.getPlanned(), not(task2.getCreated()));
|
||||
}
|
||||
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testCreateThrowingAuthorizedOnWorkbasket()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
TaskImpl task = createUnitTestTask("1", "dummyTask", "1");
|
||||
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(task.getWorkbasketId(), WorkbasketAuthorization.APPEND);
|
||||
try {
|
||||
Mockito.doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(any(), any());
|
||||
Task task = new Task();
|
||||
task.setWorkbasketId("1");
|
||||
task.setBusinessProcessId("BPI1");
|
||||
task.setParentBusinessProcessId("PBPI1");
|
||||
|
||||
cut.createTask(task);
|
||||
} catch (Exception e) {
|
||||
} catch (NotAuthorizedException e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(task.getWorkbasketId());
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getWorkbasketId(), WorkbasketAuthorization.APPEND);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
|
@ -310,17 +298,14 @@ public class TaskServiceImplTest {
|
|||
}
|
||||
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void testCreateThrowsWorkbasketNotFoundException()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
public void testCreateThrowsWorkbasketNotFoundException() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
TaskImpl task = createUnitTestTask("1", "dumma-task", "1");
|
||||
doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock).getWorkbasket(any());
|
||||
try {
|
||||
Mockito.doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock).getWorkbasket(any());
|
||||
Task task = new Task();
|
||||
task.setWorkbasketId("1");
|
||||
|
||||
cut.createTask(task);
|
||||
} catch (Exception e) {
|
||||
} catch (WorkbasketNotFoundException e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any());
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(task.getWorkbasketId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
|
@ -331,7 +316,7 @@ public class TaskServiceImplTest {
|
|||
|
||||
@Test
|
||||
public void testClaimSuccessfulToOwner() throws Exception {
|
||||
Task expectedTask = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl expectedTask = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
Mockito.doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
|
||||
|
||||
Thread.sleep(SLEEP_TIME); // to have different timestamps
|
||||
|
@ -359,7 +344,7 @@ public class TaskServiceImplTest {
|
|||
@Test(expected = TaskNotFoundException.class)
|
||||
public void testClaimThrowinTaskNotFoundException() throws Exception {
|
||||
try {
|
||||
Task expectedTask = null;
|
||||
TaskImpl expectedTask = null;
|
||||
Mockito.doReturn(expectedTask).when(taskMapperMock).findById(any());
|
||||
// Mockito.doReturn("OWNER").when(currentUserContext).getUserid();
|
||||
|
||||
|
@ -380,19 +365,26 @@ public class TaskServiceImplTest {
|
|||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
final long sleepTime = 100L;
|
||||
final boolean isForced = false;
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
Thread.sleep(sleepTime);
|
||||
task.setState(TaskState.CLAIMED);
|
||||
task.setClaimed(new Timestamp(System.currentTimeMillis()));
|
||||
task.setOwner(CurrentUserContext.getUserid());
|
||||
doReturn(task).when(taskMapperMock).findById(task.getId());
|
||||
doReturn(task).when(cutSpy).completeTask(task.getId(), isForced);
|
||||
|
||||
cutSpy.completeTask(task.getId());
|
||||
Task actualTask = cut.completeTask(task.getId());
|
||||
|
||||
// Just Verify unforced call of complex-complete()
|
||||
verify(cutSpy, times(1)).completeTask(task.getId(), isForced);
|
||||
verify(taskanaEngineImpl, times(2)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findById(task.getId());
|
||||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
||||
|
||||
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
|
||||
assertThat(actualTask.getCreated(), not(equalTo(task.getModified())));
|
||||
assertThat(actualTask.getCompleted(), not(equalTo(null)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -401,7 +393,7 @@ public class TaskServiceImplTest {
|
|||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
final long sleepTime = 100L;
|
||||
final boolean isForced = false;
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
// created and modify should be able to be different.
|
||||
Thread.sleep(sleepTime);
|
||||
task.setState(TaskState.CLAIMED);
|
||||
|
@ -430,7 +422,7 @@ public class TaskServiceImplTest {
|
|||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException {
|
||||
final boolean isForced = false;
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
task.setState(TaskState.READY);
|
||||
task.setClaimed(null);
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
|
@ -452,7 +444,7 @@ public class TaskServiceImplTest {
|
|||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException {
|
||||
final boolean isForced = false;
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
task.setOwner("Dummy-Owner-ID: 10");
|
||||
task.setState(TaskState.CLAIMED);
|
||||
task.setClaimed(new Timestamp(System.currentTimeMillis()));
|
||||
|
@ -495,7 +487,7 @@ public class TaskServiceImplTest {
|
|||
final boolean isForced = true;
|
||||
final long sleepTime = 100L;
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
// created and modify should be able to be different.
|
||||
Thread.sleep(sleepTime);
|
||||
task.setState(TaskState.CLAIMED);
|
||||
|
@ -524,11 +516,11 @@ public class TaskServiceImplTest {
|
|||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
final boolean isForced = true;
|
||||
final long sleepTime = 100L;
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
task.setState(TaskState.READY);
|
||||
task.setClaimed(null);
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
Task claimedTask = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl claimedTask = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
// created and modify should be able to be different.
|
||||
Thread.sleep(sleepTime);
|
||||
claimedTask.setState(TaskState.CLAIMED);
|
||||
|
@ -557,7 +549,7 @@ public class TaskServiceImplTest {
|
|||
ClassificationAlreadyExistException {
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
Workbasket destinationWorkbasket = createWorkbasket("2");
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
task.setRead(true);
|
||||
doReturn(destinationWorkbasket).when(workbasketServiceMock).getWorkbasket(destinationWorkbasket.getId());
|
||||
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
|
||||
|
@ -593,7 +585,7 @@ public class TaskServiceImplTest {
|
|||
ClassificationAlreadyExistException {
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
Workbasket destinationWorkbasket = createWorkbasket("2");
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
task.setRead(true);
|
||||
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
|
||||
doReturn(true).when(taskanaEngineConfigurationMock).isSecurityEnabled();
|
||||
|
@ -627,7 +619,7 @@ public class TaskServiceImplTest {
|
|||
ClassificationAlreadyExistException {
|
||||
|
||||
String destinationWorkbasketId = "2";
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock)
|
||||
.checkAuthorization(destinationWorkbasketId, WorkbasketAuthorization.APPEND);
|
||||
|
@ -651,7 +643,7 @@ public class TaskServiceImplTest {
|
|||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
|
||||
ClassificationAlreadyExistException {
|
||||
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTaskById(task.getId());
|
||||
|
||||
|
@ -671,7 +663,7 @@ public class TaskServiceImplTest {
|
|||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
|
||||
ClassificationAlreadyExistException {
|
||||
String destinationWorkbasketId = "2";
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doThrow(NotAuthorizedException.class).when(workbasketServiceMock).checkAuthorization(destinationWorkbasketId,
|
||||
|
@ -695,7 +687,7 @@ public class TaskServiceImplTest {
|
|||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
|
||||
ClassificationAlreadyExistException {
|
||||
String destinationWorkbasketId = "2";
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doNothing().when(workbasketServiceMock).checkAuthorization(destinationWorkbasketId,
|
||||
|
@ -720,7 +712,7 @@ public class TaskServiceImplTest {
|
|||
@Test
|
||||
public void testSetTaskReadWIthExistingTask() throws TaskNotFoundException, ClassificationAlreadyExistException {
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
task.setModified(null);
|
||||
doReturn(task).when(cutSpy).getTaskById(task.getId());
|
||||
doNothing().when(taskMapperMock).update(task);
|
||||
|
@ -739,7 +731,7 @@ public class TaskServiceImplTest {
|
|||
@Test(expected = TaskNotFoundException.class)
|
||||
public void testSetTaskReadTaskNotBeFound() throws TaskNotFoundException, ClassificationAlreadyExistException {
|
||||
TaskServiceImpl cutSpy = Mockito.spy(cut);
|
||||
Task task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1");
|
||||
task.setModified(null);
|
||||
doThrow(TaskNotFoundException.class).when(cutSpy).getTaskById(task.getId());
|
||||
|
||||
|
@ -756,7 +748,7 @@ public class TaskServiceImplTest {
|
|||
|
||||
@Test
|
||||
public void testGetTaskByIdWithExistingTask() throws TaskNotFoundException, ClassificationAlreadyExistException {
|
||||
Task expectedTask = createUnitTestTask("1", "DUMMY-TASK", "1");
|
||||
TaskImpl expectedTask = createUnitTestTask("1", "DUMMY-TASK", "1");
|
||||
doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
|
||||
|
||||
Task actualTask = cut.getTaskById(expectedTask.getId());
|
||||
|
@ -771,7 +763,7 @@ public class TaskServiceImplTest {
|
|||
|
||||
@Test(expected = TaskNotFoundException.class)
|
||||
public void testGetTaskByIdWhereTaskDoesNotExist() throws Exception {
|
||||
Task task = createUnitTestTask("1", "DUMMY-TASK", "1");
|
||||
TaskImpl task = createUnitTestTask("1", "DUMMY-TASK", "1");
|
||||
doThrow(TaskNotFoundException.class).when(taskMapperMock).findById(task.getId());
|
||||
|
||||
try {
|
||||
|
@ -851,15 +843,17 @@ public class TaskServiceImplTest {
|
|||
assertThat(actualResultList.size(), equalTo(expectedResultList.size()));
|
||||
}
|
||||
|
||||
private Task createUnitTestTask(String id, String name, String workbasketId) {
|
||||
Task task = new Task();
|
||||
task.setId(id);
|
||||
task.setName(name);
|
||||
private TaskImpl createUnitTestTask(String taskId, String taskName, String workbasketId) {
|
||||
TaskImpl task = new TaskImpl();
|
||||
task.setId(taskId);
|
||||
task.setName(taskName);
|
||||
task.setWorkbasketId(workbasketId);
|
||||
Timestamp now = new Timestamp(System.currentTimeMillis());
|
||||
task.setCreated(now);
|
||||
task.setModified(now);
|
||||
Classification classification = new ClassificationImpl();
|
||||
classification.setName("dummy-classification");
|
||||
classification.setDomain("dummy-domain");
|
||||
task.setClassification(classification);
|
||||
return task;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import pro.taskana.Classification;
|
|||
import pro.taskana.ClassificationQuery;
|
||||
import pro.taskana.ClassificationService;
|
||||
import pro.taskana.ObjectReferenceQuery;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.WorkbasketService;
|
||||
|
@ -33,11 +34,11 @@ import pro.taskana.exceptions.TaskNotFoundException;
|
|||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.impl.ClassificationQueryImpl;
|
||||
import pro.taskana.impl.ObjectReferenceQueryImpl;
|
||||
import pro.taskana.impl.TaskImpl;
|
||||
import pro.taskana.impl.TaskServiceImpl;
|
||||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
import pro.taskana.impl.configuration.DBCleaner;
|
||||
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.TaskSummary;
|
||||
import pro.taskana.model.Workbasket;
|
||||
|
@ -96,7 +97,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
classification.setKey("TEST");
|
||||
taskanaEngine.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
Task task = taskServiceImpl.newTask();
|
||||
task.setName("Unit Test Task");
|
||||
task.setWorkbasketId(wb.getId());
|
||||
task.setClassification(classification);
|
||||
|
@ -121,7 +122,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
classification.setKey("TEST");
|
||||
taskanaEngine.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
Task task = taskServiceImpl.newTask();
|
||||
task.setName("Unit Test Task");
|
||||
task.setWorkbasketId(wb.getId());
|
||||
task.setClassification(classification);
|
||||
|
@ -144,7 +145,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
classification.setKey("TEST");
|
||||
taskanaEngine.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
Task task = taskServiceImpl.newTask();
|
||||
task.setName("Unit Test Task");
|
||||
task.setWorkbasketId(wb.getId());
|
||||
task.setClassification(classification);
|
||||
|
@ -164,7 +165,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
classification.setKey("TEST");
|
||||
taskanaEngine.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
Task task = taskServiceImpl.newTask();
|
||||
task.setName("Unit Test Task");
|
||||
task.setWorkbasketId(wb.getId());
|
||||
task.setClassification(classification);
|
||||
|
@ -215,12 +216,12 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
dummyClassification.setName("Dummy-Classification");
|
||||
classificationService.createClassification(dummyClassification);
|
||||
|
||||
Task dummyTask = new Task();
|
||||
TaskImpl dummyTask = (TaskImpl) taskServiceImpl.newTask();
|
||||
dummyTask.setId("1");
|
||||
dummyTask.setName("Dummy-Task");
|
||||
dummyTask.setClassification(dummyClassification);
|
||||
dummyTask.setWorkbasketId(dummyWorkbasket.getId());
|
||||
dummyTask = taskServiceImpl.createTask(dummyTask);
|
||||
dummyTask = (TaskImpl) taskServiceImpl.createTask(dummyTask);
|
||||
|
||||
List<TaskSummary> expectedTaskSumamries = new ArrayList<>();
|
||||
TaskSummary taskSummary = new TaskSummary();
|
||||
|
|
|
@ -19,15 +19,14 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import pro.taskana.security.JAASRunner;
|
||||
import pro.taskana.security.WithAccessId;
|
||||
import pro.taskana.Classification;
|
||||
import pro.taskana.ClassificationQuery;
|
||||
import pro.taskana.ClassificationService;
|
||||
import pro.taskana.ObjectReferenceQuery;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.exceptions.ClassificationAlreadyExistException;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
|
@ -45,10 +44,11 @@ import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
|||
import pro.taskana.impl.util.IdGenerator;
|
||||
import pro.taskana.model.ClassificationImpl;
|
||||
import pro.taskana.model.ObjectReference;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.Workbasket;
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
import pro.taskana.security.JAASRunner;
|
||||
import pro.taskana.security.WithAccessId;
|
||||
|
||||
/**
|
||||
* Integration Test for TaskServiceImpl transactions with connection management mode EXPLICIT.
|
||||
|
@ -92,7 +92,6 @@ public class TaskServiceImplIntExplicitTest {
|
|||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
// taskServiceImpl = (TaskServiceImpl) taskanaEngine.getTaskService();
|
||||
|
||||
generateSampleAccessItems();
|
||||
|
||||
|
@ -103,8 +102,8 @@ public class TaskServiceImplIntExplicitTest {
|
|||
classification.setKey("TEST");
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(workbasket);
|
||||
taskanaEngine.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
connection.commit();
|
||||
Task task = taskServiceImpl.newTask();
|
||||
task.setName("Unit Test Task");
|
||||
task.setWorkbasketId(workbasket.getId());
|
||||
task.setClassification(classification);
|
||||
|
@ -127,6 +126,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
generateSampleAccessItems();
|
||||
|
||||
Task task = this.generateDummyTask();
|
||||
connection.commit();
|
||||
task = taskServiceImpl.createTask(task);
|
||||
connection.commit(); // needed so that the change is visible in the other session
|
||||
|
||||
|
@ -157,7 +157,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
workbasketServiceImpl.createWorkbasket(workbasket);
|
||||
classificationServiceImpl.createClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
Task task = taskServiceImpl.newTask();
|
||||
task.setName("Unit Test Task");
|
||||
task.setWorkbasketId(workbasket.getId());
|
||||
task.setClassification(classification);
|
||||
|
@ -193,29 +193,29 @@ public class TaskServiceImplIntExplicitTest {
|
|||
|
||||
Timestamp tomorrow = Timestamp.valueOf(LocalDateTime.now().plusDays(1));
|
||||
|
||||
Task test = this.generateDummyTask();
|
||||
test.setClassification(classification);
|
||||
test.setName("Name");
|
||||
test.setPrimaryObjRef(objectReference);
|
||||
test.setPlanned(tomorrow);
|
||||
test = taskServiceImpl.createTask(test);
|
||||
Task task = this.generateDummyTask();
|
||||
task.setClassification(classification);
|
||||
task.setName("Name");
|
||||
task.setPrimaryObjRef(objectReference);
|
||||
task.setPlanned(tomorrow);
|
||||
Task resultTask = taskServiceImpl.createTask(task);
|
||||
|
||||
Assert.assertNotEquals(test.getPlanned(), test.getCreated());
|
||||
Assert.assertNotNull(test.getDue());
|
||||
Assert.assertNotEquals(resultTask.getPlanned(), resultTask.getCreated());
|
||||
Assert.assertNotNull(resultTask.getDue());
|
||||
|
||||
Task test2 = new Task();
|
||||
test2.setWorkbasketId(test.getWorkbasketId());
|
||||
test2.setClassification(classification);
|
||||
test2.setPrimaryObjRef(objectReference);
|
||||
test2.setDescription("desc");
|
||||
taskServiceImpl.createTask(test2);
|
||||
Task task2 = taskServiceImpl.newTask();
|
||||
task2.setWorkbasketId(task.getWorkbasketId());
|
||||
task2.setClassification(classification);
|
||||
task2.setPrimaryObjRef(objectReference);
|
||||
task2.setDescription("desc");
|
||||
Task resultTask2 = taskServiceImpl.createTask(task2);
|
||||
|
||||
Assert.assertEquals(test2.getPlanned(), test2.getCreated());
|
||||
Assert.assertTrue(test2.getName().equals(classification.getName()));
|
||||
Assert.assertEquals(resultTask2.getPlanned(), resultTask2.getCreated());
|
||||
Assert.assertTrue(resultTask2.getName().equals(classification.getName()));
|
||||
|
||||
Assert.assertEquals(test.getClassification().getId(), test2.getClassification().getId());
|
||||
Assert.assertTrue(test.getDue().after(test2.getDue()));
|
||||
Assert.assertFalse(test.getName().equals(test2.getName()));
|
||||
Assert.assertEquals(resultTask.getClassification().getId(), resultTask2.getClassification().getId());
|
||||
Assert.assertTrue(resultTask.getDue().after(resultTask2.getDue()));
|
||||
Assert.assertFalse(resultTask.getName().equals(resultTask2.getName()));
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
|
@ -260,7 +260,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
taskanaEngine.getWorkbasketService().createWorkbasket(workbasket);
|
||||
taskanaEngine.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
Task task = taskServiceImpl.newTask();
|
||||
task.setName("Unit Test Task");
|
||||
task.setWorkbasketId(workbasket.getId());
|
||||
task.setClassification(classification);
|
||||
|
@ -294,7 +294,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
classification.setKey("TEST");
|
||||
taskanaEngine.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = new Task();
|
||||
Task task = taskServiceImpl.newTask();
|
||||
task.setWorkbasketId(workbasket.getId());
|
||||
task.setClassification(classification);
|
||||
return task;
|
||||
|
|
|
@ -12,7 +12,6 @@ import pro.taskana.exceptions.InvalidStateException;
|
|||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.Task;
|
||||
|
||||
@Component
|
||||
@Transactional
|
||||
|
@ -24,7 +23,7 @@ public class ExampleBootstrap {
|
|||
@PostConstruct
|
||||
public void test() throws TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, InvalidStateException, InvalidOwnerException {
|
||||
System.out.println("---------------------------> Start App");
|
||||
Task task = new Task();
|
||||
Task task = taskService.newTask();
|
||||
task.setName("Spring example task");
|
||||
task.setWorkbasketId("1");
|
||||
task = taskService.createTask(task);
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.Task;
|
||||
|
||||
@Component
|
||||
@Transactional
|
||||
|
@ -21,7 +20,7 @@ public class TaskanaComponent {
|
|||
}
|
||||
|
||||
public void triggerRollback() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
||||
Task task = new Task();
|
||||
Task task = taskService.newTask();
|
||||
task.setName("Unit Test Task");
|
||||
task.setWorkbasketId("1");
|
||||
task = taskService.createTask(task);
|
||||
|
|
|
@ -35,20 +35,20 @@ public class ClassificationController {
|
|||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{classificationId}", method = RequestMethod.GET)
|
||||
public ResponseEntity<Classification> getClassification(@PathVariable String classificationId) {
|
||||
@RequestMapping(value = "/{classificationKey}", method = RequestMethod.GET)
|
||||
public ResponseEntity<Classification> getClassification(@PathVariable String classificationKey) {
|
||||
try {
|
||||
Classification classification = classificationService.getClassification(classificationId, "");
|
||||
Classification classification = classificationService.getClassification(classificationKey, "");
|
||||
return ResponseEntity.status(HttpStatus.OK).body(classification);
|
||||
} catch(Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{classificationId}/{domain}", method = RequestMethod.GET)
|
||||
public ResponseEntity<Classification> getClassification(@PathVariable String classificationId, @PathVariable String domain) {
|
||||
@RequestMapping(value = "/{classificationKey}/{domain}", method = RequestMethod.GET)
|
||||
public ResponseEntity<Classification> getClassification(@PathVariable String classificationKey, @PathVariable String domain) {
|
||||
try {
|
||||
Classification classification = classificationService.getClassification(classificationId, domain);
|
||||
Classification classification = classificationService.getClassification(classificationKey, domain);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(classification);
|
||||
} catch(Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
|
|
|
@ -19,13 +19,13 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskService;
|
||||
import pro.taskana.exceptions.InvalidOwnerException;
|
||||
import pro.taskana.exceptions.InvalidStateException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.TaskSummary;
|
||||
import pro.taskana.rest.query.TaskFilter;
|
||||
|
|
|
@ -11,10 +11,10 @@ import org.springframework.util.MultiValueMap;
|
|||
import pro.taskana.ClassificationQuery;
|
||||
import pro.taskana.ClassificationService;
|
||||
import pro.taskana.ObjectReferenceQuery;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskQuery;
|
||||
import pro.taskana.TaskService;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.model.Task;
|
||||
import pro.taskana.model.TaskState;
|
||||
|
||||
@Component
|
||||
|
|
Loading…
Reference in New Issue