Challenge extends AcmeJsonResource { public void trigger() throws AcmeException { LOG.debug("trigger"); try (Connection conn = getSession().connect()) { JSONBuilder claims = new JSONBuilder(); prepareResponse(claims); conn.sendSignedRequest(getLocation(), claims, getLogin()); setJSON(conn.readJsonResponse()); } } Challenge(Login login, JSON data); String getType(); Status getStatus(); @Nullable Instant getValidated(); @Nullable Problem getError(); void trigger();  }
@Test public void testTrigger() throws Exception { TestableConnectionProvider provider = new TestableConnectionProvider() { @Override public int sendSignedRequest(URL url, JSONBuilder claims, Login login) { assertThat(url, is(locationUrl)); assertThat(claims.toString(), sameJSONAs(getJSON("triggerHttpChallengeRequest").toString())); assertThat(login, is(notNullValue())); return HttpURLConnection.HTTP_OK; } @Override public JSON readJsonResponse() { return getJSON("triggerHttpChallengeResponse"); } }; Login login = provider.createLogin(); Http01Challenge challenge = new Http01Challenge(login, getJSON("triggerHttpChallenge")); challenge.trigger(); assertThat(challenge.getStatus(), is(Status.PENDING)); assertThat(challenge.getLocation(), is(locationUrl)); provider.close(); }