### Question:
LoginHintHook implements AuthorizeRequestHook, TokenRequestHook { @Override public void beforeAuthorizeHandling(OAuth2Request o2request, Request request, Response response) { String loginHint = o2request.getParameter(LOGIN_HINT); if (loginHint != null && !loginHint.equals(request.getCookies().getFirstValue(LOGIN_HINT_COOKIE))) { CookieSetting cookie = new CookieSetting(0, LOGIN_HINT_COOKIE, loginHint); cookie.setPath("/"); cookie.setAccessRestricted(true); response.getCookieSettings().add(cookie); } }  @Override void beforeAuthorizeHandling(OAuth2Request o2request, Request request, Response response); @Override void afterAuthorizeSuccess(OAuth2Request o2request, Request request, Response response); @Override void afterTokenHandling(OAuth2Request o2request, Request request, Response response);  }### Answer:
@Test public void testBeforeAuthorizeHandlingNoLoginHint() throws Exception { Series<CookieSetting> cookieSettings = new Series<CookieSetting>(CookieSetting.class); when(response.getCookieSettings()).thenReturn(cookieSettings); when(o2request.getParameter(anyString())).thenReturn(null); hook.beforeAuthorizeHandling(o2request, request, response); verify(o2request).getParameter(LOGIN_HINT); assertThat(cookieSettings.size()).isEqualTo(0); }
@Test public void testBeforeAuthorizeHandling() throws Exception { Series<CookieSetting> cookieSettings = new Series<CookieSetting>(CookieSetting.class); when(response.getCookieSettings()).thenReturn(cookieSettings); when(o2request.getParameter(LOGIN_HINT)).thenReturn("msisdn=07898989898"); Series<Cookie> cookies = new Series<Cookie>(Cookie.class); when(request.getCookies()).thenReturn(cookies); hook.beforeAuthorizeHandling(o2request, request, response); verify(o2request).getParameter(LOGIN_HINT); assertThat(cookieSettings.size()).isEqualTo(1); assertThat(cookieSettings.getFirst(LOGIN_HINT_COOKIE).getValue()).isEqualTo("msisdn=07898989898"); assertThat(cookieSettings.getFirst(LOGIN_HINT_COOKIE).isAccessRestricted()).isTrue(); }