### Question:
Issuer { public static Issuer build(final String name, final URI wellKnownUri, final List<String> supportedDomains, final Handler handler) throws DiscoveryException { final Request request = new Request(); request.setMethod("GET"); request.setUri(wellKnownUri); Response response; try { response = blockingCall(handler, new AttributesContext(new RootContext()), request); } catch (InterruptedException e) { throw new DiscoveryException(format("Interrupted while waiting for '%s' response", wellKnownUri), e); } if (!OK.equals(response.getStatus())) { throw new DiscoveryException("Unable to read well-known OpenID Configuration from '" + wellKnownUri + "'", response.getCause()); } JsonValue config = null; try { config = getJsonContent(response); } catch (OAuth2ErrorException | JsonValueException e) { throw new DiscoveryException("Cannot read JSON", e); } return new Issuer(name, config.put("supportedDomains", supportedDomains)); } Issuer(final String name, final JsonValue config); String getName(); URI getAuthorizeEndpoint(); URI getTokenEndpoint(); URI getRegistrationEndpoint(); URI getUserInfoEndpoint(); URI getWellKnownEndpoint(); boolean hasUserInfoEndpoint(); List<Pattern> getSupportedDomains(); static Issuer build(final String name,
                               final URI wellKnownUri,
                               final List<String> supportedDomains,
                               final Handler handler); static final String ISSUER_KEY; }### Answer:
@Test(expectedExceptions = JsonValueException.class) public void shouldFailToPerformBuildWithWellKnownUriProvidedCausedByInvalidResponse() throws Exception { final Response response = new Response(); response.setStatus(Status.OK); response.setEntity(json(object(field("invalid", "response")))); when(handler.handle(any(Context.class), any(Request.class))).thenReturn(newResponsePromise(response)); Issuer.build("myIssuer", new URI(SAMPLE_URI + WELLKNOWN_ENDPOINT), null, handler); }
@Test(expectedExceptions = DiscoveryException.class) public void shouldFailToPerformBuildWithWellKnownUriProvidedCausedByTeapotResponse() throws Exception { final Response response = new Response(); response.setStatus(Status.TEAPOT); response.setEntity(getValidWellKnownOpenIdConfigurationResponse()); when(handler.handle(any(Context.class), any(Request.class))).thenReturn(newResponsePromise(response)); Issuer.build("myIssuer", new URI(SAMPLE_URI + WELLKNOWN_ENDPOINT), null, handler); }