### Question:
IndexerRestService extends RestServiceBase { protected List<ProviderContentTypeInfo> getAllIndexerConfigurationsWithManagePermissionCheck() { List<ProviderContentTypeInfo> ret = new ArrayList<>(); List<Map<String, Object>> allProviders = providerService.getAll(); if (allProviders != null) { for (Map<String, Object> providerDef : allProviders) { String providerName = (String) providerDef.get(ProviderService.NAME); try { authenticationUtilService.checkProviderManagementPermission(providerName); Map<String, Map<String, Object>> allCt = ProviderService.extractAllContentTypes(providerDef); if (allCt != null) { for (String typeName : allCt.keySet()) { Map<String, Object> typeDef = allCt.get(typeName); Map<String, Object> ic = ProviderService.extractIndexerConfiguration(typeDef, typeName); if (ic != null) { ret.add(new ProviderContentTypeInfo(providerDef, typeName)); } } } } catch (NotAuthorizedException e) { } } } return ret; }  @POST @Path("/{type}/_force_reindex") Response forceReindex(@PathParam("type") @AuditId String type); @POST @Path("/_all/_stop") Map<String, String> stopAll(); @POST @Path("/{type}/_stop") Response stop(@PathParam("type") @AuditId String type); @POST @Path("/_all/_restart") Map<String, String> restartAll(); @POST @Path("/{type}/_restart") Response restart(@PathParam("type") @AuditId String type); @GET @Path("/_all/_status") @AuditIgnore Map<String, Object> statusAll(); @GET @Path("/{type}/_status") @AuditIgnore Object getStatus(@PathParam("type") String type); static final String INDEXER_TYPE_ES_RIVER_REMOTE; static final String INDEXER_TYPE_ES_RIVER_JIRA; }### Answer:
@Test public void getAllIndexerConfigurationsWithManagePermissionCheck() { IndexerRestService tested = getTested(); { List<ProviderContentTypeInfo> ret = tested.getAllIndexerConfigurationsWithManagePermissionCheck(); Assert.assertNotNull(ret); Assert.assertEquals(0, ret.size()); } { List<Map<String, Object>> allProviders = new ArrayList<>(); allProviders.add(TestUtils.loadJSONFromClasspathFile("/indexer/provider_1.json")); allProviders.add(TestUtils.loadJSONFromClasspathFile("/indexer/provider_2.json")); Mockito.when(tested.providerService.getAll()).thenReturn(allProviders); Mockito.doThrow(new NotAuthorizedException("no perm")).when(tested.authenticationUtilService) .checkProviderManagementPermission(TEST_PROVIDER_NAME_UNAUTH); List<ProviderContentTypeInfo> ret = tested.getAllIndexerConfigurationsWithManagePermissionCheck(); Assert.assertNotNull(ret); Assert.assertEquals(2, ret.size()); Assert.assertEquals(ProviderServiceTest.TEST_PROVIDER_NAME, ret.get(0).getProviderName()); Assert.assertEquals("jbossorg_type_1", ret.get(0).getTypeName()); Assert.assertEquals(ProviderServiceTest.TEST_PROVIDER_NAME, ret.get(1).getProviderName()); Assert.assertEquals("jbossorg_type_3", ret.get(1).getTypeName()); verify(tested.authenticationUtilService).checkProviderManagementPermission( ProviderServiceTest.TEST_PROVIDER_NAME); verify(tested.authenticationUtilService).checkProviderManagementPermission( TEST_PROVIDER_NAME_UNAUTH); } }