### Question:
AuthorizationApiHandler { public Authorization initializeAuth(String clientId, String redirectUri, String scope) throws SessionRetrievalException { Authorization authorization = new Authorization(); try { if(config.isUsePKCE()) { authorization.storeSession(this.client.authorize(clientId, redirectUri, scope, authorization.getCodeChallenge())); } else { authorization.storeSession(this.client.authorize(clientId, redirectUri, scope)); } } catch (IllegalArgumentException e) { throw new SessionRetrievalException("Failed to extract the session from the initial authorize call.", e); } return authorization; } AuthorizationApiHandler(OAuthConfig config);   AuthorizationApiHandler(OAuthConfig config, AuthorizationApiClient client); Authorization initializeAuth(String clientId, String redirectUri, String scope); String submitConsent(String action, String sessionId, String sessionData);  }### Answer:
@Test public void testInitializeAuth_whenPKCEShouldBeUsedAndCodeChallengeProvided_shouldCallClientAccordingly() throws Exception { Mockito.when(client.authorize(eq("client-id"), eq("http: .thenReturn(resourceAsString("__files/login/redirected_login_form.html")); authorizationApiHandler = new AuthorizationApiHandler(getDefaultBuilder().usePKCE(true).build(), client); authorizationApiHandler.initializeAuth("client-id", "http: assertThat(stringCaptor.getValue()).isNotNull(); }
@Test public void testInitializeAuth_whenPKCEShouldNotBeUsed_shouldCallClientAccordingly() throws Exception { Mockito.when(client.authorize(eq("client-id"), eq("http: .thenReturn(resourceAsString("__files/login/redirected_login_form.html")); authorizationApiHandler = new AuthorizationApiHandler(createDefaultConfig(), client); authorizationApiHandler.initializeAuth("client-id", "http: Mockito.verify(client, times(1)).authorize(eq("client-id"), eq("http: }
@Test(expected = SessionRetrievalException.class) public void testInitializeAuth_whenClientReturnsEmptyString_shouldThrowException() throws Exception { Mockito.when(client.authorize(eq("client-id"), eq("http: authorizationApiHandler = new AuthorizationApiHandler(createDefaultConfig(), client); authorizationApiHandler.initializeAuth("client-id", "http: }