@Test public void testCheckValueIsNull() { final ObjectNode param = mapper.createObjectNode(); assertThatThrownBy(() -> service.check(testingFilterName, param)) .isInstanceOf(BadParameterException.class) .hasMessageContaining("required parameter"); }
@Post("/{name}/check") public JsonNode check(@Param String name, @RequestObject JsonNode req) throws FilterNotFoundException { final JsonNode testingValue = checkNotNull("value", req.get("value")); checkParameter("value", testingValue.isTextual(), "expect string type"); final BloomFilter filter = bloomFilterManager.ensureGetValidFilter(name); final boolean contain = filter.mightContain(testingValue.textValue()); return BooleanNode.valueOf(contain); }
BloomFilterHttpService { @Post("/{name}/check") public JsonNode check(@Param String name, @RequestObject JsonNode req) throws FilterNotFoundException { final JsonNode testingValue = checkNotNull("value", req.get("value")); checkParameter("value", testingValue.isTextual(), "expect string type"); final BloomFilter filter = bloomFilterManager.ensureGetValidFilter(name); final boolean contain = filter.mightContain(testingValue.textValue()); return BooleanNode.valueOf(contain); } }
BloomFilterHttpService { @Post("/{name}/check") public JsonNode check(@Param String name, @RequestObject JsonNode req) throws FilterNotFoundException { final JsonNode testingValue = checkNotNull("value", req.get("value")); checkParameter("value", testingValue.isTextual(), "expect string type"); final BloomFilter filter = bloomFilterManager.ensureGetValidFilter(name); final boolean contain = filter.mightContain(testingValue.textValue()); return BooleanNode.valueOf(contain); } BloomFilterHttpService(BloomFilterManager<?, ? super ExpirableBloomFilterConfig> bloomFilterManager); }
BloomFilterHttpService { @Post("/{name}/check") public JsonNode check(@Param String name, @RequestObject JsonNode req) throws FilterNotFoundException { final JsonNode testingValue = checkNotNull("value", req.get("value")); checkParameter("value", testingValue.isTextual(), "expect string type"); final BloomFilter filter = bloomFilterManager.ensureGetValidFilter(name); final boolean contain = filter.mightContain(testingValue.textValue()); return BooleanNode.valueOf(contain); } BloomFilterHttpService(BloomFilterManager<?, ? super ExpirableBloomFilterConfig> bloomFilterManager); @Put("/{name}") HttpResponse create(@Param String name,
                               @RequestObject JsonNode req); @Get("/{name}") JsonNode getFilterInfo(@Param String name); @Get("/list") JsonNode list(); @Post("/{name}/check") JsonNode check(@Param String name,
                          @RequestObject JsonNode req); @Post("/{name}/multi-check") JsonNode multiCheck(@Param String name,
                               @RequestObject JsonNode req); @Post("/{name}/check-and-set") JsonNode checkAndSet(@Param String name,
                                @RequestObject JsonNode req); @Post("/{name}/multi-check-and-set") JsonNode multiCheckAndSet(@Param String name,
                                     @RequestObject JsonNode req); @Delete("/{name}") HttpResponse remove(@Param String name); }
BloomFilterHttpService { @Post("/{name}/check") public JsonNode check(@Param String name, @RequestObject JsonNode req) throws FilterNotFoundException { final JsonNode testingValue = checkNotNull("value", req.get("value")); checkParameter("value", testingValue.isTextual(), "expect string type"); final BloomFilter filter = bloomFilterManager.ensureGetValidFilter(name); final boolean contain = filter.mightContain(testingValue.textValue()); return BooleanNode.valueOf(contain); } BloomFilterHttpService(BloomFilterManager<?, ? super ExpirableBloomFilterConfig> bloomFilterManager); @Put("/{name}") HttpResponse create(@Param String name,
                               @RequestObject JsonNode req); @Get("/{name}") JsonNode getFilterInfo(@Param String name); @Get("/list") JsonNode list(); @Post("/{name}/check") JsonNode check(@Param String name,
                          @RequestObject JsonNode req); @Post("/{name}/multi-check") JsonNode multiCheck(@Param String name,
                               @RequestObject JsonNode req); @Post("/{name}/check-and-set") JsonNode checkAndSet(@Param String name,
                                @RequestObject JsonNode req); @Post("/{name}/multi-check-and-set") JsonNode multiCheckAndSet(@Param String name,
                                     @RequestObject JsonNode req); @Delete("/{name}") HttpResponse remove(@Param String name);  }