### Question:
URLProtector { public String protectRedirectUrl(String redirectUrl) { if (redirectUrl != null && !redirectUrl.startsWith("portal")) { return removeTokenFromUrl(redirectUrl, new ArrayList<String>(tokens)); } return redirectUrl; }  String protectRedirectUrl(String redirectUrl);  }### Answer:
@Test public void testProtectRedirectUrlShouldRemoveHTTPFromURL() { assertEquals("google", urlProtecter.protectRedirectUrl("httpgoogle")); }
@Test public void testProtectRedirectUrlShouldRemoveHTTPSFromURL() { assertEquals("google", urlProtecter.protectRedirectUrl("httpsgoogle")); }
@Test public void testProtectRedirectUrlShouldNotChangeURL() { assertEquals("mobile/#home", urlProtecter.protectRedirectUrl("mobile/#home")); assertEquals("/bonita/mobile/#login", urlProtecter.protectRedirectUrl("/bonita/mobile/#login")); assertEquals("/bonita/portal", urlProtecter.protectRedirectUrl("/bonita/portal")); }
@Test public void testProtectRedirectUrlRedirectingtoCaseListingUser() { assertEquals("#?_p=caselistinguser", urlProtecter.protectRedirectUrl("#?_p=caselistinguser")); }
@Test public void testProtectRedirectUrlIsNotChangedIfStartingWithBonitaPortal() { assertEquals("portal/homepage#?_p=caselistinguser&test=http: urlProtecter.protectRedirectUrl("portal/homepage#?_p=caselistinguser&test=http: }
@Test public void it_should_filter_capital_letters(){ assertEquals(":.google.com", urlProtecter.protectRedirectUrl("HTTPS: }
@Test public void it_should_filter_double_backslash() { assertEquals(".google.com", urlProtecter.protectRedirectUrl(" assertEquals("google.com", urlProtecter.protectRedirectUrl(" }