Text { public static String matchMax(String left, String right) { if (!Strings.isNullOrEmpty(right)) { if (right.startsWith("http: return right; } else { if (!Strings.isNullOrEmpty(left)) { int offset = 0; for (int i = 0; i < left.length(); i++) { if (left.charAt(i) != right.charAt(offset)) { offset = 0; } else { offset++; } } return new StringBuilder(left).append(right.substring(offset, right.length())).toString(); } else { return right; } } } else { return right; } }  static String removeLast(String s); static String generateHash(String key); static String capitalize(String s); static String matchMax(String left, String right); static boolean containsEvilSpecialChar(String stringToCheck); static String containingString(String str, String prefix, String suffix);  }
@Test public void testMatchMax() { String content = Text.matchMax("http: "/product/modacar-aliminyum-gorunum-torpido-kaplama-seti-331164-ford-focus-05-05-sonras-9-dekor"); assertThat(content, is("http: "-05-05-sonras-9-dekor")); content = Text.matchMax("http: "/product/modacar-aliminyum-gorunum-torpido-kaplama-seti-331164-ford-focus-05-05-sonras-9-dekor"); assertThat(content, is("http: "-05-05-sonras-9-dekor")); content = Text.matchMax("www.emall.com.tr", "/product/modacar-aliminyum-gorunum-torpido-kaplama-seti-331164-ford-focus-05-05-sonras-9-dekor"); assertThat(content, is("www.emall.com.tr/product/modacar-aliminyum-gorunum-torpido-kaplama-seti-331164-ford-focus-05-05" + "-sonras-9-dekor")); content = Text.matchMax("www.emall.com.tr", "product/modacar-aliminyum-gorunum-torpido-kaplama-seti-331164-ford-focus-05-05-sonras-9-dekor"); assertThat(content, is("www.emall.com.trproduct/modacar-aliminyum-gorunum-torpido-kaplama-seti-331164-ford-focus-05-05" + "-sonras-9-dekor")); content = Text.matchMax("https: "/product/modacar-aliminyum-gorunum-torpido-kaplama-seti-331164-ford-focus-05-05-sonras-9-dekor"); assertThat(content, is("https: "-05-05-sonras-9-dekor")); content = Text.matchMax("https: "aroduct/modacar-aliminyum-gorunum-torpido-kaplama-seti-331164-ford-focus-05-05-sonras-9-dekor"); assertThat(content, is("https: "-05-05-sonras-9-dekor")); content = Text.matchMax("ab", "cd"); assertThat(content, is("abcd")); content = Text.matchMax("ptr", "pro"); assertThat(content, is("ptrpro")); content = Text.matchMax("http: assertThat(content, is("http: content = Text.matchMax("http: assertThat(content, is("http: content = Text.matchMax("http: assertThat(content, is("http: content = Text.matchMax("http: assertThat(content, is("http: content = Text.matchMax("http: assertNull(content); content = Text.matchMax(null, null); assertThat(content, is(nullValue())); content = Text.matchMax(null, "wqe"); assertThat(content, is("wqe")); content = Text.matchMax(null, "http: assertThat(content, is("http: content = Text.matchMax(null, "https: assertThat(content, is("https: content = Text.matchMax("NOT_RETURNED", "https: content = Text.matchMax("http: "http: assertThat(content, is("http: }