TSK-1168: made interfaces clonable with a new "copy()" method, added tests
This commit is contained in:
parent
9013eaa573
commit
7d7a9e123e
|
|
@ -36,6 +36,27 @@ public interface Classification extends ClassificationSummary {
|
||||||
*/
|
*/
|
||||||
String getDomain();
|
String getDomain();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the logical name of the associated application entry point.
|
||||||
|
*
|
||||||
|
* @return applicationEntryPoint
|
||||||
|
*/
|
||||||
|
String getApplicationEntryPoint();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the logical name of the associated application entry point.
|
||||||
|
*
|
||||||
|
* @param applicationEntryPoint The application entry point
|
||||||
|
*/
|
||||||
|
void setApplicationEntryPoint(String applicationEntryPoint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicates this Classification.
|
||||||
|
*
|
||||||
|
* @return a copy of this Classification
|
||||||
|
*/
|
||||||
|
Classification copy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a flag if the classification if currently valid in the used domain.
|
* Get a flag if the classification if currently valid in the used domain.
|
||||||
*
|
*
|
||||||
|
|
@ -101,20 +122,6 @@ public interface Classification extends ClassificationSummary {
|
||||||
*/
|
*/
|
||||||
void setServiceLevel(String serviceLevel);
|
void setServiceLevel(String serviceLevel);
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the logical name of the associated application entry point.
|
|
||||||
*
|
|
||||||
* @return applicationEntryPoint
|
|
||||||
*/
|
|
||||||
String getApplicationEntryPoint();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the logical name of the associated application entry point.
|
|
||||||
*
|
|
||||||
* @param applicationEntryPoint The application entry point
|
|
||||||
*/
|
|
||||||
void setApplicationEntryPoint(String applicationEntryPoint);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set/Change the 1. custom-attribute.
|
* Set/Change the 1. custom-attribute.
|
||||||
*
|
*
|
||||||
|
|
@ -177,11 +184,4 @@ public interface Classification extends ClassificationSummary {
|
||||||
* @return the ClassificationSummary object for the current classification
|
* @return the ClassificationSummary object for the current classification
|
||||||
*/
|
*/
|
||||||
ClassificationSummary asSummary();
|
ClassificationSummary asSummary();
|
||||||
|
|
||||||
/**
|
|
||||||
* Duplicates this Classification
|
|
||||||
*
|
|
||||||
* @return a copy of this Classification
|
|
||||||
*/
|
|
||||||
Classification clone();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ package pro.taskana.classification.api.models;
|
||||||
* Interface for ClassificationSummaries. This is a specific short model-object which only requieres
|
* Interface for ClassificationSummaries. This is a specific short model-object which only requieres
|
||||||
* the most important informations. Specific ones can be load afterwards via ID.
|
* the most important informations. Specific ones can be load afterwards via ID.
|
||||||
*/
|
*/
|
||||||
public interface ClassificationSummary extends Cloneable {
|
public interface ClassificationSummary {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the id of the classification.
|
* Gets the id of the classification.
|
||||||
|
|
@ -141,9 +141,9 @@ public interface ClassificationSummary extends Cloneable {
|
||||||
String getCustom8();
|
String getCustom8();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicates this ClassificationSummary
|
* Duplicates this ClassificationSummary.
|
||||||
*
|
*
|
||||||
* @return a copy of this ClassificationSummary
|
* @return a copy of this ClassificationSummary
|
||||||
*/
|
*/
|
||||||
ClassificationSummary clone();
|
ClassificationSummary copy();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -335,7 +335,7 @@ public class ClassificationServiceImpl implements ClassificationService {
|
||||||
private void addClassificationToMasterDomain(ClassificationImpl classificationImpl) {
|
private void addClassificationToMasterDomain(ClassificationImpl classificationImpl) {
|
||||||
if (!Objects.equals(classificationImpl.getDomain(), "")) {
|
if (!Objects.equals(classificationImpl.getDomain(), "")) {
|
||||||
boolean doesExist = true;
|
boolean doesExist = true;
|
||||||
ClassificationImpl masterClassification = new ClassificationImpl(classificationImpl);
|
ClassificationImpl masterClassification = classificationImpl.copy();
|
||||||
masterClassification.setId(IdGenerator.generateWithPrefix(ID_PREFIX_CLASSIFICATION));
|
masterClassification.setId(IdGenerator.generateWithPrefix(ID_PREFIX_CLASSIFICATION));
|
||||||
masterClassification.setParentKey(classificationImpl.getParentKey());
|
masterClassification.setParentKey(classificationImpl.getParentKey());
|
||||||
masterClassification.setDomain("");
|
masterClassification.setDomain("");
|
||||||
|
|
|
||||||
|
|
@ -62,16 +62,6 @@ public class ClassificationImpl extends ClassificationSummaryImpl implements Cla
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getApplicationEntryPoint() {
|
|
||||||
return applicationEntryPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setApplicationEntryPoint(String applicationEntryPoint) {
|
|
||||||
this.applicationEntryPoint = applicationEntryPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClassificationSummary asSummary() {
|
public ClassificationSummary asSummary() {
|
||||||
ClassificationSummaryImpl summary = new ClassificationSummaryImpl();
|
ClassificationSummaryImpl summary = new ClassificationSummaryImpl();
|
||||||
|
|
@ -97,15 +87,25 @@ public class ClassificationImpl extends ClassificationSummaryImpl implements Cla
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canEqual(Object other) {
|
@Override
|
||||||
return (other instanceof ClassificationImpl);
|
public String getApplicationEntryPoint() {
|
||||||
|
return applicationEntryPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClassificationImpl clone() {
|
public void setApplicationEntryPoint(String applicationEntryPoint) {
|
||||||
|
this.applicationEntryPoint = applicationEntryPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClassificationImpl copy() {
|
||||||
return new ClassificationImpl(this);
|
return new ClassificationImpl(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(Object other) {
|
||||||
|
return (other instanceof ClassificationImpl);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(super.hashCode(), isValidInDomain, created, modified, description);
|
return Objects.hash(super.hashCode(), isValidInDomain, created, modified, description);
|
||||||
|
|
|
||||||
|
|
@ -222,13 +222,13 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
|
||||||
this.custom8 = custom8;
|
this.custom8 = custom8;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canEqual(Object other) {
|
@Override
|
||||||
return (other instanceof ClassificationSummaryImpl);
|
public ClassificationSummaryImpl copy() {
|
||||||
|
return new ClassificationSummaryImpl(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected boolean canEqual(Object other) {
|
||||||
public ClassificationSummaryImpl clone() {
|
return (other instanceof ClassificationSummaryImpl);
|
||||||
return new ClassificationSummaryImpl(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,9 @@ public interface Attachment extends AttachmentSummary {
|
||||||
AttachmentSummary asSummary();
|
AttachmentSummary asSummary();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicates this Attachment
|
* Duplicates this Attachment.
|
||||||
*
|
*
|
||||||
* @return a copy of this Attachment
|
* @return a copy of this Attachment
|
||||||
*/
|
*/
|
||||||
Attachment clone();
|
Attachment copy();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import pro.taskana.classification.api.models.ClassificationSummary;
|
||||||
* Interface for AttachmentSummaries. This is a specific short model-object which only contains the
|
* Interface for AttachmentSummaries. This is a specific short model-object which only contains the
|
||||||
* most important information.
|
* most important information.
|
||||||
*/
|
*/
|
||||||
public interface AttachmentSummary extends Cloneable {
|
public interface AttachmentSummary {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the id of the attachment.
|
* Gets the id of the attachment.
|
||||||
|
|
@ -67,9 +67,9 @@ public interface AttachmentSummary extends Cloneable {
|
||||||
Instant getReceived();
|
Instant getReceived();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicates this AttachmentSummary
|
* Duplicates this AttachmentSummary.
|
||||||
*
|
*
|
||||||
* @return a copy of this AttachmentSummary
|
* @return a copy of this AttachmentSummary
|
||||||
*/
|
*/
|
||||||
AttachmentSummary clone();
|
AttachmentSummary copy();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||||
|
|
||||||
/** ObjectReference entity. */
|
/** ObjectReference entity. */
|
||||||
public class ObjectReference implements Cloneable {
|
public class ObjectReference {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ObjectReference.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ObjectReference.class);
|
||||||
private String id;
|
private String id;
|
||||||
private String company;
|
private String company;
|
||||||
|
|
@ -102,8 +102,7 @@ public class ObjectReference implements Cloneable {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected ObjectReference copy() {
|
||||||
protected ObjectReference clone() {
|
|
||||||
return new ObjectReference(this);
|
return new ObjectReference(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -189,9 +189,9 @@ public interface Task extends TaskSummary {
|
||||||
String getClassificationCategory();
|
String getClassificationCategory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicates this Task
|
* Duplicates this Task.
|
||||||
*
|
*
|
||||||
* @return a copy of this Task
|
* @return a copy of this Task
|
||||||
*/
|
*/
|
||||||
Task clone();
|
Task copy();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package pro.taskana.task.api.models;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
/** TaskComment-Interface to specify TaskComment Attributes. */
|
/** TaskComment-Interface to specify TaskComment Attributes. */
|
||||||
public interface TaskComment extends Cloneable {
|
public interface TaskComment {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the id of the task comment.
|
* Gets the id of the task comment.
|
||||||
|
|
@ -33,8 +33,11 @@ public interface TaskComment extends Cloneable {
|
||||||
*/
|
*/
|
||||||
String getTextField();
|
String getTextField();
|
||||||
|
|
||||||
/** Sets the text field of the task comment. */
|
/**
|
||||||
|
* Sets the text field of the task comment.
|
||||||
|
*
|
||||||
* @param textField the text field
|
* @param textField the text field
|
||||||
|
*/
|
||||||
void setTextField(String textField);
|
void setTextField(String textField);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -52,9 +55,9 @@ public interface TaskComment extends Cloneable {
|
||||||
Instant getModified();
|
Instant getModified();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicates this TaskComment
|
* Duplicates this TaskComment.
|
||||||
*
|
*
|
||||||
* @return a copy of this TaskComment
|
* @return a copy of this TaskComment
|
||||||
*/
|
*/
|
||||||
TaskComment clone();
|
TaskComment copy();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import pro.taskana.workbasket.api.models.WorkbasketSummary;
|
||||||
* Interface for TaskSummary. This is a specific short model-object which only contains the most
|
* Interface for TaskSummary. This is a specific short model-object which only contains the most
|
||||||
* important information.
|
* important information.
|
||||||
*/
|
*/
|
||||||
public interface TaskSummary extends Cloneable {
|
public interface TaskSummary {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the id of the task.
|
* Gets the id of the task.
|
||||||
|
|
@ -194,9 +194,9 @@ public interface TaskSummary extends Cloneable {
|
||||||
String getCustomAttribute(String num) throws InvalidArgumentException;
|
String getCustomAttribute(String num) throws InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicates this TaskSummary
|
* Duplicates this TaskSummary.
|
||||||
*
|
*
|
||||||
* @return a copy of this TaskSummary
|
* @return a copy of this TaskSummary
|
||||||
*/
|
*/
|
||||||
TaskSummary clone();
|
TaskSummary copy();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,13 +50,13 @@ public class AttachmentImpl extends AttachmentSummaryImpl implements Attachment
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canEqual(Object other) {
|
@Override
|
||||||
return (!(other instanceof AttachmentImpl));
|
public AttachmentImpl copy() {
|
||||||
|
return new AttachmentImpl(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected boolean canEqual(Object other) {
|
||||||
public AttachmentImpl clone() {
|
return (!(other instanceof AttachmentImpl));
|
||||||
return new AttachmentImpl(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,11 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
|
||||||
this.received = received;
|
this.received = received;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AttachmentSummaryImpl copy() {
|
||||||
|
return new AttachmentSummaryImpl(this);
|
||||||
|
}
|
||||||
|
|
||||||
// auxiliary method to enable MyBatis access to classificationSummary
|
// auxiliary method to enable MyBatis access to classificationSummary
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public ClassificationSummaryImpl getClassificationSummaryImpl() {
|
public ClassificationSummaryImpl getClassificationSummaryImpl() {
|
||||||
|
|
@ -153,11 +158,6 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
|
||||||
return (!(other instanceof AttachmentSummaryImpl));
|
return (!(other instanceof AttachmentSummaryImpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AttachmentSummaryImpl clone() {
|
|
||||||
return new AttachmentSummaryImpl(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(
|
return Objects.hash(
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ public class TaskCommentImpl implements TaskComment {
|
||||||
|
|
||||||
public TaskCommentImpl() {}
|
public TaskCommentImpl() {}
|
||||||
|
|
||||||
private TaskCommentImpl(TaskCommentImpl copyFrom) {
|
public TaskCommentImpl(TaskCommentImpl copyFrom) {
|
||||||
id = copyFrom.id;
|
id = copyFrom.id;
|
||||||
taskId = copyFrom.taskId;
|
taskId = copyFrom.taskId;
|
||||||
textField = copyFrom.textField;
|
textField = copyFrom.textField;
|
||||||
|
|
@ -78,13 +78,13 @@ public class TaskCommentImpl implements TaskComment {
|
||||||
this.modified = modified;
|
this.modified = modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canEqual(Object other) {
|
@Override
|
||||||
return (other instanceof TaskCommentImpl);
|
public TaskCommentImpl copy() {
|
||||||
|
return new TaskCommentImpl(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected boolean canEqual(Object other) {
|
||||||
public TaskCommentImpl clone() {
|
return (other instanceof TaskCommentImpl);
|
||||||
return new TaskCommentImpl(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,11 @@ public class TaskImpl extends TaskSummaryImpl implements Task {
|
||||||
((ClassificationSummaryImpl) this.classificationSummary).setCategory(classificationCategory);
|
((ClassificationSummaryImpl) this.classificationSummary).setCategory(classificationCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TaskImpl copy() {
|
||||||
|
return new TaskImpl(this);
|
||||||
|
}
|
||||||
|
|
||||||
public String getClassificationId() {
|
public String getClassificationId() {
|
||||||
return classificationSummary == null ? null : classificationSummary.getId();
|
return classificationSummary == null ? null : classificationSummary.getId();
|
||||||
}
|
}
|
||||||
|
|
@ -270,11 +275,6 @@ public class TaskImpl extends TaskSummaryImpl implements Task {
|
||||||
return (other instanceof TaskImpl);
|
return (other instanceof TaskImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskImpl clone() {
|
|
||||||
return new TaskImpl(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(
|
return Objects.hash(
|
||||||
|
|
|
||||||
|
|
@ -472,6 +472,11 @@ public class TaskSummaryImpl implements TaskSummary {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TaskSummaryImpl copy() {
|
||||||
|
return new TaskSummaryImpl(this);
|
||||||
|
}
|
||||||
|
|
||||||
// utility method to allow mybatis access to workbasketSummary
|
// utility method to allow mybatis access to workbasketSummary
|
||||||
public WorkbasketSummaryImpl getWorkbasketSummaryImpl() {
|
public WorkbasketSummaryImpl getWorkbasketSummaryImpl() {
|
||||||
return (WorkbasketSummaryImpl) workbasketSummary;
|
return (WorkbasketSummaryImpl) workbasketSummary;
|
||||||
|
|
@ -647,11 +652,6 @@ public class TaskSummaryImpl implements TaskSummary {
|
||||||
return (other instanceof TaskSummaryImpl);
|
return (other instanceof TaskSummaryImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TaskSummaryImpl clone() {
|
|
||||||
return new TaskSummaryImpl(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(
|
return Objects.hash(
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,13 @@ public interface Workbasket extends WorkbasketSummary {
|
||||||
*/
|
*/
|
||||||
void setMarkedForDeletion(boolean markedForDeletion);
|
void setMarkedForDeletion(boolean markedForDeletion);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicates this Workbasket.
|
||||||
|
*
|
||||||
|
* @return a copy of this Workbasket
|
||||||
|
*/
|
||||||
|
Workbasket copy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the owner-ID of the workbasket.
|
* Sets the owner-ID of the workbasket.
|
||||||
*
|
*
|
||||||
|
|
@ -126,11 +133,4 @@ public interface Workbasket extends WorkbasketSummary {
|
||||||
* @return the WorkbasketSummary object for the current work basket
|
* @return the WorkbasketSummary object for the current work basket
|
||||||
*/
|
*/
|
||||||
WorkbasketSummary asSummary();
|
WorkbasketSummary asSummary();
|
||||||
|
|
||||||
/**
|
|
||||||
* Duplicates this Workbasket
|
|
||||||
*
|
|
||||||
* @return a copy of this Workbasket
|
|
||||||
*/
|
|
||||||
Workbasket clone();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ package pro.taskana.workbasket.api.models;
|
||||||
*
|
*
|
||||||
* @author bbr
|
* @author bbr
|
||||||
*/
|
*/
|
||||||
public interface WorkbasketAccessItem extends Cloneable {
|
public interface WorkbasketAccessItem {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current id of the WorkbasketAccessItem.
|
* Returns the current id of the WorkbasketAccessItem.
|
||||||
|
|
@ -317,9 +317,9 @@ public interface WorkbasketAccessItem extends Cloneable {
|
||||||
void setPermCustom12(boolean permCustom12);
|
void setPermCustom12(boolean permCustom12);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicates this WorkbasketAccessItem
|
* Duplicates this WorkbasketAccessItem.
|
||||||
*
|
*
|
||||||
* @return a copy of this WorkbasketAccessItem
|
* @return a copy of this WorkbasketAccessItem
|
||||||
*/
|
*/
|
||||||
WorkbasketAccessItem clone();
|
WorkbasketAccessItem copy();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import pro.taskana.workbasket.api.WorkbasketType;
|
||||||
* Interface for WorkbasketSummary. This is a specific short model-object which only contains the
|
* Interface for WorkbasketSummary. This is a specific short model-object which only contains the
|
||||||
* most important information.
|
* most important information.
|
||||||
*/
|
*/
|
||||||
public interface WorkbasketSummary extends Cloneable {
|
public interface WorkbasketSummary {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the id of the workbasket.
|
* Gets the id of the workbasket.
|
||||||
|
|
@ -121,9 +121,9 @@ public interface WorkbasketSummary extends Cloneable {
|
||||||
boolean isMarkedForDeletion();
|
boolean isMarkedForDeletion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicates this WorkbasketSummary
|
* Duplicates this WorkbasketSummary.
|
||||||
*
|
*
|
||||||
* @return a copy of this WorkbasketSummary
|
* @return a copy of this WorkbasketSummary
|
||||||
*/
|
*/
|
||||||
WorkbasketSummary clone();
|
WorkbasketSummary copy();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -430,7 +430,7 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkbasketAccessItemImpl clone() {
|
public WorkbasketAccessItemImpl copy() {
|
||||||
return new WorkbasketAccessItemImpl(this);
|
return new WorkbasketAccessItemImpl(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,11 @@ public class WorkbasketImpl extends WorkbasketSummaryImpl implements Workbasket
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorkbasketImpl copy() {
|
||||||
|
return new WorkbasketImpl(this);
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean canEqual(Object other) {
|
protected boolean canEqual(Object other) {
|
||||||
return (other instanceof WorkbasketImpl);
|
return (other instanceof WorkbasketImpl);
|
||||||
}
|
}
|
||||||
|
|
@ -105,11 +110,6 @@ public class WorkbasketImpl extends WorkbasketSummaryImpl implements Workbasket
|
||||||
return Objects.equals(created, other.created) && Objects.equals(modified, other.modified);
|
return Objects.equals(created, other.created) && Objects.equals(modified, other.modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public WorkbasketImpl clone() {
|
|
||||||
return new WorkbasketImpl(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "WorkbasketImpl [id="
|
return "WorkbasketImpl [id="
|
||||||
|
|
|
||||||
|
|
@ -250,6 +250,11 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
|
||||||
this.markedForDeletion = markedForDeletion;
|
this.markedForDeletion = markedForDeletion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorkbasketSummaryImpl copy() {
|
||||||
|
return new WorkbasketSummaryImpl(this);
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean canEqual(Object other) {
|
protected boolean canEqual(Object other) {
|
||||||
return (other instanceof WorkbasketSummaryImpl);
|
return (other instanceof WorkbasketSummaryImpl);
|
||||||
}
|
}
|
||||||
|
|
@ -305,11 +310,6 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
|
||||||
&& Objects.equals(orgLevel4, other.orgLevel4);
|
&& Objects.equals(orgLevel4, other.orgLevel4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public WorkbasketSummaryImpl clone() {
|
|
||||||
return new WorkbasketSummaryImpl(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "WorkbasketSummaryImpl [id="
|
return "WorkbasketSummaryImpl [id="
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package pro.taskana.classification.api.models;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import pro.taskana.classification.internal.models.ClassificationImpl;
|
||||||
|
|
||||||
|
class ClassificationModelsCloneTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCloneInClassificationSummary() {
|
||||||
|
Classification dummyClassificationForSummaryTest = new ClassificationImpl();
|
||||||
|
dummyClassificationForSummaryTest.setApplicationEntryPoint("dummyEntryPoint");
|
||||||
|
dummyClassificationForSummaryTest.setCategory("dummyCategory");
|
||||||
|
dummyClassificationForSummaryTest.setCustom1("dummyCustom1");
|
||||||
|
dummyClassificationForSummaryTest.setCustom2("dummyCustom2");
|
||||||
|
dummyClassificationForSummaryTest.setCustom3("dummyCustom3");
|
||||||
|
dummyClassificationForSummaryTest.setCustom4("dummyCustom4");
|
||||||
|
dummyClassificationForSummaryTest.setCustom5("dummyCustom5");
|
||||||
|
dummyClassificationForSummaryTest.setCustom6("dummyCustom6");
|
||||||
|
dummyClassificationForSummaryTest.setCustom7("dummyCustom7");
|
||||||
|
dummyClassificationForSummaryTest.setCustom8("dummyCustom8");
|
||||||
|
dummyClassificationForSummaryTest.setDescription("dummyDescription");
|
||||||
|
dummyClassificationForSummaryTest.setIsValidInDomain(true);
|
||||||
|
dummyClassificationForSummaryTest.setParentId("dummyParentId");
|
||||||
|
dummyClassificationForSummaryTest.setServiceLevel("dummyServiceLevel");
|
||||||
|
dummyClassificationForSummaryTest.setPriority(1);
|
||||||
|
dummyClassificationForSummaryTest.setName("dummyName");
|
||||||
|
dummyClassificationForSummaryTest.setParentKey("dummyParentKey");
|
||||||
|
ClassificationSummary dummyClassificationSummary =
|
||||||
|
dummyClassificationForSummaryTest.asSummary();
|
||||||
|
ClassificationSummary dummyClassificationSummaryCloned = dummyClassificationSummary.copy();
|
||||||
|
assertThat(dummyClassificationSummaryCloned).isEqualTo(dummyClassificationSummary);
|
||||||
|
assertThat(dummyClassificationSummaryCloned).isNotSameAs(dummyClassificationSummary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCloneInClassification() {
|
||||||
|
Classification dummyClassification = new ClassificationImpl();
|
||||||
|
dummyClassification.setApplicationEntryPoint("dummyEntryPoint");
|
||||||
|
dummyClassification.setCategory("dummyCategory");
|
||||||
|
dummyClassification.setCustom1("dummyCustom1");
|
||||||
|
dummyClassification.setCustom2("dummyCustom2");
|
||||||
|
dummyClassification.setCustom3("dummyCustom3");
|
||||||
|
dummyClassification.setCustom4("dummyCustom4");
|
||||||
|
dummyClassification.setCustom5("dummyCustom5");
|
||||||
|
dummyClassification.setCustom6("dummyCustom6");
|
||||||
|
dummyClassification.setCustom7("dummyCustom7");
|
||||||
|
dummyClassification.setCustom8("dummyCustom8");
|
||||||
|
dummyClassification.setDescription("dummyDescription");
|
||||||
|
dummyClassification.setIsValidInDomain(true);
|
||||||
|
dummyClassification.setParentId("dummyParentId");
|
||||||
|
dummyClassification.setServiceLevel("dummyServiceLevel");
|
||||||
|
dummyClassification.setPriority(1);
|
||||||
|
dummyClassification.setName("dummyName");
|
||||||
|
dummyClassification.setParentKey("dummyParentKey");
|
||||||
|
Classification dummyClassificationCloned = dummyClassification.copy();
|
||||||
|
assertThat(dummyClassificationCloned).isEqualTo(dummyClassification);
|
||||||
|
assertThat(dummyClassificationCloned).isNotSameAs(dummyClassification);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,112 @@
|
||||||
|
package pro.taskana.task.api.models;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import pro.taskana.task.internal.CreateTaskModelHelper;
|
||||||
|
import pro.taskana.task.internal.models.TaskCommentImpl;
|
||||||
|
import pro.taskana.task.internal.models.TaskSummaryImpl;
|
||||||
|
|
||||||
|
class TaskModelsCloneTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCloneInTaskSummary() {
|
||||||
|
TaskSummaryImpl dummyTaskSummary = new TaskSummaryImpl();
|
||||||
|
|
||||||
|
Attachment dummyAttachmentForSummaryTestPreClone =
|
||||||
|
CreateTaskModelHelper.createAttachment("uniqueIdForDeepTest", "uniqueTaskIdForDeepTest");
|
||||||
|
AttachmentSummary dummyAttachmentSummary = dummyAttachmentForSummaryTestPreClone.asSummary();
|
||||||
|
ArrayList<AttachmentSummary> attachmentSummaries = new ArrayList<>();
|
||||||
|
attachmentSummaries.add(dummyAttachmentSummary);
|
||||||
|
dummyTaskSummary.setAttachmentSummaries(attachmentSummaries);
|
||||||
|
|
||||||
|
TaskSummary dummyTaskSummaryCloned = dummyTaskSummary.copy();
|
||||||
|
assertThat(dummyTaskSummaryCloned).isEqualTo(dummyTaskSummary);
|
||||||
|
assertThat(dummyTaskSummaryCloned).isNotSameAs(dummyTaskSummary);
|
||||||
|
|
||||||
|
Attachment dummyAttachmentForSummaryTestPostClone =
|
||||||
|
CreateTaskModelHelper.createAttachment(
|
||||||
|
"differentIdForDeepTest", "differentTaskIdForDeepTest");
|
||||||
|
AttachmentSummary dummyAttachmentSummary2 = dummyAttachmentForSummaryTestPostClone.asSummary();
|
||||||
|
attachmentSummaries.add(dummyAttachmentSummary2);
|
||||||
|
assertThat(dummyTaskSummaryCloned).isNotEqualTo(dummyTaskSummary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCloneInTask() {
|
||||||
|
Task dummyTask =
|
||||||
|
CreateTaskModelHelper.createUnitTestTask(
|
||||||
|
"dummyTaskId",
|
||||||
|
"dummyTaskName",
|
||||||
|
"workbasketKey",
|
||||||
|
CreateTaskModelHelper.createDummyClassification());
|
||||||
|
Map<String, String> dummyCustomAttributesPreClone = new HashMap<>();
|
||||||
|
dummyCustomAttributesPreClone.put("dummyAttributeKey", "dummyAttributeValue");
|
||||||
|
dummyTask.setCustomAttributes(dummyCustomAttributesPreClone);
|
||||||
|
Map<String, String> dummyCallbackInfoPreClone = new HashMap<>();
|
||||||
|
dummyCallbackInfoPreClone.put("dummyCallbackKey", "dummyCallbackValue");
|
||||||
|
dummyTask.setCallbackInfo(dummyCallbackInfoPreClone);
|
||||||
|
|
||||||
|
Task dummyTaskCloned = dummyTask.copy();
|
||||||
|
assertThat(dummyTaskCloned).isEqualTo(dummyTask);
|
||||||
|
assertThat(dummyTaskCloned).isNotSameAs(dummyTask);
|
||||||
|
|
||||||
|
dummyCustomAttributesPreClone.put("deepTestAttributeKey", "deepTestAttributeValue");
|
||||||
|
dummyCallbackInfoPreClone.put("deepTestCallbackKey", "deepTestCallbackValue");
|
||||||
|
assertThat(dummyTaskCloned).isNotEqualTo(dummyTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCloneInTaskComment() {
|
||||||
|
TaskCommentImpl dummyComment = new TaskCommentImpl();
|
||||||
|
dummyComment.setTextField("dummyTextField");
|
||||||
|
TaskComment dummyCommentCloned = dummyComment.copy();
|
||||||
|
assertThat(dummyCommentCloned).isEqualTo(dummyComment);
|
||||||
|
assertThat(dummyCommentCloned).isNotSameAs(dummyComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCloneInObjectReference() {
|
||||||
|
ObjectReference dummyReference = new ObjectReference();
|
||||||
|
dummyReference.setId("dummyId");
|
||||||
|
dummyReference.setSystem("dummySystem");
|
||||||
|
dummyReference.setCompany("dummyCompany");
|
||||||
|
dummyReference.setSystemInstance("dummySystemInstance");
|
||||||
|
dummyReference.setType("dummyType");
|
||||||
|
dummyReference.setValue("dummyValue");
|
||||||
|
ObjectReference dummyReferenceCloned = dummyReference.copy();
|
||||||
|
assertThat(dummyReferenceCloned).isEqualTo(dummyReference);
|
||||||
|
assertThat(dummyReferenceCloned).isNotSameAs(dummyReference);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCloneInAttachmentSummary() {
|
||||||
|
Attachment dummyAttachmentForSummaryTest =
|
||||||
|
CreateTaskModelHelper.createAttachment("dummyAttachmentId", "dummyTaskId");
|
||||||
|
AttachmentSummary dummyAttachmentSummary = dummyAttachmentForSummaryTest.asSummary();
|
||||||
|
AttachmentSummary dummyAttachmentSummaryCloned = dummyAttachmentSummary.copy();
|
||||||
|
assertThat(dummyAttachmentSummaryCloned).isEqualTo(dummyAttachmentSummary);
|
||||||
|
assertThat(dummyAttachmentSummaryCloned).isNotSameAs(dummyAttachmentSummary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCloneInAttachment() {
|
||||||
|
Attachment dummyAttachment =
|
||||||
|
CreateTaskModelHelper.createAttachment("dummyAttachmentId", "dummyTaskId");
|
||||||
|
|
||||||
|
Map<String, String> dummyMapPreClone = new HashMap<>();
|
||||||
|
dummyMapPreClone.put("dummyString1", "dummyString2");
|
||||||
|
dummyAttachment.setCustomAttributes(dummyMapPreClone);
|
||||||
|
|
||||||
|
Attachment dummyAttachmentCloned = dummyAttachment.copy();
|
||||||
|
assertThat(dummyAttachmentCloned).isEqualTo(dummyAttachment);
|
||||||
|
assertThat(dummyAttachmentCloned).isNotSameAs(dummyAttachment);
|
||||||
|
|
||||||
|
dummyMapPreClone.put("deepTestString1", "deepTestString2");
|
||||||
|
assertThat(dummyAttachment).isNotEqualTo(dummyAttachmentCloned);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package pro.taskana.task.internal;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import pro.taskana.classification.api.models.Classification;
|
||||||
|
import pro.taskana.classification.internal.models.ClassificationImpl;
|
||||||
|
import pro.taskana.task.api.models.Attachment;
|
||||||
|
import pro.taskana.task.internal.models.AttachmentImpl;
|
||||||
|
import pro.taskana.task.internal.models.TaskImpl;
|
||||||
|
import pro.taskana.workbasket.internal.models.WorkbasketImpl;
|
||||||
|
|
||||||
|
public class CreateTaskModelHelper {
|
||||||
|
|
||||||
|
public static TaskImpl createUnitTestTask(
|
||||||
|
String id, String name, String workbasketKey, Classification classification) {
|
||||||
|
TaskImpl task = new TaskImpl();
|
||||||
|
task.setId(id);
|
||||||
|
task.setExternalId(id);
|
||||||
|
task.setName(name);
|
||||||
|
task.setWorkbasketKey(workbasketKey);
|
||||||
|
task.setDomain("");
|
||||||
|
task.setAttachments(new ArrayList<>());
|
||||||
|
Instant now = Instant.now().minus(Duration.ofMinutes(1L));
|
||||||
|
task.setCreated(now);
|
||||||
|
task.setModified(now);
|
||||||
|
if (classification == null) {
|
||||||
|
classification = createDummyClassification();
|
||||||
|
}
|
||||||
|
task.setClassificationSummary(classification.asSummary());
|
||||||
|
task.setClassificationKey(classification.getKey());
|
||||||
|
task.setDomain(classification.getDomain());
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Classification createDummyClassification() {
|
||||||
|
ClassificationImpl classification = new ClassificationImpl();
|
||||||
|
classification.setName("dummy-classification");
|
||||||
|
classification.setDomain("dummy-domain");
|
||||||
|
classification.setKey("dummy-classification-key");
|
||||||
|
classification.setId("DummyClassificationId");
|
||||||
|
return classification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WorkbasketImpl createWorkbasket(String id, String key) {
|
||||||
|
WorkbasketImpl workbasket = new WorkbasketImpl();
|
||||||
|
workbasket.setId(id);
|
||||||
|
workbasket.setDomain("Domain1");
|
||||||
|
workbasket.setKey(key);
|
||||||
|
workbasket.setName("Workbasket " + id);
|
||||||
|
return workbasket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Attachment createAttachment(String id, String taskId) {
|
||||||
|
AttachmentImpl attachment = new AttachmentImpl();
|
||||||
|
attachment.setId(id);
|
||||||
|
attachment.setTaskId(taskId);
|
||||||
|
return attachment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,15 +9,11 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
|
||||||
import org.mockito.InjectMocks;
|
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
|
||||||
|
|
||||||
import pro.taskana.classification.internal.models.ClassificationImpl;
|
import pro.taskana.classification.internal.models.ClassificationImpl;
|
||||||
import pro.taskana.task.api.models.Attachment;
|
import pro.taskana.task.api.models.Attachment;
|
||||||
import pro.taskana.task.api.models.AttachmentSummary;
|
import pro.taskana.task.api.models.AttachmentSummary;
|
||||||
import pro.taskana.task.api.models.ObjectReference;
|
import pro.taskana.task.api.models.ObjectReference;
|
||||||
import pro.taskana.task.internal.models.AttachmentImpl;
|
|
||||||
import pro.taskana.task.internal.models.TaskImpl;
|
import pro.taskana.task.internal.models.TaskImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -25,16 +21,15 @@ import pro.taskana.task.internal.models.TaskImpl;
|
||||||
* This test should test every interaction with Attachments, which means adding, removing, nulling
|
* This test should test every interaction with Attachments, which means adding, removing, nulling
|
||||||
* them.
|
* them.
|
||||||
*/
|
*/
|
||||||
@ExtendWith(MockitoExtension.class)
|
|
||||||
class TaskAttachmentTest {
|
class TaskAttachmentTest {
|
||||||
|
|
||||||
@InjectMocks private TaskImpl cut;
|
private TaskImpl cut = new TaskImpl();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testAddAttachmentWithValidValue() {
|
void testAddAttachmentWithValidValue() {
|
||||||
Attachment attachment1 = createAttachment("ID1", "taskId1");
|
Attachment attachment1 = CreateTaskModelHelper.createAttachment("ID1", "taskId1");
|
||||||
Attachment attachment2 = createAttachment("ID2", "taskId1");
|
Attachment attachment2 = CreateTaskModelHelper.createAttachment("ID2", "taskId1");
|
||||||
Attachment attachment3 = createAttachment("ID3", "taskId1");
|
Attachment attachment3 = CreateTaskModelHelper.createAttachment("ID3", "taskId1");
|
||||||
|
|
||||||
cut.addAttachment(attachment1);
|
cut.addAttachment(attachment1);
|
||||||
cut.addAttachment(attachment2);
|
cut.addAttachment(attachment2);
|
||||||
|
|
@ -45,7 +40,7 @@ class TaskAttachmentTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testAddNullValue() {
|
void testAddNullValue() {
|
||||||
Attachment attachment1 = createAttachment("ID1", "taskId1");
|
Attachment attachment1 = CreateTaskModelHelper.createAttachment("ID1", "taskId1");
|
||||||
|
|
||||||
cut.addAttachment(attachment1);
|
cut.addAttachment(attachment1);
|
||||||
cut.addAttachment(null);
|
cut.addAttachment(null);
|
||||||
|
|
@ -56,8 +51,8 @@ class TaskAttachmentTest {
|
||||||
@Test
|
@Test
|
||||||
void testAddSameTwice() {
|
void testAddSameTwice() {
|
||||||
// Same values, not same REF. Important.
|
// Same values, not same REF. Important.
|
||||||
Attachment attachment1 = createAttachment("ID1", "taskId1");
|
Attachment attachment1 = CreateTaskModelHelper.createAttachment("ID1", "taskId1");
|
||||||
Attachment attachment2 = createAttachment("ID1", "taskId1");
|
Attachment attachment2 = CreateTaskModelHelper.createAttachment("ID1", "taskId1");
|
||||||
|
|
||||||
cut.addAttachment(attachment1);
|
cut.addAttachment(attachment1);
|
||||||
cut.addAttachment(attachment2);
|
cut.addAttachment(attachment2);
|
||||||
|
|
@ -75,8 +70,8 @@ class TaskAttachmentTest {
|
||||||
@Test
|
@Test
|
||||||
void testRemoveAttachment() {
|
void testRemoveAttachment() {
|
||||||
// Testing normal way
|
// Testing normal way
|
||||||
Attachment attachment1 = createAttachment("ID1", "taskId1");
|
Attachment attachment1 = CreateTaskModelHelper.createAttachment("ID1", "taskId1");
|
||||||
Attachment attachment2 = createAttachment("ID2", "taskId1");
|
Attachment attachment2 = CreateTaskModelHelper.createAttachment("ID2", "taskId1");
|
||||||
cut.addAttachment(attachment1);
|
cut.addAttachment(attachment1);
|
||||||
cut.addAttachment(attachment2);
|
cut.addAttachment(attachment2);
|
||||||
|
|
||||||
|
|
@ -88,7 +83,7 @@ class TaskAttachmentTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testRemoveLoopStopsAtResult() {
|
void testRemoveLoopStopsAtResult() {
|
||||||
Attachment attachment1 = createAttachment("ID2", "taskId1");
|
Attachment attachment1 = CreateTaskModelHelper.createAttachment("ID2", "taskId1");
|
||||||
// adding same uncommon way to test that the loop will stop.
|
// adding same uncommon way to test that the loop will stop.
|
||||||
cut.getAttachments().add(attachment1);
|
cut.getAttachments().add(attachment1);
|
||||||
cut.getAttachments().add(attachment1);
|
cut.getAttachments().add(attachment1);
|
||||||
|
|
@ -110,7 +105,7 @@ class TaskAttachmentTest {
|
||||||
Map<String, String> customAttr = new HashMap<>();
|
Map<String, String> customAttr = new HashMap<>();
|
||||||
customAttr.put("key", "value");
|
customAttr.put("key", "value");
|
||||||
|
|
||||||
Attachment attachment1 = createAttachment("ID1", "taskId1");
|
Attachment attachment1 = CreateTaskModelHelper.createAttachment("ID1", "taskId1");
|
||||||
attachment1.setChannel("channel");
|
attachment1.setChannel("channel");
|
||||||
attachment1.setClassificationSummary(new ClassificationImpl().asSummary());
|
attachment1.setClassificationSummary(new ClassificationImpl().asSummary());
|
||||||
attachment1.setReceived(Instant.now());
|
attachment1.setReceived(Instant.now());
|
||||||
|
|
@ -143,11 +138,4 @@ class TaskAttachmentTest {
|
||||||
summaries = cut.asSummary().getAttachmentSummaries();
|
summaries = cut.asSummary().getAttachmentSummaries();
|
||||||
assertThat(summaries.size(), equalTo(0));
|
assertThat(summaries.size(), equalTo(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Attachment createAttachment(String id, String taskId) {
|
|
||||||
AttachmentImpl attachment = new AttachmentImpl();
|
|
||||||
attachment.setId(id);
|
|
||||||
attachment.setTaskId(taskId);
|
|
||||||
return attachment;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,20 +3,15 @@ package pro.taskana.task.internal;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import pro.taskana.classification.api.models.Classification;
|
import pro.taskana.classification.api.models.Classification;
|
||||||
import pro.taskana.classification.internal.models.ClassificationImpl;
|
|
||||||
import pro.taskana.common.internal.JunitHelper;
|
import pro.taskana.common.internal.JunitHelper;
|
||||||
import pro.taskana.task.api.TaskState;
|
import pro.taskana.task.api.TaskState;
|
||||||
import pro.taskana.task.api.models.ObjectReference;
|
import pro.taskana.task.api.models.ObjectReference;
|
||||||
import pro.taskana.task.api.models.TaskSummary;
|
import pro.taskana.task.api.models.TaskSummary;
|
||||||
import pro.taskana.task.internal.models.TaskImpl;
|
import pro.taskana.task.internal.models.TaskImpl;
|
||||||
import pro.taskana.workbasket.api.models.Workbasket;
|
import pro.taskana.workbasket.api.models.Workbasket;
|
||||||
import pro.taskana.workbasket.internal.models.WorkbasketImpl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit Test for TaskServiceImpl.
|
* Unit Test for TaskServiceImpl.
|
||||||
|
|
@ -27,13 +22,15 @@ class TaskServiceImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTaskSummaryEqualsHashCode() throws InterruptedException {
|
void testTaskSummaryEqualsHashCode() throws InterruptedException {
|
||||||
Classification classification = createDummyClassification();
|
Classification classification = CreateTaskModelHelper.createDummyClassification();
|
||||||
Workbasket wb = createWorkbasket("WB-ID", "WB-Key");
|
Workbasket wb = CreateTaskModelHelper.createWorkbasket("WB-ID", "WB-Key");
|
||||||
ObjectReference objectReference = JunitHelper.createDefaultObjRef();
|
ObjectReference objectReference = JunitHelper.createDefaultObjRef();
|
||||||
TaskImpl taskBefore = createUnitTestTask("ID", "taskName", wb.getKey(), classification);
|
TaskImpl taskBefore =
|
||||||
|
CreateTaskModelHelper.createUnitTestTask("ID", "taskName", wb.getKey(), classification);
|
||||||
taskBefore.setPrimaryObjRef(objectReference);
|
taskBefore.setPrimaryObjRef(objectReference);
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
TaskImpl taskAfter = createUnitTestTask("ID", "taskName", wb.getKey(), classification);
|
TaskImpl taskAfter =
|
||||||
|
CreateTaskModelHelper.createUnitTestTask("ID", "taskName", wb.getKey(), classification);
|
||||||
taskAfter.setPrimaryObjRef(objectReference);
|
taskAfter.setPrimaryObjRef(objectReference);
|
||||||
TaskSummary summaryBefore = taskBefore.asSummary();
|
TaskSummary summaryBefore = taskBefore.asSummary();
|
||||||
TaskSummary summaryAfter = taskAfter.asSummary();
|
TaskSummary summaryAfter = taskAfter.asSummary();
|
||||||
|
|
@ -57,7 +54,7 @@ class TaskServiceImplTest {
|
||||||
assertEquals(summaryBefore, summaryAfter);
|
assertEquals(summaryBefore, summaryAfter);
|
||||||
assertEquals(summaryBefore.hashCode(), summaryAfter.hashCode());
|
assertEquals(summaryBefore.hashCode(), summaryAfter.hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
static TaskImpl createUnitTestTask(
|
static TaskImpl createUnitTestTask(
|
||||||
String id, String name, String workbasketKey, Classification classification) {
|
String id, String name, String workbasketKey, Classification classification) {
|
||||||
TaskImpl task = new TaskImpl();
|
TaskImpl task = new TaskImpl();
|
||||||
|
|
@ -97,4 +94,5 @@ class TaskServiceImplTest {
|
||||||
workbasket.setName("Workbasket " + id);
|
workbasket.setName("Workbasket " + id);
|
||||||
return workbasket;
|
return workbasket;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,12 +74,12 @@ class TaskTransferrerTest {
|
||||||
cut = new TaskTransferrer(internalTaskanaEngineMock, taskMapperMock, taskServiceImplMock);
|
cut = new TaskTransferrer(internalTaskanaEngineMock, taskMapperMock, taskServiceImplMock);
|
||||||
|
|
||||||
final TaskTransferrer cutSpy = Mockito.spy(cut);
|
final TaskTransferrer cutSpy = Mockito.spy(cut);
|
||||||
Workbasket destinationWorkbasket = TaskServiceImplTest.createWorkbasket("2", "k1");
|
Workbasket destinationWorkbasket = CreateTaskModelHelper.createWorkbasket("2", "k1");
|
||||||
Workbasket sourceWorkbasket = TaskServiceImplTest.createWorkbasket("47", "key47");
|
Workbasket sourceWorkbasket = CreateTaskModelHelper.createWorkbasket("47", "key47");
|
||||||
Classification dummyClassification = TaskServiceImplTest.createDummyClassification();
|
Classification dummyClassification = CreateTaskModelHelper.createDummyClassification();
|
||||||
TaskImpl task =
|
TaskImpl task =
|
||||||
TaskServiceImplTest.createUnitTestTask(
|
CreateTaskModelHelper
|
||||||
"1", "Unit Test Task 1", "key47", dummyClassification);
|
.createUnitTestTask("1", "Unit Test Task 1", "key47", dummyClassification);
|
||||||
task.setWorkbasketSummary(sourceWorkbasket.asSummary());
|
task.setWorkbasketSummary(sourceWorkbasket.asSummary());
|
||||||
task.setRead(true);
|
task.setRead(true);
|
||||||
when(workbasketServiceMock.getWorkbasket(destinationWorkbasket.getId()))
|
when(workbasketServiceMock.getWorkbasket(destinationWorkbasket.getId()))
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
package pro.taskana.workbasket.api.models;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
|
||||||
|
import pro.taskana.workbasket.internal.models.WorkbasketImpl;
|
||||||
|
|
||||||
|
class WorkbasketModelsCloneTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCloneInWorkbasketSummary() {
|
||||||
|
Workbasket dummyWorkbasketForSummaryTest = new WorkbasketImpl();
|
||||||
|
dummyWorkbasketForSummaryTest.setCustom1("dummyCustom1");
|
||||||
|
dummyWorkbasketForSummaryTest.setCustom2("dummyCustom2");
|
||||||
|
dummyWorkbasketForSummaryTest.setCustom3("dummyCustom3");
|
||||||
|
dummyWorkbasketForSummaryTest.setCustom4("dummyCustom4");
|
||||||
|
dummyWorkbasketForSummaryTest.setDescription("dummyDescription");
|
||||||
|
dummyWorkbasketForSummaryTest.setMarkedForDeletion(false);
|
||||||
|
dummyWorkbasketForSummaryTest.setName("dummyName");
|
||||||
|
dummyWorkbasketForSummaryTest.setOrgLevel1("dummyOrgLevel1");
|
||||||
|
dummyWorkbasketForSummaryTest.setOrgLevel2("dummyOrgLevel2");
|
||||||
|
dummyWorkbasketForSummaryTest.setOrgLevel3("dummyOrgLevel3");
|
||||||
|
dummyWorkbasketForSummaryTest.setOrgLevel4("dummyOrgLevel4");
|
||||||
|
dummyWorkbasketForSummaryTest.setOwner("dummyOwner");
|
||||||
|
WorkbasketSummary dummyWorkbasketSummary = dummyWorkbasketForSummaryTest.asSummary();
|
||||||
|
WorkbasketSummary dummyWorkbasketSummaryCloned = dummyWorkbasketSummary.copy();
|
||||||
|
assertThat(dummyWorkbasketSummaryCloned).isEqualTo(dummyWorkbasketSummary);
|
||||||
|
assertThat(dummyWorkbasketSummaryCloned).isNotSameAs(dummyWorkbasketSummary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCloneInWorkbasket() {
|
||||||
|
Workbasket dummyWorkbasket = new WorkbasketImpl();
|
||||||
|
dummyWorkbasket.setCustom1("dummyCustom1");
|
||||||
|
dummyWorkbasket.setCustom2("dummyCustom2");
|
||||||
|
dummyWorkbasket.setCustom3("dummyCustom3");
|
||||||
|
dummyWorkbasket.setCustom4("dummyCustom4");
|
||||||
|
dummyWorkbasket.setDescription("dummyDescription");
|
||||||
|
dummyWorkbasket.setMarkedForDeletion(false);
|
||||||
|
dummyWorkbasket.setName("dummyName");
|
||||||
|
dummyWorkbasket.setOrgLevel1("dummyOrgLevel1");
|
||||||
|
dummyWorkbasket.setOrgLevel2("dummyOrgLevel2");
|
||||||
|
dummyWorkbasket.setOrgLevel3("dummyOrgLevel3");
|
||||||
|
dummyWorkbasket.setOrgLevel4("dummyOrgLevel4");
|
||||||
|
dummyWorkbasket.setOwner("dummyOwner");
|
||||||
|
Workbasket dummyWorkbasketCloned = dummyWorkbasket.copy();
|
||||||
|
assertThat(dummyWorkbasketCloned).isEqualTo(dummyWorkbasket);
|
||||||
|
assertThat(dummyWorkbasketCloned).isNotSameAs(dummyWorkbasket);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCloneInWorkbasketAccessItem() {
|
||||||
|
WorkbasketAccessItem dummyWorkbasketAccessItem = new WorkbasketAccessItemImpl();
|
||||||
|
dummyWorkbasketAccessItem.setAccessName("dummyAccessName");
|
||||||
|
dummyWorkbasketAccessItem.setPermAppend(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermCustom1(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermCustom2(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermCustom3(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermCustom4(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermCustom5(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermCustom6(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermCustom7(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermCustom8(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermCustom9(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermCustom10(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermCustom11(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermCustom12(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermDistribute(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermOpen(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermRead(false);
|
||||||
|
dummyWorkbasketAccessItem.setPermTransfer(false);
|
||||||
|
WorkbasketAccessItem dummyWorkbasketAccessItemCloned = dummyWorkbasketAccessItem.copy();
|
||||||
|
assertThat(dummyWorkbasketAccessItemCloned).isEqualTo(dummyWorkbasketAccessItem);
|
||||||
|
assertThat(dummyWorkbasketAccessItemCloned).isNotSameAs(dummyWorkbasketAccessItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue