### Question:
SpringOidcConfigurationService implements OidcConfigurationService { @Override public OAuth2ServiceEndpointsProvider retrieveEndpoints(@Nonnull URI discoveryEndpointUri) throws OAuth2ServiceException { Assertions.assertNotNull(discoveryEndpointUri, "discoveryEndpointUri must not be null!"); try { ResponseEntity<String> response = restOperations.getForEntity(discoveryEndpointUri, String.class); if (HttpStatus.OK.value() == response.getStatusCode().value()) { return new DefaultOidcConfigurationService.OidcEndpointsProvider(response.getBody()); } else { throw OAuth2ServiceException.builder("Error retrieving configured oidc endpoints") .withUri(discoveryEndpointUri) .withStatusCode(response.getStatusCodeValue()) .withResponseBody(response.getBody()) .build(); } } catch (HttpClientErrorException ex) { throw OAuth2ServiceException.builder("Error retrieving configured oidc endpoints") .withUri(discoveryEndpointUri) .withStatusCode(ex.getStatusCode().value()) .withResponseBody(ex.getResponseBodyAsString()) .build(); } } SpringOidcConfigurationService(@Nonnull RestOperations restOperations); @Override OAuth2ServiceEndpointsProvider retrieveEndpoints(@Nonnull URI discoveryEndpointUri);  }### Answer:
@Test public void retrieveEndpoints_parameterIsNull_throwsException() throws OAuth2ServiceException { assertThatThrownBy(() -> retrieveEndpoints(null)) .isInstanceOf(IllegalArgumentException.class); }
@Test public void retrieveEndpoints_badRequest_throwsException() { String errorDescription = "Something wen't wrong"; mockResponse(errorDescription, HttpStatus.BAD_REQUEST); assertThatThrownBy(() -> retrieveEndpoints()) .isInstanceOf(OAuth2ServiceException.class) .hasMessageContaining(errorDescription); }
@Test public void retrieveEndpoints_executesHttpGetRequestWithCorrectURI() throws OAuth2ServiceException { mockResponse(); retrieveEndpoints(); Mockito.verify(restOperationsMock, times(1)) .getForEntity(CONFIG_ENDPOINT_URI, String.class); }
@Test public void retrieveEndpoints_containsBothKeys() throws OAuth2ServiceException { mockResponse(); OAuth2ServiceEndpointsProvider result = retrieveEndpoints(); assertThat(result.getTokenEndpoint().toString()).isEqualTo("http: assertThat(result.getJwksUri().toString()).isEqualTo("http: assertThat(result.getAuthorizeEndpoint().toString()).isEqualTo("http: }