### Question:
StandardAuthenticationManagerImpl implements AuthenticationManager { @Override public String getLoginPageURL(final HttpServletRequestAccessor request, final String redirectURL) throws ServletException { final StringBuilder url = new StringBuilder(); String context = request.asHttpServletRequest().getContextPath(); final String servletPath = request.asHttpServletRequest().getServletPath(); if (StringUtils.isNotBlank(servletPath) && servletPath.startsWith("/mobile")) { context += "/mobile"; } url.append(context).append(AuthenticationManager.LOGIN_PAGE).append("?"); long tenantId = getTenantId(request); if (tenantId != getDefaultTenantId()) { url.append(AuthenticationManager.TENANT).append("=").append(tenantId).append("&"); } String localeFromRequestedURL = LocaleUtils.getLocaleFromRequestURL(request.asHttpServletRequest()); if (localeFromRequestedURL != null) { url.append(LocaleUtils.PORTAL_LOCALE_PARAM).append("=").append(localeFromRequestedURL).append("&"); } url.append(AuthenticationManager.REDIRECT_URL).append("=").append(redirectURL); return url.toString(); }  @Override String getLoginPageURL(final HttpServletRequestAccessor request, final String redirectURL); @Override Map<String, Serializable> authenticate(final HttpServletRequestAccessor requestAccessor, final Credentials credentials); @Override String getLogoutPageURL(final HttpServletRequestAccessor request, final String redirectURL);  }### Answer:
@Test public void testGetSimpleLoginpageURL() throws Exception { String redirectUrl = "%2Fportal%2Fhomepage"; String loginURL = standardLoginManagerImpl.getLoginPageURL(requestAccessor, redirectUrl); assertThat(loginURL).isEqualToIgnoringCase("bonita/login.jsp?tenant=1&redirectUrl=%2Fportal%2Fhomepage"); }
@Test public void testGetLoginpageURLWithLocale() throws Exception { String redirectUrl = "%2Fportal%2Fhomepage"; request.setParameter("_l", "es"); String loginURL = standardLoginManagerImpl.getLoginPageURL(requestAccessor, redirectUrl); assertThat(loginURL).isEqualToIgnoringCase("bonita/login.jsp?tenant=1&_l=es&redirectUrl=%2Fportal%2Fhomepage"); }
@Test public void testGetLoginpageURLFromPortal() throws Exception { String redirectUrl = "%2Fportal%2Fhomepage"; request.setServletPath("/portal/"); String loginURL = standardLoginManagerImpl.getLoginPageURL(requestAccessor, redirectUrl); assertThat(loginURL).isEqualToIgnoringCase("bonita/login.jsp?tenant=1&redirectUrl=%2Fportal%2Fhomepage"); }
@Test public void testGetLoginpageURLFromMobile() throws Exception { String redirectUrl = "%2Fmobile%2F"; request.setServletPath("/mobile/#login"); String loginURL = standardLoginManagerImpl.getLoginPageURL(requestAccessor, redirectUrl); assertThat(loginURL).isEqualToIgnoringCase("bonita/mobile/login.jsp?tenant=1&redirectUrl=%2Fmobile%2F"); }
@Test public void should_add_tenant_parameter_contained_in_request_params() throws Exception { request.setParameter("tenant", "4"); request.setCookies(new Cookie("bonita.tenant", "123")); String redirectUrl = "%2Fportal%2Fhomepage"; String loginURL = standardLoginManagerImpl.getLoginPageURL(requestAccessor, redirectUrl); assertThat(loginURL).isEqualToIgnoringCase("bonita/login.jsp?tenant=4&redirectUrl=%2Fportal%2Fhomepage"); }
@Test public void should_add_tenant_parameter_from_cookie_if_not_in_request() throws Exception { request.removeAllParameters(); request.setCookies(new Cookie("bonita.tenant", "123")); String redirectUrl = "%2Fportal%2Fhomepage"; String loginURL = standardLoginManagerImpl.getLoginPageURL(requestAccessor, redirectUrl); assertThat(loginURL).isEqualToIgnoringCase("bonita/login.jsp?tenant=123&redirectUrl=%2Fportal%2Fhomepage"); }