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