@ApiOperation(value = "Update a processing rule from rule builder", notes = "")
    @Path("/{id}")
    @PUT
    @RequiresPermissions(PipelineRestPermissions.PIPELINE_RULE_CREATE)
    @AuditEvent(type = PipelineProcessorAuditEventTypes.RULE_CREATE)
    public RuleBuilderDto updateFromBuilder(@ApiParam(name = "id") @PathParam("id") String id,
                                            @ApiParam(name = "rule", required = true) @NotNull RuleBuilderDto ruleBuilderDto) throws NotFoundException {
        RuleSource ruleSource = toRuleSource(ruleBuilderDto, false);
        final RuleSource stored = ruleResource.update(id, ruleSource);
        return ruleBuilderDto.toBuilder()
                .id(stored.id())
                .build();
    }
@Test
    public void ruleParsedAndUpdatedByRuleResource() throws NotFoundException {
        when(ruleBuilderService.generateRuleSource(any(), any(RuleBuilder.class), anyBoolean()))
                .thenReturn("rulesource");
        final String updatedId = "updated_id";
        when(ruleResource.update(eq(updatedId), any(RuleSource.class))).thenReturn(RuleSource.builder().id(updatedId).source("rulesource").build());
        RuleBuilder ruleBuilder = RuleBuilder.builder().build();
        when(ruleBuilderService.generateTitles(any())).thenReturn(ruleBuilder);
        RuleBuilderDto toSave = RuleBuilderDto.builder()
                .title("title")
                .ruleBuilder(ruleBuilder)
                .build();
        final RuleBuilderDto saved = ruleBuilderResource.updateFromBuilder(updatedId, toSave);
        assertThat(saved.id()).isEqualTo(updatedId);
        verify(ruleResource).update(eq(updatedId), any());
    }