MaintenanceServiceImpl implements MaintenanceService { @Override public void deleteFolder(final Repository repository, final String path) { checkNotNull(repository); checkNotNull(path); if (!canDeleteFolder(repository, path)) { throw new AuthorizationException(); } executorService.submit(() -> deleteFolderService.deleteFolder(repository, path, DateTime.now(), () -> false)); } @Inject  MaintenanceServiceImpl(final ContentPermissionChecker contentPermissionChecker,
                                final VariableResolverAdapterManager variableResolverAdapterManager,
                                final DeleteFolderService deleteFolderService,
                                final RepositoryPermissionChecker repositoryPermissionChecker); @Override Set<String> deleteAsset(final Repository repository, final Asset asset); @Override Set<String> deleteComponent(final Repository repository, final Component component); @Override void deleteFolder(final Repository repository, final String path); @Override boolean canDeleteComponent(final Repository repository, final Component component); @Override boolean canDeleteAsset(final Repository repository,
                                final Asset asset); @Override boolean canDeleteFolder(final Repository repository,
                                 final String folder);  }
@Test public void testDeleteFolder() { ThreadContext.bind(FakeAlmightySubject.forUserId("disabled-security")); when(repositoryPermissionChecker.userCanDeleteInRepository(mavenReleases)).thenReturn(true); underTest.deleteFolder(mavenReleases, "someFolder"); verify(deleteFolderService, timeout(500)).deleteFolder(eq(mavenReleases), eq("someFolder"), any(DateTime.class), any()); }
@Test(expected = AuthorizationException.class) public void testDeleteFolder_NotAuthorized() { when(contentPermissionChecker.isPermitted("maven-releases", "maven2", BreadActions.DELETE, variableSource)) .thenReturn(false); underTest.deleteFolder(mavenReleases, "somePath"); }