TSK-157: remove unnecessary method which have been replaced by query.
This commit is contained in:
parent
0e393f35f6
commit
fcef49dcb3
|
@ -15,7 +15,6 @@ import pro.taskana.exceptions.TaskNotFoundException;
|
|||
import pro.taskana.exceptions.TaskanaException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.impl.BulkOperationResults;
|
||||
import pro.taskana.impl.TaskState;
|
||||
|
||||
/**
|
||||
* The Task Service manages all operations on tasks.
|
||||
|
@ -31,7 +30,7 @@ public interface TaskService {
|
|||
* @throws TaskNotFoundException
|
||||
* if the task with taskId was not found
|
||||
* @throws InvalidStateException
|
||||
* if the state of the task with taskId is not {@link TaskState#READY}
|
||||
* if the state of the task with taskId is not READY
|
||||
* @throws InvalidOwnerException
|
||||
* if the task with taskId is claimed by some else
|
||||
*/
|
||||
|
@ -49,7 +48,7 @@ public interface TaskService {
|
|||
* @throws TaskNotFoundException
|
||||
* if the task with taskId was not found
|
||||
* @throws InvalidStateException
|
||||
* if the state of the task with taskId is not {@link TaskState#READY}
|
||||
* if the state of the task with taskId is not READY
|
||||
* @throws InvalidOwnerException
|
||||
* if the task with taskId is claimed by someone else
|
||||
*/
|
||||
|
@ -199,38 +198,6 @@ public interface TaskService {
|
|||
*/
|
||||
TaskQuery createTaskQuery();
|
||||
|
||||
/**
|
||||
* Getting a list of all Task summaries which got matching workbasketIds and states.
|
||||
*
|
||||
* @param workbasketKey
|
||||
* the key of the workbasket where the tasks need to be in.
|
||||
* @param taskState
|
||||
* which is required for the request,
|
||||
* @return a filled/empty list of tasks with attributes which are matching given params.
|
||||
* @throws WorkbasketNotFoundException
|
||||
* if the workbasketId can´t be resolved to a existing work basket.
|
||||
* @throws NotAuthorizedException
|
||||
* if the current user got no rights for reading on this work basket.
|
||||
* @throws ClassificationNotFoundException
|
||||
* if a single Classification can not be found for a task which is returned
|
||||
*/
|
||||
List<TaskSummary> getTasksByWorkbasketKeyAndState(String workbasketKey, TaskState taskState)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException;
|
||||
|
||||
/**
|
||||
* Getting a short summary of all tasks in a specific work basket.
|
||||
*
|
||||
* @param workbasketKey
|
||||
* Key of work basket where tasks are located.
|
||||
* @return TaskSummaryList with all TaskSummaries of a work basket
|
||||
* @throws WorkbasketNotFoundException
|
||||
* if a Work basket can´t be located.
|
||||
* @throws NotAuthorizedException
|
||||
* if the current user got no rights for reading on this work basket.
|
||||
*/
|
||||
List<TaskSummary> getTaskSummariesByWorkbasketKey(String workbasketKey)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* Returns a not persisted instance of {@link Task}.
|
||||
*
|
||||
|
|
|
@ -493,31 +493,6 @@ public class TaskServiceImpl implements TaskService {
|
|||
return new TaskQueryImpl(taskanaEngine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskSummary> getTasksByWorkbasketKeyAndState(String workbasketKey, TaskState taskState)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException {
|
||||
LOGGER.debug("entry to getTasksByWorkbasketKeyAndState(workbasketKey = {}, taskState = {})", workbasketKey,
|
||||
taskState);
|
||||
List<TaskSummary> results = new ArrayList<>();
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
workbasketService.checkAuthorization(workbasketKey, WorkbasketAuthorization.READ);
|
||||
List<TaskSummaryImpl> tasks = taskMapper.findTasksByWorkbasketIdAndState(workbasketKey, taskState);
|
||||
// postprocessing: augment each tasksummary by classificationSummary, workbasketSummary and
|
||||
// list<attachmentsummary>
|
||||
results = augmentTaskSummariesByContainedSummaries(tasks);
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = results == null ? 0 : results.size();
|
||||
LOGGER.debug(
|
||||
"exit from getTasksByWorkbasketIdAndState(workbasketId, taskState). Returning {} resulting Objects: {} ",
|
||||
numberOfResultObjects, LoggerUtils.listToString(results));
|
||||
}
|
||||
}
|
||||
return (results == null) ? new ArrayList<>() : results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task updateTask(Task task)
|
||||
throws InvalidArgumentException, TaskNotFoundException, ConcurrencyException, WorkbasketNotFoundException,
|
||||
|
@ -598,35 +573,6 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskSummary> getTaskSummariesByWorkbasketKey(String workbasketKey)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
LOGGER.debug("entry to getTaskSummariesByWorkbasketId(workbasketId = {}", workbasketKey);
|
||||
List<TaskSummary> results = new ArrayList<>();
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
workbasketService.getWorkbasketByKey(workbasketKey); // make sure that the workbasket exists
|
||||
List<TaskSummaryImpl> taskSummaries = taskMapper.findTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
// postprocessing: augment each tasksummary by classificationSummary, workbasketSummary and
|
||||
// list<attachmentsummary>
|
||||
results = augmentTaskSummariesByContainedSummaries(taskSummaries);
|
||||
|
||||
} catch (WorkbasketNotFoundException | NotAuthorizedException ex) {
|
||||
throw ex;
|
||||
} catch (Exception ex) {
|
||||
LOGGER.error("Getting TASKSUMMARY failed internally.", ex);
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = results.size();
|
||||
LOGGER.debug(
|
||||
"exit from getTaskSummariesByWorkbasketId(workbasketId). Returning {} resulting Objects: {} ",
|
||||
numberOfResultObjects, LoggerUtils.listToString(results));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
List<TaskSummary> augmentTaskSummariesByContainedSummaries(List<TaskSummaryImpl> taskSummaries)
|
||||
throws NotAuthorizedException {
|
||||
LOGGER.debug("entry to augmentTaskSummariesByContainedSummaries()");
|
||||
|
|
|
@ -39,7 +39,6 @@ import pro.taskana.Classification;
|
|||
import pro.taskana.ClassificationSummary;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskService;
|
||||
import pro.taskana.TaskSummary;
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
|
@ -1125,116 +1124,6 @@ public class TaskServiceImplTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTaskSummariesByWorkbasketIdWithInternalException()
|
||||
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException {
|
||||
// given - set behaviour and expected result
|
||||
String workbasketKey = "1";
|
||||
List<TaskSummaryImpl> expectedResultList = new ArrayList<>();
|
||||
doNothing().when(taskanaEngineImpl).openConnection();
|
||||
doThrow(new IllegalArgumentException("Invalid ID: " + workbasketKey)).when(taskMapperMock)
|
||||
.findTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
doNothing().when(taskanaEngineImpl).returnConnection();
|
||||
doReturn(new WorkbasketImpl()).when(workbasketServiceMock).getWorkbasket(any());
|
||||
|
||||
// when - make the call
|
||||
List<TaskSummary> actualResultList = cut.getTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
|
||||
// then - verify external communications and assert result
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(any());
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
assertThat(actualResultList, equalTo(expectedResultList));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTaskSummariesByWorkbasketIdGettingResults()
|
||||
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException {
|
||||
String workbasketKey = "1";
|
||||
WorkbasketSummaryImpl wbs = new WorkbasketSummaryImpl();
|
||||
wbs.setDomain("domain");
|
||||
wbs.setKey("key");
|
||||
ClassificationSummaryImpl cl = new ClassificationSummaryImpl();
|
||||
cl.setDomain("domain");
|
||||
cl.setKey("clKey");
|
||||
TaskSummaryImpl t1 = new TaskSummaryImpl();
|
||||
t1.setWorkbasketSummary(wbs);
|
||||
t1.setDomain("domain");
|
||||
t1.setClassificationSummary(cl);
|
||||
t1.setTaskId("007");
|
||||
TaskSummaryImpl t2 = new TaskSummaryImpl();
|
||||
t2.setWorkbasketSummary(wbs);
|
||||
t2.setDomain("domain");
|
||||
t2.setClassificationSummary(cl);
|
||||
t2.setTaskId("008");
|
||||
List<TaskSummaryImpl> expectedResultList = Arrays.asList(t1, t2);
|
||||
List<ClassificationSummaryImpl> expectedClassifications = Arrays.asList(cl);
|
||||
List<WorkbasketSummaryImpl> expectedWorkbaskets = Arrays.asList(wbs);
|
||||
|
||||
doNothing().when(taskanaEngineImpl).openConnection();
|
||||
doNothing().when(taskanaEngineImpl).returnConnection();
|
||||
doReturn(new WorkbasketImpl()).when(workbasketServiceMock).getWorkbasketByKey(any());
|
||||
doReturn(expectedResultList).when(taskMapperMock).findTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
doReturn(classificationQueryImplMock).when(classificationServiceImplMock).createClassificationQuery();
|
||||
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).keyIn(any());
|
||||
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).domainIn(any());
|
||||
doReturn(workbasketQueryImplMock).when(workbasketServiceMock).createWorkbasketQuery();
|
||||
doReturn(workbasketQueryImplMock).when(workbasketQueryImplMock).keyIn(any());
|
||||
doReturn(expectedWorkbaskets).when(workbasketQueryImplMock).list();
|
||||
|
||||
doReturn(expectedClassifications).when(classificationQueryImplMock).list();
|
||||
|
||||
List<TaskSummary> actualResultList = cut.getTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(workbasketKey);
|
||||
verify(classificationServiceImplMock, times(1)).createClassificationQuery();
|
||||
verify(classificationQueryImplMock, times(1)).domainIn(any());
|
||||
verify(classificationQueryImplMock, times(1)).keyIn(any());
|
||||
verify(classificationQueryImplMock, times(1)).list();
|
||||
verify(workbasketServiceMock, times(1)).createWorkbasketQuery();
|
||||
verify(workbasketQueryImplMock, times(1)).keyIn(any());
|
||||
verify(workbasketQueryImplMock, times(1)).list();
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(attachmentMapperMock, times(1)).findAttachmentSummariesByTaskIds(any());
|
||||
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock,
|
||||
workbasketQueryImplMock,
|
||||
sqlSessionMock, classificationQueryImplMock);
|
||||
assertThat(actualResultList, equalTo(expectedResultList));
|
||||
assertThat(actualResultList.size(), equalTo(expectedResultList.size()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTaskSummariesByWorkbasketIdGettingNull()
|
||||
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException {
|
||||
String workbasketKey = "1";
|
||||
List<TaskSummaryImpl> expectedResultList = new ArrayList<>();
|
||||
doNothing().when(taskanaEngineImpl).openConnection();
|
||||
doNothing().when(taskanaEngineImpl).returnConnection();
|
||||
doReturn(null).when(taskMapperMock).findTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
doReturn(new WorkbasketImpl()).when(workbasketServiceMock).getWorkbasketByKey(any());
|
||||
|
||||
List<TaskSummary> actualResultList = cut.getTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(any());
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskMapperMock, taskanaEngineImpl,
|
||||
workbasketServiceMock);
|
||||
|
||||
assertThat(actualResultList, equalTo(expectedResultList));
|
||||
assertThat(actualResultList.size(), equalTo(expectedResultList.size()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateTaskAddingValidAttachment() throws TaskNotFoundException, SystemException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException,
|
||||
|
|
|
@ -7,7 +7,6 @@ import static org.junit.Assert.fail;
|
|||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -47,7 +46,6 @@ import pro.taskana.impl.ObjectReference;
|
|||
import pro.taskana.impl.TaskImpl;
|
||||
import pro.taskana.impl.TaskServiceImpl;
|
||||
import pro.taskana.impl.TaskState;
|
||||
import pro.taskana.impl.TaskSummaryImpl;
|
||||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
import pro.taskana.impl.WorkbasketImpl;
|
||||
import pro.taskana.impl.WorkbasketType;
|
||||
|
@ -220,58 +218,6 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
Assert.assertEquals(0, results.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnTaskSummaryListWithValues() throws Exception {
|
||||
Workbasket dummyWorkbasket = workbasketService.newWorkbasket("Dummy-Key");
|
||||
dummyWorkbasket.setName("Dummy-Basket");
|
||||
dummyWorkbasket.setType(WorkbasketType.GROUP);
|
||||
dummyWorkbasket.setDomain("novatec");
|
||||
dummyWorkbasket = workbasketService.createWorkbasket(dummyWorkbasket);
|
||||
|
||||
Classification dummyClassification = classificationService.newClassification("novatec", "1", "t1");
|
||||
dummyClassification.setName("Dummy-Classification");
|
||||
classificationService.createClassification(dummyClassification);
|
||||
|
||||
TaskImpl dummyTask = (TaskImpl) taskServiceImpl.newTask(dummyWorkbasket.getKey());
|
||||
dummyTask.setId(null);
|
||||
dummyTask.setName("Dummy-Task");
|
||||
dummyTask.setClassificationKey(dummyClassification.getKey());
|
||||
dummyTask.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
|
||||
dummyTask = (TaskImpl) taskServiceImpl.createTask(dummyTask);
|
||||
|
||||
List<TaskSummaryImpl> expectedTaskSumamries = new ArrayList<>();
|
||||
TaskSummaryImpl taskSummary = (TaskSummaryImpl) taskServiceImpl.newTask(dummyTask.getWorkbasketKey())
|
||||
.asSummary();
|
||||
taskSummary.setTaskId(dummyTask.getId());
|
||||
taskSummary.setName(dummyTask.getName());
|
||||
expectedTaskSumamries.add(taskSummary);
|
||||
|
||||
List<TaskSummary> actualTaskSumamryResult = taskServiceImpl
|
||||
.getTaskSummariesByWorkbasketKey(dummyWorkbasket.getKey());
|
||||
|
||||
assertThat(actualTaskSumamryResult.size(), equalTo(expectedTaskSumamries.size()));
|
||||
}
|
||||
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void shouldThrowWorkbasketNotFoundExceptionByNullParameter()
|
||||
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException {
|
||||
taskServiceImpl.getTaskSummariesByWorkbasketKey(null);
|
||||
}
|
||||
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void shouldThrowWorkbasketNotFoundExceptionByInvalidWorkbasketParameter()
|
||||
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException {
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("key");
|
||||
wb.setName("wb");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
wb.setDomain("novatec");
|
||||
workbasketService.createWorkbasket(wb);
|
||||
taskServiceImpl.getTaskSummariesByWorkbasketKey("1");
|
||||
wb = (WorkbasketImpl) workbasketService.createWorkbasket(wb);
|
||||
workbasketService.createWorkbasket(wb);
|
||||
taskServiceImpl.getTaskSummariesByWorkbasketKey("1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldTransferTaskToOtherWorkbasket()
|
||||
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
|
||||
|
|
|
@ -27,8 +27,8 @@ import pro.taskana.exceptions.InvalidArgumentException;
|
|||
import pro.taskana.exceptions.InvalidOwnerException;
|
||||
import pro.taskana.exceptions.InvalidStateException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.impl.TaskState;
|
||||
import pro.taskana.rest.query.TaskFilter;
|
||||
|
||||
|
@ -76,12 +76,13 @@ public class TaskController {
|
|||
@PathVariable(value = "workbasketKey") String workbasketKey,
|
||||
@PathVariable(value = "taskState") TaskState taskState) {
|
||||
try {
|
||||
List<TaskSummary> taskList = taskService.getTasksByWorkbasketKeyAndState(workbasketKey, taskState);
|
||||
List<TaskSummary> taskList = taskService.createTaskQuery()
|
||||
.workbasketKeyIn(workbasketKey)
|
||||
.stateIn(taskState)
|
||||
.list();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(taskList);
|
||||
} catch (WorkbasketNotFoundException e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
|
||||
} catch (NotAuthorizedException e) {
|
||||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
|
||||
} catch (NotAuthorizedToQueryWorkbasketException e) {
|
||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
|
@ -147,8 +148,10 @@ public class TaskController {
|
|||
@PathVariable(value = "workbasketKey") String workbasketKey) {
|
||||
List<TaskSummary> taskSummaries = null;
|
||||
try {
|
||||
taskSummaries = taskService.getTaskSummariesByWorkbasketKey(workbasketKey);
|
||||
taskSummaries = taskService.createTaskQuery().workbasketKeyIn(workbasketKey).list();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(taskSummaries);
|
||||
} catch (NotAuthorizedToQueryWorkbasketException e) {
|
||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
|
||||
} catch (Exception ex) {
|
||||
if (taskSummaries == null) {
|
||||
taskSummaries = Collections.emptyList();
|
||||
|
|
Loading…
Reference in New Issue