@Test public void testCheck() throws Exception { final String testingValue = "testing-value"; final GuavaBloomFilter testingFilter = factory.createFilter(new ExpirableBloomFilterConfig()); when(mockedManager.ensureGetValidFilter(testingFilterName)).thenReturn(testingFilter); final ObjectNode param = mapper.createObjectNode(); param.put("value", testingValue); final JsonNode res = service.check(testingFilterName, param); assertThat(res.asBoolean()).isFalse(); assertThat(testingFilter.mightContain(testingValue)).isFalse(); }
@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);  }