TSK-15 solve merge conflicts
This commit is contained in:
parent
f753ef6767
commit
26675dcb7a
|
|
@ -343,81 +343,4 @@ public class TaskServiceImpl implements TaskService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void standardSettings(Task task) {
|
|
||||||
Timestamp now = new Timestamp(System.currentTimeMillis());
|
|
||||||
task.setId(IdGenerator.generateWithPrefix(ID_PREFIX_TASK));
|
|
||||||
task.setState(TaskState.READY);
|
|
||||||
task.setCreated(now);
|
|
||||||
task.setModified(now);
|
|
||||||
task.setRead(false);
|
|
||||||
task.setTransferred(false);
|
|
||||||
|
|
||||||
if (task.getPlanned() == null) {
|
|
||||||
task.setPlanned(now);
|
|
||||||
}
|
|
||||||
|
|
||||||
// insert Classification specifications if Classification is given.
|
|
||||||
Classification classification = task.getClassification();
|
|
||||||
if (classification != null) {
|
|
||||||
if (classification.getServiceLevel() != null) {
|
|
||||||
Duration serviceLevel = Duration.parse(task.getClassification().getServiceLevel());
|
|
||||||
LocalDateTime due = task.getPlanned().toLocalDateTime().plus(serviceLevel);
|
|
||||||
task.setDue(Timestamp.valueOf(due));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (task.getName() == null) {
|
|
||||||
task.setName(classification.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (task.getDescription() == null) {
|
|
||||||
task.setDescription(classification.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (task.getPriority() == 0) {
|
|
||||||
task.setPriority(classification.getPriority());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// insert ObjectReference if needed.
|
|
||||||
if (task.getPrimaryObjRef() != null) {
|
|
||||||
ObjectReference objectReference = this.objectReferenceMapper.findByObjectReference(task.getPrimaryObjRef());
|
|
||||||
if (objectReference == null) {
|
|
||||||
objectReference = task.getPrimaryObjRef();
|
|
||||||
objectReference.setId(IdGenerator.generateWithPrefix(ID_PREFIX_OBJECTR_EFERENCE));
|
|
||||||
this.objectReferenceMapper.insert(objectReference);
|
|
||||||
}
|
|
||||||
task.setPrimaryObjRef(objectReference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setCustomers(Task task) {
|
|
||||||
if (task.getCustomAttributes() != null) {
|
|
||||||
for (String custom : task.getCustomAttributes().keySet()) {
|
|
||||||
if (task.getCustom1() == null) {
|
|
||||||
task.setCustom1(custom);
|
|
||||||
} else if (task.getCustom2() == null) {
|
|
||||||
task.setCustom2(custom);
|
|
||||||
} else if (task.getCustom3() == null) {
|
|
||||||
task.setCustom3(custom);
|
|
||||||
} else if (task.getCustom4() == null) {
|
|
||||||
task.setCustom4(custom);
|
|
||||||
} else if (task.getCustom5() == null) {
|
|
||||||
task.setCustom5(custom);
|
|
||||||
} else if (task.getCustom6() == null) {
|
|
||||||
task.setCustom6(custom);
|
|
||||||
} else if (task.getCustom7() == null) {
|
|
||||||
task.setCustom7(custom);
|
|
||||||
} else if (task.getCustom8() == null) {
|
|
||||||
task.setCustom8(custom);
|
|
||||||
} else if (task.getCustom9() == null) {
|
|
||||||
task.setCustom9(custom);
|
|
||||||
} else if (task.getCustom10() == null) {
|
|
||||||
task.setCustom10(custom);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -218,52 +218,6 @@ public class TaskServiceImplTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreateManualTask() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException {
|
|
||||||
ObjectReference expectedObjectReference = new ObjectReference();
|
|
||||||
expectedObjectReference.setId("1");
|
|
||||||
expectedObjectReference.setType("DUMMY");
|
|
||||||
|
|
||||||
Classification classification = new Classification();
|
|
||||||
classification.setName("Name");
|
|
||||||
classification.setCategory("MANUAL");
|
|
||||||
|
|
||||||
Mockito.doReturn(classification).when(classificationServiceMock).getClassification(any(), any());
|
|
||||||
Mockito.doNothing().when(taskMapperMock).insert(any());
|
|
||||||
Mockito.doNothing().when(objectReferenceMapperMock).insert(any());
|
|
||||||
|
|
||||||
Task manualTask = cut.createManualTask("workbasketId", "classification", "domain", null, null, "simply awesome task", expectedObjectReference, null);
|
|
||||||
|
|
||||||
Task manualTask2 = cut.createManualTask("workbasketId", "classification", "domain", Timestamp.valueOf(LocalDateTime.now().minusHours(1)), "Task2", "simply awesome task", expectedObjectReference, null);
|
|
||||||
|
|
||||||
verify(taskanaEngineImpl, times(2)).openConnection();
|
|
||||||
verify(taskanaEngineMock, times(2 + 2)).getWorkbasketService();
|
|
||||||
verify(taskanaEngineMock, times(2)).getClassificationService();
|
|
||||||
verify(workbasketServiceMock, times(2)).checkAuthorization(any(), any());
|
|
||||||
verify(workbasketServiceMock, times(2)).getWorkbasket(any());
|
|
||||||
verify(objectReferenceMapperMock, times(2)).findByObjectReference(any());
|
|
||||||
verify(objectReferenceMapperMock, times(2)).insert(any());
|
|
||||||
verify(taskMapperMock, times(1)).insert(manualTask);
|
|
||||||
verify(taskMapperMock, times(1)).insert(manualTask2);
|
|
||||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
|
||||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
||||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
||||||
|
|
||||||
assertNull(manualTask.getOwner());
|
|
||||||
assertNotNull(manualTask.getCreated());
|
|
||||||
assertNotNull(manualTask.getModified());
|
|
||||||
assertNull(manualTask.getCompleted());
|
|
||||||
assertNull(manualTask.getDue());
|
|
||||||
assertThat(manualTask.getWorkbasketId(), equalTo(manualTask2.getWorkbasketId()));
|
|
||||||
assertThat(manualTask.getName(), equalTo(classification.getName()));
|
|
||||||
assertThat(manualTask.getState(), equalTo(TaskState.READY));
|
|
||||||
assertThat(manualTask.getPrimaryObjRef(), equalTo(expectedObjectReference));
|
|
||||||
assertThat(manualTask.getName(), not(manualTask2.getName()));
|
|
||||||
assertThat(manualTask.getPlanned(), not(manualTask2.getPlanned()));
|
|
||||||
assertThat(manualTask2.getPlanned(), not(manualTask2.getCreated()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = NotAuthorizedException.class)
|
@Test(expected = NotAuthorizedException.class)
|
||||||
public void testCreateThrowingAuthorizedOnWorkbasket() throws NotAuthorizedException, WorkbasketNotFoundException {
|
public void testCreateThrowingAuthorizedOnWorkbasket() throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue