### Question:
WebFormHandler { public BaseConsent consent(String appId, String sessionId, String sessionData, List<String> approvedScopes, BaseClient.CookieStorage cookieStorage) throws UserConsentException { String result = this.client.consent(appId, sessionId, sessionData, approvedScopes, cookieStorage); if(Strings.isNullOrEmpty(result)) { throw new UserConsentException("Failed to submit the user consent with the provided scopes since the returned result was null or empty."); } try { return ConsentFactory.fromResponse(result); } catch(IllegalArgumentException e) { throw new UserConsentException("Failed to submit the user consent with the provided scopes.", e); } } WebFormHandler(OAuthConfig config);   WebFormHandler(WebFormClient client); BaseConsent login(String appId, String sessionId, String sessionData, String username, String password, BaseClient.CookieStorage cookieStorage); BaseConsent consent(String appId, String sessionId, String sessionData, List<String> approvedScopes, BaseClient.CookieStorage cookieStorage);  }### Answer:
@Test(expected = UserConsentException.class) public void testConsent_whenResponseIsNull_shouldThrowException() throws Exception { Mockito.when(client.consent(anyString(), anyString(), anyString(), ArgumentMatchers.<String>anyList(), any(BaseClient.CookieStorage.class))) .thenReturn(null); webFormHandler.consent("app-id", "session-id", "session-data", Arrays.asList("scope-1", "scope-2"), cookieStorage); }
@Test(expected = UserConsentException.class) public void testConsent_whenResponseIsInvalid_shouldThrowException() throws Exception { Mockito.when(client.consent(anyString(), anyString(), anyString(), ArgumentMatchers.<String>anyList(), any(BaseClient.CookieStorage.class))) .thenReturn("<html>"); webFormHandler.consent("app-id", "session-id", "session-data", Arrays.asList("scope-1", "scope-2"), cookieStorage); }
@Test public void testConsent_whenResponseIsValid_shouldReturnAConsent() throws Exception { Mockito.when(client.consent(anyString(), anyString(), anyString(), ArgumentMatchers.<String>anyList(), any(BaseClient.CookieStorage.class))) .thenReturn(consentFormHTML); assertThat(webFormHandler.consent("app-id", "session-id", "session-data", Arrays.asList("scope-1", "scope-2"), cookieStorage)) .isInstanceOf(BaseConsent.class); }