### Question:
PackagePath { public static String directSubPackageOf(String parent, String packageName) { if (areSamePackage(parent, packageName)) return null; if (!isSubPackageOf(parent, packageName)) throw new IllegalArgumentException("Package '" + packageName + "' is not a subPackage of '" + parent + "'"); int dec = parent.length(); if (dec > 0) dec++; String subTree = packageName.substring(dec); int nextPkg = subTree.indexOf('.'); if (nextPkg < 0) return subTree; else return subTree.substring(0, nextPkg); }  static boolean isSubPackageOf(String parent, String packageName); static String directSubPackageOf(String parent, String packageName); static boolean areSamePackage(String packageName1, String packageName2);  }### Answer:
@Test public void directSubPackageOf_should_work___() { assertThat(directSubPackageOf("", "tzatziki.util.matcher.string")).isEqualTo("tzatziki"); assertThat(directSubPackageOf("tzatziki", "tzatziki.util")).isEqualTo("util"); assertThat(directSubPackageOf("tzatziki.util", "tzatziki.util.matcher")).isEqualTo("matcher"); assertThat(directSubPackageOf("tzatziki.util", "tzatziki.util.matcher.string")).isEqualTo("matcher"); }
@Test public void directSubPackageOf_should_return_null_when_same_packages_are_provided() { assertThat(directSubPackageOf("tzatziki.pdf", "tzatziki.pdf")).isNull(); }
@Test(expected = IllegalArgumentException.class) public void directSubPackageOf_should_throw_when_packages_does_not_belong_to_the_same_tree() { directSubPackageOf("tzatziki.pdf", "tzatziki.util"); }