TSK-1567: Fixed creating a task using a TaskRouter
This commit is contained in:
parent
7b48d8bb20
commit
542ca3d7eb
|
@ -112,8 +112,12 @@ public class TaskRepresentationModelAssembler
|
||||||
|
|
||||||
public Task toEntityModel(TaskRepresentationModel repModel) throws InvalidArgumentException {
|
public Task toEntityModel(TaskRepresentationModel repModel) throws InvalidArgumentException {
|
||||||
verifyCorrectCustomAttributesFormat(repModel);
|
verifyCorrectCustomAttributesFormat(repModel);
|
||||||
TaskImpl task =
|
TaskImpl task;
|
||||||
(TaskImpl) taskService.newTask(repModel.getWorkbasketSummary().getWorkbasketId());
|
if (repModel.getWorkbasketSummary() != null) {
|
||||||
|
task = (TaskImpl) taskService.newTask(repModel.getWorkbasketSummary().getWorkbasketId());
|
||||||
|
} else {
|
||||||
|
task = (TaskImpl) taskService.newTask();
|
||||||
|
}
|
||||||
task.setId(repModel.getTaskId());
|
task.setId(repModel.getTaskId());
|
||||||
task.setExternalId(repModel.getExternalId());
|
task.setExternalId(repModel.getExternalId());
|
||||||
task.setCreated(repModel.getCreated());
|
task.setCreated(repModel.getCreated());
|
||||||
|
@ -130,7 +134,9 @@ public class TaskRepresentationModelAssembler
|
||||||
task.setState(repModel.getState());
|
task.setState(repModel.getState());
|
||||||
task.setClassificationSummary(
|
task.setClassificationSummary(
|
||||||
classificationAssembler.toEntityModel(repModel.getClassificationSummary()));
|
classificationAssembler.toEntityModel(repModel.getClassificationSummary()));
|
||||||
task.setWorkbasketSummary(workbasketAssembler.toEntityModel(repModel.getWorkbasketSummary()));
|
if (repModel.getWorkbasketSummary() != null) {
|
||||||
|
task.setWorkbasketSummary(workbasketAssembler.toEntityModel(repModel.getWorkbasketSummary()));
|
||||||
|
}
|
||||||
task.setBusinessProcessId(repModel.getBusinessProcessId());
|
task.setBusinessProcessId(repModel.getBusinessProcessId());
|
||||||
task.setParentBusinessProcessId(repModel.getParentBusinessProcessId());
|
task.setParentBusinessProcessId(repModel.getParentBusinessProcessId());
|
||||||
task.setOwner(repModel.getOwner());
|
task.setOwner(repModel.getOwner());
|
||||||
|
|
|
@ -116,8 +116,10 @@ public class TaskSummaryRepresentationModelAssembler
|
||||||
taskSummary.setState(repModel.getState());
|
taskSummary.setState(repModel.getState());
|
||||||
taskSummary.setClassificationSummary(
|
taskSummary.setClassificationSummary(
|
||||||
classificationAssembler.toEntityModel(repModel.getClassificationSummary()));
|
classificationAssembler.toEntityModel(repModel.getClassificationSummary()));
|
||||||
taskSummary.setWorkbasketSummary(
|
if (repModel.getWorkbasketSummary() != null) {
|
||||||
workbasketAssembler.toEntityModel(repModel.getWorkbasketSummary()));
|
taskSummary.setWorkbasketSummary(
|
||||||
|
workbasketAssembler.toEntityModel(repModel.getWorkbasketSummary()));
|
||||||
|
}
|
||||||
taskSummary.setBusinessProcessId(repModel.getBusinessProcessId());
|
taskSummary.setBusinessProcessId(repModel.getBusinessProcessId());
|
||||||
taskSummary.setParentBusinessProcessId(repModel.getParentBusinessProcessId());
|
taskSummary.setParentBusinessProcessId(repModel.getParentBusinessProcessId());
|
||||||
taskSummary.setOwner(repModel.getOwner());
|
taskSummary.setOwner(repModel.getOwner());
|
||||||
|
|
|
@ -116,6 +116,35 @@ class TaskRepresentationModelAssemberTest {
|
||||||
testEquality(task, repModel);
|
testEquality(task, repModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_ReturnEntity_When_ConvertingRepresentationModelWithoutWorkbasketSummaryToEntity()
|
||||||
|
throws Exception {
|
||||||
|
// given
|
||||||
|
ObjectReferenceRepresentationModel primaryObjRef = new ObjectReferenceRepresentationModel();
|
||||||
|
primaryObjRef.setId("abc");
|
||||||
|
ClassificationSummaryRepresentationModel classificationSummary =
|
||||||
|
new ClassificationSummaryRepresentationModel();
|
||||||
|
classificationSummary.setKey("keyabc");
|
||||||
|
classificationSummary.setDomain("DOMAIN_A");
|
||||||
|
classificationSummary.setType("MANUAL");
|
||||||
|
AttachmentRepresentationModel attachment = new AttachmentRepresentationModel();
|
||||||
|
attachment.setClassificationSummary(classificationSummary);
|
||||||
|
attachment.setAttachmentId("attachmentId");
|
||||||
|
attachment.setObjectReference(primaryObjRef);
|
||||||
|
TaskRepresentationModel repModel = new TaskRepresentationModel();
|
||||||
|
repModel.setTaskId("taskId");
|
||||||
|
repModel.setExternalId("externalId");
|
||||||
|
repModel.setClassificationSummary(classificationSummary);
|
||||||
|
repModel.setPrimaryObjRef(primaryObjRef);
|
||||||
|
// when
|
||||||
|
Task task = assembler.toEntityModel(repModel);
|
||||||
|
// then
|
||||||
|
assertThat(repModel.getWorkbasketSummary()).isNull();
|
||||||
|
assertThat(task.getWorkbasketSummary())
|
||||||
|
.isNotNull()
|
||||||
|
.hasAllNullFieldsOrPropertiesExcept("markedForDeletion");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_ReturnRepresentationModel_When_ConvertingEntityToRepresentationModel()
|
void should_ReturnRepresentationModel_When_ConvertingEntityToRepresentationModel()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
|
@ -186,6 +186,34 @@ class TaskSummaryRepresentationModelAssemblerTest {
|
||||||
testEquality(task, repModel);
|
testEquality(task, repModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_ReturnEntity_When_ConvertingRepresentationModelWithoutWorkbasketSummaryToEntity() {
|
||||||
|
// given
|
||||||
|
ObjectReferenceRepresentationModel primaryObjRef = new ObjectReferenceRepresentationModel();
|
||||||
|
primaryObjRef.setId("abc");
|
||||||
|
ClassificationSummaryRepresentationModel classificationSummary =
|
||||||
|
new ClassificationSummaryRepresentationModel();
|
||||||
|
classificationSummary.setKey("keyabc");
|
||||||
|
classificationSummary.setDomain("DOMAIN_A");
|
||||||
|
classificationSummary.setType("MANUAL");
|
||||||
|
AttachmentRepresentationModel attachment = new AttachmentRepresentationModel();
|
||||||
|
attachment.setClassificationSummary(classificationSummary);
|
||||||
|
attachment.setAttachmentId("attachmentId");
|
||||||
|
attachment.setObjectReference(primaryObjRef);
|
||||||
|
TaskRepresentationModel repModel = new TaskRepresentationModel();
|
||||||
|
repModel.setTaskId("taskId");
|
||||||
|
repModel.setExternalId("externalId");
|
||||||
|
repModel.setClassificationSummary(classificationSummary);
|
||||||
|
repModel.setPrimaryObjRef(primaryObjRef);
|
||||||
|
// when
|
||||||
|
TaskSummary taskSummary = assembler.toEntityModel(repModel);
|
||||||
|
// then
|
||||||
|
assertThat(repModel.getWorkbasketSummary()).isNull();
|
||||||
|
assertThat(taskSummary.getWorkbasketSummary())
|
||||||
|
.isNotNull()
|
||||||
|
.hasAllNullFieldsOrPropertiesExcept("markedForDeletion");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_Equal_When_ComparingEntityWithConvertedEntity() {
|
void should_Equal_When_ComparingEntityWithConvertedEntity() {
|
||||||
// given
|
// given
|
||||||
|
|
Loading…
Reference in New Issue