@Test public void createContentSelectorValidatesTheExpression() { ContentSelectorApiCreateRequest request = new ContentSelectorApiCreateRequest(); request.setName("name"); request.setExpression("invalid-expression"); doThrow(new ConstraintViolationException(emptySet())).when(selectorFactory) .validateSelector(CselSelector.TYPE, request.getExpression()); exceptionRule.expect(ConstraintViolationException.class); underTest.createContentSelector(request); }
@POST @Validate @RequiresAuthentication @RequiresPermissions("nexus:selectors:create") public void createContentSelector(@Valid final ContentSelectorApiCreateRequest request) { selectorFactory.validateSelector(CselSelector.TYPE, request.getExpression()); selectorManager.create(request.getName(), CselSelector.TYPE, request.getDescription(), singletonMap(EXPRESSION, request.getExpression())); }
ContentSelectorsApiResource implements Resource, ContentSelectorsResourceDoc { @POST @Validate @RequiresAuthentication @RequiresPermissions("nexus:selectors:create") public void createContentSelector(@Valid final ContentSelectorApiCreateRequest request) { selectorFactory.validateSelector(CselSelector.TYPE, request.getExpression()); selectorManager.create(request.getName(), CselSelector.TYPE, request.getDescription(), singletonMap(EXPRESSION, request.getExpression())); } }
ContentSelectorsApiResource implements Resource, ContentSelectorsResourceDoc { @POST @Validate @RequiresAuthentication @RequiresPermissions("nexus:selectors:create") public void createContentSelector(@Valid final ContentSelectorApiCreateRequest request) { selectorFactory.validateSelector(CselSelector.TYPE, request.getExpression()); selectorManager.create(request.getName(), CselSelector.TYPE, request.getDescription(), singletonMap(EXPRESSION, request.getExpression())); } @Inject  ContentSelectorsApiResource(final SelectorFactory selectorFactory, final SelectorManager selectorManager); }
ContentSelectorsApiResource implements Resource, ContentSelectorsResourceDoc { @POST @Validate @RequiresAuthentication @RequiresPermissions("nexus:selectors:create") public void createContentSelector(@Valid final ContentSelectorApiCreateRequest request) { selectorFactory.validateSelector(CselSelector.TYPE, request.getExpression()); selectorManager.create(request.getName(), CselSelector.TYPE, request.getDescription(), singletonMap(EXPRESSION, request.getExpression())); } @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); }
ContentSelectorsApiResource implements Resource, ContentSelectorsResourceDoc { @POST @Validate @RequiresAuthentication @RequiresPermissions("nexus:selectors:create") public void createContentSelector(@Valid final ContentSelectorApiCreateRequest request) { selectorFactory.validateSelector(CselSelector.TYPE, request.getExpression()); selectorManager.create(request.getName(), CselSelector.TYPE, request.getDescription(), singletonMap(EXPRESSION, request.getExpression())); } @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);  }