@Test
void testTransferTaskToDestinationWorkbasketWithoutSecurity() throws Exception {

  doReturn(taskanaEngineMock).when(internalTaskanaEngineMock).getEngine();
  doReturn(workbasketServiceMock).when(taskanaEngineMock).getWorkbasketService();
  cut = new TaskTransferrer(internalTaskanaEngineMock, taskMapperMock, taskServiceImplMock);
  final TaskTransferrer cutSpy = Mockito.spy(cut);
  Workbasket destinationWorkbasket = CreateTaskModelHelper.createWorkbasket("2", "k1");
  Workbasket sourceWorkbasket = CreateTaskModelHelper.createWorkbasket("47", "key47");
  Classification dummyClassification = CreateTaskModelHelper.createDummyClassification();
  TaskImpl task =
      CreateTaskModelHelper.createUnitTestTask(
          "1", "Unit Test Task 1", "key47", dummyClassification);
  task.setWorkbasketSummary(sourceWorkbasket.asSummary());
  task.setRead(true);
  doReturn(destinationWorkbasket)
      .when(workbasketServiceMock)
      .getWorkbasket(destinationWorkbasket.getId());
  doReturn(task).when(taskServiceImplMock).getTask(task.getId());
  final Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId());
  verify(internalTaskanaEngineMock, times(1)).openConnection();
  verify(workbasketServiceMock, times(1))
      .checkAuthorization(destinationWorkbasket.getId(), WorkbasketPermission.APPEND);
  verify(workbasketServiceMock, times(1))
      .checkAuthorization(sourceWorkbasket.getId(), WorkbasketPermission.TRANSFER);
  verify(workbasketServiceMock, times(1)).getWorkbasket(destinationWorkbasket.getId());
  verify(taskMapperMock, times(1)).update(any());
  verify(internalTaskanaEngineMock, times(1)).returnConnection();
  verify(internalTaskanaEngineMock, times(1)).getEngine();
  verify(internalTaskanaEngineMock).getHistoryEventManager();
  verify(taskanaEngineMock).getWorkbasketService();
  verifyNoMoreInteractions(
      attachmentMapperMock,
      taskanaEngineConfigurationMock,
      taskanaEngineMock,
      internalTaskanaEngineMock,
      taskMapperMock,
      objectReferenceMapperMock,
      workbasketServiceMock,
      sqlSessionMock,
      classificationQueryImplMock);
  assertThat(actualTask.isRead()).isFalse();
  assertThat(actualTask.getState()).isEqualTo(TaskState.READY);
  assertThat(actualTask.isTransferred()).isTrue();
  assertThat(actualTask.getWorkbasketKey()).isEqualTo(destinationWorkbasket.getKey());
}