Login { public Challenge createChallenge(JSON data) { Challenge challenge = session.provider().createChallenge(this, data); if (challenge == null) { throw new AcmeProtocolException("Could not create challenge for: " + data); } return challenge; } Login(URL accountLocation, KeyPair keyPair, Session session); Session getSession(); KeyPair getKeyPair(); URL getAccountLocation(); Account getAccount(); Authorization bindAuthorization(URL location); Certificate bindCertificate(URL location); Order bindOrder(URL location); Challenge bindChallenge(URL location); Challenge createChallenge(JSON data);  }
@Test public void testCreateChallenge() throws Exception { String challengeType = Http01Challenge.TYPE; URL challengeUrl = url("https: JSON data = new JSONBuilder() .put("type", challengeType) .put("url", challengeUrl) .toJSON(); Http01Challenge mockChallenge = mock(Http01Challenge.class); final AcmeProvider mockProvider = mock(AcmeProvider.class); when(mockProvider.createChallenge( ArgumentMatchers.any(Login.class), ArgumentMatchers.eq(data))) .thenReturn(mockChallenge); URL location = url(TestUtils.ACCOUNT_URL); KeyPair keypair = TestUtils.createKeyPair(); Session session = TestUtils.session(mockProvider); Login login = new Login(location, keypair, session); Challenge challenge = login.createChallenge(data); assertThat(challenge, is(instanceOf(Http01Challenge.class))); assertThat(challenge, is(sameInstance(mockChallenge))); verify(mockProvider).createChallenge(login, data); }