diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskServiceImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskServiceImpl.java index b5d7f2901..302c2538d 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskServiceImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskServiceImpl.java @@ -105,8 +105,8 @@ public class TaskServiceImpl implements TaskService { LOGGER.debug("entry to createTask(task = {})", task); try { taskanaEngineImpl.openConnection(); - taskanaEngine.getWorkbasketService().checkAuthorization(task.getWorkbasketId(), WorkbasketAuthorization.APPEND); Workbasket wb = taskanaEngine.getWorkbasketService().getWorkbasket(task.getWorkbasketId()); + taskanaEngine.getWorkbasketService().checkAuthorization(task.getWorkbasketId(), WorkbasketAuthorization.APPEND); Classification classification = task.getClassification(); if (classification == null) { @@ -338,79 +338,5 @@ public class TaskServiceImpl implements TaskService { } task.setPrimaryObjRef(objectReference); } - - //guarantees redundancy of customers and customAttributes - this.checkCustomAttributes(task); - } - - private void checkCustomAttributes(Task task) { - List customList = new ArrayList<>(); - if (task.getCustom1() != null) { - customList.add(task.getCustom1()); - } - if (task.getCustom2() != null) { - customList.add(task.getCustom2()); - } - if (task.getCustom3() != null) { - customList.add(task.getCustom3()); - } - if (task.getCustom4() != null) { - customList.add(task.getCustom4()); - } - if (task.getCustom5() != null) { - customList.add(task.getCustom5()); - } - if (task.getCustom6() != null) { - customList.add(task.getCustom6()); - } - if (task.getCustom7() != null) { - customList.add(task.getCustom7()); - } - if (task.getCustom8() != null) { - customList.add(task.getCustom8()); - } - if (task.getCustom9() != null) { - customList.add(task.getCustom9()); - } - if (task.getCustom10() != null) { - customList.add(task.getCustom10()); - } - - if (task.getCustomAttributes() != null) { - for (String custom : task.getCustomAttributes().keySet()) { - if (!customList.isEmpty() && customList.contains(custom)) { - 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; - } - } - } - } - if (!customList.isEmpty()) { - for (String custom : customList) { - if (!task.getCustomAttributes().containsKey(custom)) { - task.getCustomAttributes().put(custom, null); - } - } - } } } diff --git a/lib/taskana-core/src/test/java/pro/taskana/impl/TaskServiceImplTest.java b/lib/taskana-core/src/test/java/pro/taskana/impl/TaskServiceImplTest.java index c87ae0447..36a54e1a9 100644 --- a/lib/taskana-core/src/test/java/pro/taskana/impl/TaskServiceImplTest.java +++ b/lib/taskana-core/src/test/java/pro/taskana/impl/TaskServiceImplTest.java @@ -261,7 +261,8 @@ public class TaskServiceImplTest { cut.createTask(task); } catch (Exception e) { verify(taskanaEngineImpl, times(1)).openConnection(); - verify(taskanaEngineMock, times(1)).getWorkbasketService(); + verify(taskanaEngineMock, times(2)).getWorkbasketService(); + verify(workbasketServiceMock, times(1)).getWorkbasket(any()); verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any()); verify(taskanaEngineImpl, times(1)).returnConnection(); verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl, @@ -274,7 +275,7 @@ public class TaskServiceImplTest { @Test(expected = WorkbasketNotFoundException.class) public void testCreateThrowsWorkbasketNotFoundException() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException { try { - Mockito.doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock).checkAuthorization(any(), any()); + Mockito.doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock).getWorkbasket(any()); Task task = new Task(); task.setWorkbasketId("1"); @@ -282,7 +283,7 @@ public class TaskServiceImplTest { } catch (Exception e) { verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).getWorkbasketService(); - verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any()); + verify(workbasketServiceMock, times(1)).getWorkbasket(any()); verify(taskanaEngineImpl, times(1)).returnConnection(); verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, diff --git a/lib/taskana-core/src/test/java/pro/taskana/impl/integration/TaskServiceImplIntExplicitTest.java b/lib/taskana-core/src/test/java/pro/taskana/impl/integration/TaskServiceImplIntExplicitTest.java index c263638b8..e10d2571a 100644 --- a/lib/taskana-core/src/test/java/pro/taskana/impl/integration/TaskServiceImplIntExplicitTest.java +++ b/lib/taskana-core/src/test/java/pro/taskana/impl/integration/TaskServiceImplIntExplicitTest.java @@ -23,9 +23,7 @@ import java.sql.Connection; import java.sql.SQLException; import java.sql.Timestamp; import java.time.LocalDateTime; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * Integration Test for TaskServiceImpl transactions with connection management mode EXPLICIT. @@ -132,7 +130,7 @@ public class TaskServiceImplIntExplicitTest { } @Test - public void testCreateTaskWithCustomsAndPlanned() throws SQLException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException { + public void testCreateTaskWithPlannedAndName() throws SQLException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException { Connection connection = dataSource.getConnection(); taskanaEngineImpl.setConnection(connection); @@ -161,27 +159,19 @@ public class TaskServiceImplIntExplicitTest { Assert.assertNotEquals(test.getPlanned(), test.getCreated()); Assert.assertNotNull(test.getDue()); - Map customs = new HashMap(); - customs.put("Daimler", "Tons of money. And cars. And gold."); - customs.put("Audi", 2); - - Task test2 = new Task(); test2.setWorkbasketId(test.getWorkbasketId()); test2.setClassification(classification); test2.setPrimaryObjRef(objectReference); - test2.setName("Name2"); test2.setDescription("desc"); - test2.setCustomAttributes(customs); - test2.setCustom1("Daimler"); - test2.setCustom5("BMW"); taskServiceImpl.createTask(test2); Assert.assertEquals(test2.getPlanned(), test2.getCreated()); + Assert.assertTrue(test2.getName().equals(classification.getName())); - Assert.assertEquals(2 + 1, test2.getCustomAttributes().size()); Assert.assertEquals(test.getClassification().getId(), test2.getClassification().getId()); - Assert.assertTrue(test.getDue().after(test2.getPlanned())); + Assert.assertTrue(test.getDue().after(test2.getDue())); + Assert.assertFalse(test.getName().equals(test2.getName())); } @Test(expected = WorkbasketNotFoundException.class)