MaintenanceServiceImpl implements MaintenanceService { @Override public Set<String> deleteComponent(final Repository repository, final Component component) { checkNotNull(repository); checkNotNull(component); if (!canDeleteComponent(repository, component)) { throw new AuthorizationException(); } return getComponentMaintenanceFacet(repository).deleteComponent(component.getEntityMetadata().getId()); } @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 testDeleteComponent() { when(storageTx.browseAssets(component)).thenReturn(singletonList(assetOne)); when(contentPermissionChecker.isPermitted("maven-releases", "maven2", BreadActions.DELETE, variableSource)) .thenReturn(true); underTest.deleteComponent(mavenReleases, component); verify(storageTx).begin(); verify(storageTx).close(); verify(componentMaintenance).deleteComponent(componentEntityId); }
@Test(expected = AuthorizationException.class) public void testDeleteComponent_NotAuthorized() { when(storageTx.browseAssets(component)).thenReturn(singletonList(assetOne)); when(contentPermissionChecker.isPermitted("maven-releases", "maven2", BreadActions.DELETE, variableSource)) .thenReturn(false); underTest.deleteComponent(mavenReleases, component); }