@WithMockUser @Test void testCopyResourcesRootPackage() { ResourceCopyJobExecution copyJobExecution = mock(ResourceCopyJobExecution.class); when(copyJobExecutionFactory.create()).thenReturn(copyJobExecution); List<ResourceIdentifier> resources = asList( ResourceIdentifier.builder().setType(ResourceType.PACKAGE).setId("p0").build(), ResourceIdentifier.builder().setType(ResourceType.ENTITY_TYPE).setId("e0").build()); assertEquals(copyJobExecution, navigatorServiceImpl.copyResources(resources, null)); verify(copyJobExecution).setResources(resources); verify(copyJobExecution).setTargetPackage(null); verify(jobExecutor).submit(copyJobExecution); }
@Override public JobExecution copyResources( List<ResourceIdentifier> resources, @Nullable @CheckForNull String targetFolderId) { if (resources.isEmpty()) { throw new IllegalArgumentException(MESSAGE_EMPTY_RESOURCES); } Package aPackage = getPackage(targetFolderId); ResourceCopyJobExecution jobExecution = copyJobExecutionFactory.create(); jobExecution.setResources(resources); jobExecution.setTargetPackage(aPackage != null ? aPackage.getId() : null); jobExecutor.submit(jobExecution); return jobExecution; }
NavigatorServiceImpl implements NavigatorService { @Override public JobExecution copyResources( List<ResourceIdentifier> resources, @Nullable @CheckForNull String targetFolderId) { if (resources.isEmpty()) { throw new IllegalArgumentException(MESSAGE_EMPTY_RESOURCES); } Package aPackage = getPackage(targetFolderId); ResourceCopyJobExecution jobExecution = copyJobExecutionFactory.create(); jobExecution.setResources(resources); jobExecution.setTargetPackage(aPackage != null ? aPackage.getId() : null); jobExecutor.submit(jobExecution); return jobExecution; } }
NavigatorServiceImpl implements NavigatorService { @Override public JobExecution copyResources( List<ResourceIdentifier> resources, @Nullable @CheckForNull String targetFolderId) { if (resources.isEmpty()) { throw new IllegalArgumentException(MESSAGE_EMPTY_RESOURCES); } Package aPackage = getPackage(targetFolderId); ResourceCopyJobExecution jobExecution = copyJobExecutionFactory.create(); jobExecution.setResources(resources); jobExecution.setTargetPackage(aPackage != null ? aPackage.getId() : null); jobExecutor.submit(jobExecution); return jobExecution; } NavigatorServiceImpl(
      DataService dataService,
      JobExecutor jobExecutor,
      ResourceDownloadJobExecutionFactory downloadJobExecutionFactory,
      ResourceCopyJobExecutionFactory copyJobExecutionFactory,
      ResourceDeleteJobExecutionFactory resourceDeleteJobExecutionFactory); }
NavigatorServiceImpl implements NavigatorService { @Override public JobExecution copyResources( List<ResourceIdentifier> resources, @Nullable @CheckForNull String targetFolderId) { if (resources.isEmpty()) { throw new IllegalArgumentException(MESSAGE_EMPTY_RESOURCES); } Package aPackage = getPackage(targetFolderId); ResourceCopyJobExecution jobExecution = copyJobExecutionFactory.create(); jobExecution.setResources(resources); jobExecution.setTargetPackage(aPackage != null ? aPackage.getId() : null); jobExecutor.submit(jobExecution); return jobExecution; } NavigatorServiceImpl(
      DataService dataService,
      JobExecutor jobExecutor,
      ResourceDownloadJobExecutionFactory downloadJobExecutionFactory,
      ResourceCopyJobExecutionFactory copyJobExecutionFactory,
      ResourceDeleteJobExecutionFactory resourceDeleteJobExecutionFactory); @Transactional(readOnly = true) @Override @Nullable @CheckForNull Folder getFolder(@Nullable @CheckForNull String folderId); @Transactional(readOnly = true) @Override List<Resource> getResources(@Nullable @CheckForNull String folderId); @Transactional(readOnly = true) @Override List<Resource> findResources(String query); @Transactional @Override void moveResources(
      List<ResourceIdentifier> resources, @Nullable @CheckForNull String targetFolderId); @Override JobExecution copyResources(
      List<ResourceIdentifier> resources, @Nullable @CheckForNull String targetFolderId); @Override JobExecution downloadResources(List<ResourceIdentifier> resources); @Transactional @Override JobExecution deleteResources(List<ResourceIdentifier> resources); @Transactional @Override void updateResource(Resource resource); }
NavigatorServiceImpl implements NavigatorService { @Override public JobExecution copyResources( List<ResourceIdentifier> resources, @Nullable @CheckForNull String targetFolderId) { if (resources.isEmpty()) { throw new IllegalArgumentException(MESSAGE_EMPTY_RESOURCES); } Package aPackage = getPackage(targetFolderId); ResourceCopyJobExecution jobExecution = copyJobExecutionFactory.create(); jobExecution.setResources(resources); jobExecution.setTargetPackage(aPackage != null ? aPackage.getId() : null); jobExecutor.submit(jobExecution); return jobExecution; } NavigatorServiceImpl(
      DataService dataService,
      JobExecutor jobExecutor,
      ResourceDownloadJobExecutionFactory downloadJobExecutionFactory,
      ResourceCopyJobExecutionFactory copyJobExecutionFactory,
      ResourceDeleteJobExecutionFactory resourceDeleteJobExecutionFactory); @Transactional(readOnly = true) @Override @Nullable @CheckForNull Folder getFolder(@Nullable @CheckForNull String folderId); @Transactional(readOnly = true) @Override List<Resource> getResources(@Nullable @CheckForNull String folderId); @Transactional(readOnly = true) @Override List<Resource> findResources(String query); @Transactional @Override void moveResources(
      List<ResourceIdentifier> resources, @Nullable @CheckForNull String targetFolderId); @Override JobExecution copyResources(
      List<ResourceIdentifier> resources, @Nullable @CheckForNull String targetFolderId); @Override JobExecution downloadResources(List<ResourceIdentifier> resources); @Transactional @Override JobExecution deleteResources(List<ResourceIdentifier> resources); @Transactional @Override void updateResource(Resource resource);  }