@Test public void updateContentSelectorUpdatesSelector() { ContentSelectorApiUpdateRequest request = new ContentSelectorApiUpdateRequest(); request.setDescription("description"); request.setExpression("format == \"maven2\""); SelectorConfiguration selector = new OrientSelectorConfiguration(); selector.setName("test"); when(selectorManager.findByName(selector.getName())).thenReturn(Optional.of(selector)); underTest.updateContentSelector(selector.getName(), request); ArgumentCaptor<SelectorConfiguration> configurationCaptor = ArgumentCaptor.forClass(SelectorConfiguration.class); verify(selectorManager).update(configurationCaptor.capture()); assertThat(configurationCaptor.getValue().getType(), is(CselSelector.TYPE)); assertThat(configurationCaptor.getValue().getDescription(), is(request.getDescription())); assertThat(configurationCaptor.getValue().getAttributes().get(EXPRESSION), is(request.getExpression())); }
@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);  }