@Test public void updateContentSelectorThrowsBadRequestForInvalidExpression() throws Exception { ContentSelectorApiUpdateRequest request = new ContentSelectorApiUpdateRequest(); request.setExpression("invalid-expression"); doThrow(new ConstraintViolationException("", emptySet())).when(selectorFactory) .validateSelector(CselSelector.TYPE, request.getExpression()); exceptionRule.expect(ConstraintViolationException.class); underTest.updateContentSelector("any", request); }
@PUT @Path("{name}") @Validate @RequiresAuthentication @RequiresPermissions("nexus:selectors:update") public void updateContentSelector(@PathParam("name") final String name, @Valid final ContentSelectorApiUpdateRequest request) { selectorFactory.validateSelector(CselSelector.TYPE, request.getExpression()); SelectorConfiguration configuration = findConfigurationByNameOrThrowNotFound(name); configuration.setType(CselSelector.TYPE); configuration.setDescription(request.getDescription()); configuration.setAttributes(singletonMap(EXPRESSION, request.getExpression())); selectorManager.update(configuration); }
ContentSelectorsApiResource implements Resource, ContentSelectorsResourceDoc { @PUT @Path("{name}") @Validate @RequiresAuthentication @RequiresPermissions("nexus:selectors:update") public void updateContentSelector(@PathParam("name") final String name, @Valid final ContentSelectorApiUpdateRequest request) { selectorFactory.validateSelector(CselSelector.TYPE, request.getExpression()); SelectorConfiguration configuration = findConfigurationByNameOrThrowNotFound(name); configuration.setType(CselSelector.TYPE); configuration.setDescription(request.getDescription()); configuration.setAttributes(singletonMap(EXPRESSION, request.getExpression())); selectorManager.update(configuration); } }
ContentSelectorsApiResource implements Resource, ContentSelectorsResourceDoc { @PUT @Path("{name}") @Validate @RequiresAuthentication @RequiresPermissions("nexus:selectors:update") public void updateContentSelector(@PathParam("name") final String name, @Valid final ContentSelectorApiUpdateRequest request) { selectorFactory.validateSelector(CselSelector.TYPE, request.getExpression()); SelectorConfiguration configuration = findConfigurationByNameOrThrowNotFound(name); configuration.setType(CselSelector.TYPE); configuration.setDescription(request.getDescription()); configuration.setAttributes(singletonMap(EXPRESSION, request.getExpression())); selectorManager.update(configuration); } @Inject  ContentSelectorsApiResource(final SelectorFactory selectorFactory, final SelectorManager selectorManager); }
ContentSelectorsApiResource implements Resource, ContentSelectorsResourceDoc { @PUT @Path("{name}") @Validate @RequiresAuthentication @RequiresPermissions("nexus:selectors:update") public void updateContentSelector(@PathParam("name") final String name, @Valid final ContentSelectorApiUpdateRequest request) { selectorFactory.validateSelector(CselSelector.TYPE, request.getExpression()); SelectorConfiguration configuration = findConfigurationByNameOrThrowNotFound(name); configuration.setType(CselSelector.TYPE); configuration.setDescription(request.getDescription()); configuration.setAttributes(singletonMap(EXPRESSION, request.getExpression())); selectorManager.update(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); }
ContentSelectorsApiResource implements Resource, ContentSelectorsResourceDoc { @PUT @Path("{name}") @Validate @RequiresAuthentication @RequiresPermissions("nexus:selectors:update") public void updateContentSelector(@PathParam("name") final String name, @Valid final ContentSelectorApiUpdateRequest request) { selectorFactory.validateSelector(CselSelector.TYPE, request.getExpression()); SelectorConfiguration configuration = findConfigurationByNameOrThrowNotFound(name); configuration.setType(CselSelector.TYPE); configuration.setDescription(request.getDescription()); configuration.setAttributes(singletonMap(EXPRESSION, request.getExpression())); selectorManager.update(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);  }