private Object findByPrimaryKey(final Method callMethod, final Object[] args, final ThreadContext callContext, final InterfaceType interfaceType) throws OpenEJBException { final BeanContext beanContext = callContext.getBeanContext(); final TransactionPolicy txPolicy = createTransactionPolicy(beanContext.getTransactionType(callMethod, interfaceType), callContext); try { final EntityBean bean = (EntityBean) cmpEngine.loadBean(callContext, args[0]); if (bean == null) { throw new ObjectNotFoundException(beanContext.getDeploymentID() + " : " + args[0]); } // rebuild the primary key final KeyGenerator kg = beanContext.getKeyGenerator(); final Object primaryKey = kg.getPrimaryKey(bean); // create a new ProxyInfo based on the deployment info and primary key return new ProxyInfo(beanContext, primaryKey); } catch (final FinderException fe) { handleApplicationException(txPolicy, fe, false); } catch (final Throwable e) {// handle reflection exception handleSystemException(txPolicy, e, callContext); } finally { afterInvoke(txPolicy, callContext); } throw new AssertionError("Should not get here"); }
/** * Run normalization of defined type for one input id */ @GET @Path("/{normalizationName}/{id}") @Produces(MediaType.APPLICATION_JSON) public Object normalizeOne(@PathParam("normalizationName") String normalizationName, @PathParam(INKEY_ID) String id) throws ObjectNotFoundException { if (SearchUtils.isBlank(normalizationName)) { throw new RequiredFieldException("normalizationName"); } if (SearchUtils.isBlank(id)) { throw new RequiredFieldException(INKEY_ID); } List<StructuredContentPreprocessor> preprocessors = getPreprocessors(normalizationName); return runPreprocessors(preprocessors, id); }
/** * Force reindex for given content type using Searchisko internal indexer. * * @throws ObjectNotFoundException */ @POST @Path("/{type}/_force_reindex") public Response forceReindex(@PathParam("type") @AuditId String type) throws ObjectNotFoundException { Map<String, Object> ic = getIndexerConfigurationWithManagePermissionCheck(type); IndexerHandler ih = getIndexerHandler((String) ic.get(ProviderService.TYPE), type); try { ih.forceReindex(extractIndexerName(ic, type)); return Response.ok("Full reindex forced successfuly").build(); } catch (ObjectNotFoundException e) { throw new ObjectNotFoundException( "Indexer name or type is not configured correctly because indexer instance has not found for content type " + type); } }
/** * Stop indexing for all content types using Searchisko internal indexer. * * @throws ObjectNotFoundException */ @POST @Path("/_all/_stop") public Map<String, String> stopAll() throws ObjectNotFoundException { Map<String, String> ret = new HashMap<>(); List<ProviderContentTypeInfo> allI = getAllIndexerConfigurationsWithManagePermissionCheck(); for (ProviderContentTypeInfo typeInfo : allI) { String typeName = typeInfo.getTypeName(); Map<String, Object> ic = ProviderService.extractIndexerConfiguration(typeInfo.getTypeDef(), typeName); IndexerHandler ih = getIndexerHandler((String) ic.get(ProviderService.TYPE), typeName); try { ih.stop(extractIndexerName(ic, typeName)); ret.put(typeName, "Indexer stopped successfuly"); } catch (ObjectNotFoundException e) { ret.put(typeName, "Indexer name or type is not configured correctly because indexer instance has not found"); } } return ret; }
/** * Stop indexing for given content type using Searchisko internal indexer. * * @throws ObjectNotFoundException */ @POST @Path("/{type}/_stop") public Response stop(@PathParam("type") @AuditId String type) throws ObjectNotFoundException { Map<String, Object> ic = getIndexerConfigurationWithManagePermissionCheck(type); IndexerHandler ih = getIndexerHandler((String) ic.get(ProviderService.TYPE), type); try { ih.stop(extractIndexerName(ic, type)); return Response.ok("Indexer stopped successfuly").build(); } catch (ObjectNotFoundException e) { throw new ObjectNotFoundException( "Indexer name or type is not configured correctly because indexer instance has not found for content type " + type); } }
/** * Restart indexing for all content types using Searchisko internal indexer. * * @throws ObjectNotFoundException */ @POST @Path("/_all/_restart") public Map<String, String> restartAll() throws ObjectNotFoundException { Map<String, String> ret = new HashMap<>(); List<ProviderContentTypeInfo> allI = getAllIndexerConfigurationsWithManagePermissionCheck(); for (ProviderContentTypeInfo typeInfo : allI) { String typeName = typeInfo.getTypeName(); Map<String, Object> ic = ProviderService.extractIndexerConfiguration(typeInfo.getTypeDef(), typeName); IndexerHandler ih = getIndexerHandler((String) ic.get(ProviderService.TYPE), typeName); try { ih.restart(extractIndexerName(ic, typeName)); ret.put(typeName, "Indexer restarted successfuly"); } catch (ObjectNotFoundException e) { ret.put(typeName, "Indexer name or type is not configured correctly because indexer instance has not found"); } } return ret; }
/** * Restart indexing for given content type using Searchisko internal indexer. * * @throws ObjectNotFoundException */ @POST @Path("/{type}/_restart") public Response restart(@PathParam("type") @AuditId String type) throws ObjectNotFoundException { Map<String, Object> ic = getIndexerConfigurationWithManagePermissionCheck(type); IndexerHandler ih = getIndexerHandler((String) ic.get(ProviderService.TYPE), type); try { ih.restart(extractIndexerName(ic, type)); return Response.ok("Indexer restarted successfuly").build(); } catch (ObjectNotFoundException e) { throw new ObjectNotFoundException( "Indexer name or type is not configured correctly because indexer instance has not found for content type " + type); } }
/** * Get status information for all Searchisko internal indexer you have permission to manage. * * @throws ObjectNotFoundException */ @GET @Path("/_all/_status") @AuditIgnore public Map<String, Object> statusAll() throws ObjectNotFoundException { Map<String, Object> ret = new HashMap<>(); List<ProviderContentTypeInfo> allI = getAllIndexerConfigurationsWithManagePermissionCheck(); for (ProviderContentTypeInfo typeInfo : allI) { String typeName = typeInfo.getTypeName(); Map<String, Object> ic = ProviderService.extractIndexerConfiguration(typeInfo.getTypeDef(), typeName); IndexerHandler ih = getIndexerHandler((String) ic.get(ProviderService.TYPE), typeName); try { ret.put(typeName, ih.getStatus(extractIndexerName(ic, typeName))); } catch (ObjectNotFoundException e) { ret.put(typeName, "Indexer name or type is not configured correctly because indexer instance has not found"); } } return ret; }
/** * Get status information of indexer for given content type using Searchisko internal indexer. * * @throws ObjectNotFoundException */ @GET @Path("/{type}/_status") @AuditIgnore public Object getStatus(@PathParam("type") String type) throws ObjectNotFoundException { Map<String, Object> ic = getIndexerConfigurationWithManagePermissionCheck(type); IndexerHandler ih = getIndexerHandler((String) ic.get(ProviderService.TYPE), type); try { return ih.getStatus(extractIndexerName(ic, type)); } catch (ObjectNotFoundException e) { throw new ObjectNotFoundException( "Indexer name or type is not configured correctly because indexer instance has not found for content type " + type); } }
/** * Get indexer configuration for given content type with validations and permission check. * * @param contentType to get indexer configuration for. * @return indexer configuration structure, never null. * @throws ObjectNotFoundException if indexer configuration is not found for given content type * @throws NotAuthorizedException if user is not authorized * @throws NotAuthenticatedException if user is not authenticated * @see AuthenticationUtilService#checkProviderManagementPermission(String) */ protected Map<String, Object> getIndexerConfigurationWithManagePermissionCheck(String contentType) throws ObjectNotFoundException { if (contentType == null || SearchUtils.isBlank(contentType)) { throw new RequiredFieldException("type"); } ProviderContentTypeInfo typeInfo = providerService.findContentType(contentType); if (typeInfo == null) { throw new BadFieldException("type", "content type not found"); } authenticationUtilService.checkProviderManagementPermission(typeInfo.getProviderName()); Map<String, Object> ic = ProviderService.extractIndexerConfiguration(typeInfo.getTypeDef(), contentType); if (ic == null) { throw new ObjectNotFoundException("Indexer is not configured for content type " + contentType); } return ic; }
/** * Get indexer handler based on indexer type. * * @param indexerType to get handler for * @param contentType we handle indexer for - used for error messages only * @return indexer handler, never null. * @throws ObjectNotFoundException if indexer handler for passed in type doesn't exist. */ protected IndexerHandler getIndexerHandler(String indexerType, String contentType) throws ObjectNotFoundException { indexerType = SearchUtils.trimToNull(indexerType); if (indexerType == null) { throw new ObjectNotFoundException("Indexer type is not configured correctly for content type " + contentType); } if (INDEXER_TYPE_ES_RIVER_REMOTE.equals(indexerType)) { return esRiverRemoteIndexerHandler; } else if (INDEXER_TYPE_ES_RIVER_JIRA.equals(indexerType)) { return esRiverJiraIndexerHandler; } else { throw new ObjectNotFoundException("Unsupported indexer type '" + indexerType + "' configured for content type " + contentType); } }
@Override @Lock(LockType.READ) public Object getStatus(String indexerName) throws ObjectNotFoundException { JRStateRequest actionRequest = new JRStateRequest(indexerName); JRStateResponse resp = searchClientService.getClient().admin().cluster() .execute(JRStateAction.INSTANCE, actionRequest).actionGet(); final NodeJRStateResponse nr = resp.getSuccessNodeResponse(); if (nr == null) { throw new ObjectNotFoundException(); } String si = nr.getStateInformation(); try { return SearchUtils.convertToJsonMap(si); } catch (IOException e) { return si; } }
@Test public void contentManipulationLockInfo_all_ok() throws ObjectNotFoundException { ProviderRestService tested = getTested(); Mockito.when(tested.authenticationUtilService.isUserInRole(Role.ADMIN)).thenReturn(true); // case - empty info list List<String> infolist = new ArrayList<>(); Mockito.when(tested.contentManipulationLockService.getLockInfo()).thenReturn(infolist); Map<String, Object> ret = tested.contentManipulationLockInfo(ContentManipulationLockService.API_ID_ALL); Assert.assertEquals(null, ret.get("content_manipulation_lock")); // case - something in info list infolist.add("provider1"); Mockito.when(tested.contentManipulationLockService.getLockInfo()).thenReturn(infolist); ret = tested.contentManipulationLockInfo(ContentManipulationLockService.API_ID_ALL); Assert.assertEquals(infolist, ret.get("content_manipulation_lock")); }
@Test public void extractIndexerName() throws ObjectNotFoundException { IndexerRestService tested = getTested(); Map<String, Object> ic = new HashMap<>(); // case - name not configured try { tested.extractIndexerName(ic, "type"); Assert.fail("ObjectNotFoundException expected"); } catch (ObjectNotFoundException e) { // OK } ic.put(ProviderService.NAME, "myName"); Assert.assertEquals("myName", tested.extractIndexerName(ic, "type")); }
/** * Change code of contributor to new value. Content reindexation task is started to maintain data consistency. * * @param id of contributor to change code for * @param code new code * @return contributor's data after change * @throws ObjectNotFoundException */ public Map<String, Object> changeContributorCode(String id, String code) throws ObjectNotFoundException { code = SearchUtils.trimToNull(code); if (code == null) { throw new RequiredFieldException(FIELD_CODE); } Map<String, Object> entity = get(id); if (entity == null) throw new ObjectNotFoundException(id); String codeFrom = getContributorCode(entity); // no real change in code so stop processing early if (code.equals(codeFrom)) { return entity; } validateCodeUniqueness(code, id); entity.put(FIELD_CODE, code); updateImplRaw(id, entity); Set<String> toRenormalizeContributorCodes = new HashSet<>(); toRenormalizeContributorCodes.add(codeFrom); createContentRenormalizationTask(toRenormalizeContributorCodes, "Change of contributor's code from '" + codeFrom + "' to '" + code + "' for Contributor.id=" + id); eventContributorCodeChanged.fire(new ContributorCodeChangedEvent(codeFrom, code)); return entity; }
/** * Merge two contributors into one. Content reindexation task is started to maintain data consistency. * * @param idFrom identifier of Contributor who is source of merge (so is deleted at the end) * @param idTo identifier of Contributor who is target of merge (so is kept at the end) * @return final Contributor definition which is result of merge * @throws ObjectNotFoundException */ public Map<String, Object> mergeContributors(String idFrom, String idTo) throws ObjectNotFoundException { Map<String, Object> entityFrom = get(idFrom); if (entityFrom == null) throw new ObjectNotFoundException(idFrom); Map<String, Object> entityTo = get(idTo); if (entityTo == null) throw new ObjectNotFoundException(idTo); String codeFrom = getContributorCode(entityFrom); String codeTo = getContributorCode(entityTo); if (SearchUtils.trimToNull(codeTo) == null) { throw new BadFieldException("idTo", "'code' is not defined for this Contributor"); } mergeContributorData(entityTo, entityFrom); updateImplRaw(idTo, entityTo); deleteImpl(idFrom); if (codeFrom != null) { Set<String> toRenormalizeContributorCodes = new HashSet<>(); toRenormalizeContributorCodes.add(codeFrom); createContentRenormalizationTask(toRenormalizeContributorCodes, "Merge of contributor's code from '" + codeFrom + "' to '" + codeTo + "' with final Contributor.id=" + idTo); eventContributorMerged.fire(new ContributorMergedEvent(codeFrom, codeTo)); } else { // only sanity check on data integrity, hope it will never happen log.warning("No code found for merged Contributor.id=" + idFrom + " so reindex and event skipped"); } return entityTo; }
/** * Run normalization of defined type for more input id's */ @GET @Path("/{normalizationName}") @Produces(MediaType.APPLICATION_JSON) public Object normalizeBulk(@PathParam("normalizationName") String normalizationName, @Context UriInfo uriInfo) throws ObjectNotFoundException { if (SearchUtils.isBlank(normalizationName)) { throw new RequiredFieldException("normalizationName"); } if (uriInfo == null || uriInfo.getQueryParameters().isEmpty() || !uriInfo.getQueryParameters().containsKey(INKEY_ID)) { return Response.status(Status.BAD_REQUEST) .entity("Request content must contain 'id' field with array of strings with content identifiers to delete") .build(); } List<String> ids = uriInfo.getQueryParameters().get(INKEY_ID); Map<String, Object> ret = new LinkedHashMap<>(); if (!ids.isEmpty()) { List<StructuredContentPreprocessor> preprocessors = getPreprocessors(normalizationName); for (String id : ids) { ret.put(id, runPreprocessors(preprocessors, id)); } } return ret; }
/** * Get preprocessors for given normalization name. * * @param normalizationName we want preprocessors for * @return list of preprocessors * @throws SettingsException if configuration is incorrect * @throws ObjectNotFoundException if normalization of given name is not found */ @SuppressWarnings("unchecked") public List<StructuredContentPreprocessor> getPreprocessors(String normalizationName) throws SettingsException, ObjectNotFoundException { Map<String, Object> normalizations = configService.get(ConfigService.CFGNAME_NORMALIZATIONS); if (normalizations == null || normalizations.isEmpty() || !normalizations.containsKey(normalizationName)) { throw new ObjectNotFoundException("Normalization '" + normalizationName + "' is not found in configuration."); } Object o = normalizations.get(normalizationName); if (!(o instanceof Map)) { throw new ObjectNotFoundException("Normalization '" + normalizationName + "' is not configured properly."); } Map<String, Object> normalizationDef = (Map<String, Object>) o; try { return StructuredContentPreprocessorFactory.createPreprocessors( extractPreprocessors(normalizationDef, normalizationName), searchClientService.getClient()); } catch (IllegalArgumentException | ClassCastException e) { throw new SettingsException("Bad configuration for normalization '" + normalizationName + "'. Cause: " + e.getMessage(), e); } }
@Override public Response toResponse(ObjectNotFoundException exception) { if (log.isLoggable(Level.FINE)) { log.log(Level.FINE, exception.getMessage(), exception); } return Response.status(Response.Status.NOT_FOUND).entity(exception.getMessage()).build(); }
@POST @Path("/{id}/code/{code}") @Produces(MediaType.APPLICATION_JSON) public Object codeChange(@PathParam("id") @AuditId String id, @AuditContent @PathParam("code") String code) throws ObjectNotFoundException { if ((id = SearchUtils.trimToNull(id)) == null) { throw new RequiredFieldException("id"); } if ((code = SearchUtils.trimToNull(code)) == null) { throw new RequiredFieldException("code"); } return contributorService.changeContributorCode(id, code); }
@POST @Path("/{idFrom}/mergeTo/{idTo}") @Produces(MediaType.APPLICATION_JSON) public Object mergeContributors(@PathParam("idFrom") @AuditId String idFrom, @AuditContent @PathParam("idTo") String idTo) throws ObjectNotFoundException { if ((idFrom = SearchUtils.trimToNull(idFrom)) == null) { throw new RequiredFieldException("idFrom"); } if ((idTo = SearchUtils.trimToNull(idTo)) == null) { throw new RequiredFieldException("id"); } return contributorService.mergeContributors(idFrom, idTo); }
@POST @Path("/{id}/content_manipulation_lock") @RolesAllowed({ Role.ADMIN, Role.PROVIDER }) public Object contentManipulationLockCreate(@PathParam("id") @AuditId String id) throws ObjectNotFoundException { if (StringUtils.isBlank(id)) { throw new RequiredFieldException("id"); } if (ContentManipulationLockService.API_ID_ALL.equals(id)) { if (!authenticationUtilService.isUserInRole(Role.ADMIN)) { throw new NotAuthorizedException("admin permission required"); } contentManipulationLockService.createLockAll(); } else { Map<String, Object> entity = entityService.get(id); if (entity == null) throw new ObjectNotFoundException(); String usernameOfProviderWeChange = entity.get(ProviderService.NAME).toString(); authenticationUtilService.checkProviderManagementPermission(usernameOfProviderWeChange); contentManipulationLockService.createLock(id); } return Response.ok().build(); }
@DELETE @Path("/{id}/content_manipulation_lock") @RolesAllowed({ Role.ADMIN, Role.PROVIDER }) public Object contentManipulationLockDelete(@PathParam("id") @AuditId String id) throws ObjectNotFoundException { if (StringUtils.isBlank(id)) { throw new RequiredFieldException("id"); } if (ContentManipulationLockService.API_ID_ALL.equals(id)) { if (!authenticationUtilService.isUserInRole(Role.ADMIN)) { throw new NotAuthorizedException("admin permission required"); } contentManipulationLockService.removeLockAll(); } else { Map<String, Object> entity = entityService.get(id); if (entity == null) throw new ObjectNotFoundException(); String usernameOfProviderWeChange = entity.get(ProviderService.NAME).toString(); authenticationUtilService.checkProviderManagementPermission(usernameOfProviderWeChange); if (!contentManipulationLockService.removeLock(id)) { throw new NotAuthorizedException("admin permission required"); } } return Response.ok().build(); }
/** * @param contentType of content we work for - used for error messages * @param ic indexer configuration to extract from * @return * @throws ObjectNotFoundException */ protected String extractIndexerName(Map<String, Object> ic, String contentType) throws ObjectNotFoundException { String indexerName = SearchUtils.trimToNull((String) ic.get(ProviderService.NAME)); if (indexerName == null) { throw new ObjectNotFoundException("Indexer name is not configured correctly for content type " + contentType); } return indexerName; }
@Override public void forceReindex(String indexerName) throws ObjectNotFoundException { FullUpdateRequest actionRequest = new FullUpdateRequest(indexerName, null); FullUpdateResponse resp = searchClientService.getClient().admin().cluster() .execute(FullUpdateAction.INSTANCE, actionRequest).actionGet(); NodeFullUpdateResponse nr = resp.getSuccessNodeResponse(); if (nr == null) { throw new ObjectNotFoundException(); } }
private void performLifecycleCommand(String indexerName, JRLifecycleCommand command) throws ObjectNotFoundException { JRLifecycleRequest actionRequest = new JRLifecycleRequest(indexerName, command); JRLifecycleResponse resp = searchClientService.getClient().admin().cluster() .execute(JRLifecycleAction.INSTANCE, actionRequest).actionGet(); final NodeJRLifecycleResponse nr = resp.getSuccessNodeResponse(); if (nr == null) { throw new ObjectNotFoundException(); } }
@Test(expected = ObjectNotFoundException.class) public void mergeContributors_exception() throws Exception { ContributorRestService tested = getTested(); Mockito.when(tested.contributorService.mergeContributors(Mockito.anyString(), Mockito.anyString())).thenThrow( new ObjectNotFoundException()); tested.mergeContributors("id", "id2"); }
@Test(expected = NotAuthorizedException.class) public void contentManipulationLockInfo_provider_noPermission() throws ObjectNotFoundException { ProviderRestService tested = getTested(); mockEntityGet(tested, "provider1"); Mockito.doThrow(new NotAuthorizedException("")).when(tested.authenticationUtilService) .checkProviderManagementPermission("provider1"); tested.contentManipulationLockInfo("provider1"); }
@Test public void contentManipulationLockInfo_provider_nolocklist() throws ObjectNotFoundException { ProviderRestService tested = getTested(); mockEntityGet(tested, "provider1"); Mockito.when(tested.contentManipulationLockService.getLockInfo()).thenReturn(null); Map<String, Object> ret = tested.contentManipulationLockInfo("provider1"); Assert.assertEquals(null, ret.get("content_manipulation_lock")); }
@Test public void contentManipulationLockInfo_provider_nolockinlist() throws ObjectNotFoundException { ProviderRestService tested = getTested(); mockEntityGet(tested, "provider1"); Mockito.when(tested.contentManipulationLockService.getLockInfo()).thenReturn( TestUtils.createListOfStrings("provider2", "provider3")); Map<String, Object> ret = tested.contentManipulationLockInfo("provider1"); Assert.assertEquals(null, ret.get("content_manipulation_lock")); }
@Test public void contentManipulationLockInfo_provider_lockinlist() throws ObjectNotFoundException { ProviderRestService tested = getTested(); mockEntityGet(tested, "provider1"); Mockito.when(tested.contentManipulationLockService.getLockInfo()).thenReturn( TestUtils.createListOfStrings("provider1", "provider3")); Map<String, Object> ret = tested.contentManipulationLockInfo("provider1"); Assert.assertEquals(TestUtils.createListOfStrings("provider1"), ret.get("content_manipulation_lock")); }
@Test public void contentManipulationLockInfo_provider_alllockinlist() throws ObjectNotFoundException { ProviderRestService tested = getTested(); mockEntityGet(tested, "provider1"); Mockito.when(tested.contentManipulationLockService.getLockInfo()).thenReturn( TestUtils.createListOfStrings(ContentManipulationLockService.API_ID_ALL)); Map<String, Object> ret = tested.contentManipulationLockInfo("provider1"); Assert.assertEquals(TestUtils.createListOfStrings(ContentManipulationLockService.API_ID_ALL), ret.get("content_manipulation_lock")); }
@Test(expected = NotAuthorizedException.class) public void contentManipulationLockCreate_all_noPermission() throws ObjectNotFoundException { ProviderRestService tested = getTested(); Mockito.when(tested.authenticationUtilService.isUserInRole(Role.ADMIN)).thenReturn(false); tested.contentManipulationLockCreate(ContentManipulationLockService.API_ID_ALL); Mockito.verifyZeroInteractions(tested.contentManipulationLockService); }
@Test public void contentManipulationLockCreate_all_ok() throws ObjectNotFoundException { ProviderRestService tested = getTested(); Mockito.when(tested.authenticationUtilService.isUserInRole(Role.ADMIN)).thenReturn(true); Object ret = tested.contentManipulationLockCreate(ContentManipulationLockService.API_ID_ALL); TestUtils.assertResponseStatus(ret, Status.OK); Mockito.verify(tested.contentManipulationLockService).createLockAll(); Mockito.verifyZeroInteractions(tested.contentManipulationLockService); }
@Test(expected = NotAuthorizedException.class) public void contentManipulationLockCreate_provider_noPermission() throws ObjectNotFoundException { ProviderRestService tested = getTested(); mockEntityGet(tested, "provider1"); Mockito.doThrow(new NotAuthorizedException("")).when(tested.authenticationUtilService) .checkProviderManagementPermission("provider1"); tested.contentManipulationLockCreate("provider1"); }
@Test public void contentManipulationLockCreate_provider_ok() throws ObjectNotFoundException { ProviderRestService tested = getTested(); mockEntityGet(tested, "provider1"); Object ret = tested.contentManipulationLockCreate("provider1"); TestUtils.assertResponseStatus(ret, Status.OK); Mockito.verify(tested.contentManipulationLockService).createLock("provider1"); Mockito.verifyZeroInteractions(tested.contentManipulationLockService); }
@Test(expected = NotAuthorizedException.class) public void contentManipulationLockDelete_all_noPermission() throws ObjectNotFoundException { ProviderRestService tested = getTested(); Mockito.when(tested.authenticationUtilService.isUserInRole(Role.ADMIN)).thenReturn(false); tested.contentManipulationLockDelete(ContentManipulationLockService.API_ID_ALL); Mockito.verifyZeroInteractions(tested.contentManipulationLockService); }