### Question:
Util { static String commonParent(String currentTop, String aPackage) { if (aPackage == null) return currentTop; if (currentTop == null) return aPackage; if (aPackage.startsWith(currentTop)) { return currentTop; } int next; do { next = currentTop.lastIndexOf('.'); if (next > -1) { currentTop = currentTop.substring(0, next); if (aPackage.startsWith(currentTop)) { return currentTop; } } } while (next > -1); return currentTop; }  static String getNamed(Element p); static String addForInterface(String interfaceType); static String trimMethod(String method);  }### Answer:
@Test public void commonParent() { assertEquals(Util.commonParent(null, "org.b"), "org.b"); assertEquals(Util.commonParent("org.a", null), "org.a"); assertEquals(Util.commonParent("org.foo.web", "org.foo.web.other"), "org.foo.web"); assertEquals(Util.commonParent("org.foo.web", "org.foo.web.other.more"), "org.foo.web"); assertEquals(Util.commonParent("org.foo.web", "org.foo.service"), "org.foo"); assertEquals(Util.commonParent("org.foo.web.foo", "org.foo.service.blah"), "org.foo"); }