BloomFilterHttpService { @Post("/{name}/multi-check") public JsonNode multiCheck(@Param String name, @RequestObject JsonNode req) throws FilterNotFoundException { final JsonNode values = checkNotNull("values", req.get("values")); checkParameter("values", values.isArray(), "expect Json array"); final BloomFilter filter = bloomFilterManager.ensureGetValidFilter(name); final ArrayNode response = MAPPER.createArrayNode(); for (final JsonNode value : values) { response.add(value.isTextual() && filter.mightContain(value.textValue())); } return response; } 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);  }
@Test public void testMultiCheckAndSetValueIsNull() { final ObjectNode param = mapper.createObjectNode(); assertThatThrownBy(() -> service.multiCheck(testingFilterName, param)) .isInstanceOf(BadParameterException.class) .hasMessageContaining("required parameter"); }
@Test public void testMultiCheckAndSetValueIsNotArray() { final ObjectNode param = mapper.createObjectNode(); param.put("values", "12345"); assertThatThrownBy(() -> service.multiCheck(testingFilterName, param)) .isInstanceOf(BadParameterException.class) .hasMessageContaining("invalid parameter"); }