/** * Waits for the response to pass the given predicate * @param responsePredicate The predicate to test the response against * @return this */ public HttpWaitStrategy forResponsePredicate(Predicate<String> responsePredicate) { delegateStrategy.forResponsePredicate(responsePredicate); return this; }
@NotNull private HttpWaitStrategy createNodeWaitStrategy() { return new HttpWaitStrategy() .forPath("/pools/default/") .withBasicCredentials(clusterUsername, clusterPassword) .forStatusCode(HTTP_OK) .forResponsePredicate(response -> { try { return Optional.of(MAPPER.readTree(response)) .map(n -> n.at("/nodes/0/status")) .map(JsonNode::asText) .map("healthy"::equals) .orElse(false); } catch (IOException e) { logger().error("Unable to parse response {}", response); return false; } }); }
/** * @param ready the AtomicBoolean on which to indicate success * @return the WaitStrategy under test */ @NotNull protected HttpWaitStrategy buildWaitStrategy(final AtomicBoolean ready) { return createHttpWaitStrategy(ready) .forResponsePredicate(s -> s.equals(GOOD_RESPONSE_BODY)); }
/** * Waits for the response to pass the given predicate * @param responsePredicate The predicate to test the response against * @return this */ public HttpWaitStrategy forResponsePredicate(Predicate<String> responsePredicate) { delegateStrategy.forResponsePredicate(responsePredicate); return this; }