ContentSelectorsApiResource implements Resource, ContentSelectorsResourceDoc { @DELETE @Path("{name}") @RequiresAuthentication @RequiresPermissions("nexus:selectors:delete") public void deleteContentSelector(@PathParam("name") final String name) { SelectorConfiguration configuration = findConfigurationByNameOrThrowNotFound(name); selectorManager.delete(configuration); } @Inject  ContentSelectorsApiResource(final SelectorFactory selectorFactory, final SelectorManager selectorManager); @GET @RequiresAuthentication @RequiresPermissions("nexus:selectors:read") List<ContentSelectorApiResponse> getContentSelectors(); @POST @Validate @RequiresAuthentication @RequiresPermissions("nexus:selectors:create") void createContentSelector(@Valid final ContentSelectorApiCreateRequest request); @GET @Path("{name}") @RequiresAuthentication @RequiresPermissions("nexus:selectors:read") ContentSelectorApiResponse getContentSelector(@PathParam("name") final String name); @PUT @Path("{name}") @Validate @RequiresAuthentication @RequiresPermissions("nexus:selectors:update") void updateContentSelector(@PathParam("name") final String name,
                                    @Valid final ContentSelectorApiUpdateRequest request); @DELETE @Path("{name}") @RequiresAuthentication @RequiresPermissions("nexus:selectors:delete") void deleteContentSelector(@PathParam("name") final String name);  }
@Test public void deleteContentSelectorThrowsNotFoundForSelectorNotFound() { ContentSelectorApiUpdateRequest request = new ContentSelectorApiUpdateRequest(); request.setExpression("format == \"maven2\""); SelectorConfiguration selector = new OrientSelectorConfiguration(); selector.setName("any"); when(selectorManager.findByName(any())).thenReturn(Optional.empty()); exceptionRule.expect(WebApplicationMessageException.class); exceptionRule.expect(hasProperty("response", hasProperty("status", is(NOT_FOUND)))); underTest.deleteContentSelector(selector.getName()); }
@Test public void deleteContentSelectorSucceeds() { SelectorConfiguration selector = new OrientSelectorConfiguration(); selector.setName("test"); when(selectorManager.findByName(selector.getName())).thenReturn(Optional.of(selector)); underTest.deleteContentSelector(selector.getName()); verify(selectorManager).delete(selector); }