@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullPaths() { pathCalculator.calculate(null, null, null); }
public String calculate(String absolute, String r1, String r2) { if (absolute == null || r1 == null || r2 == null) { throw new IllegalArgumentException("You can't pass null strings as input."); } String[] absolutePath = absolute.split(DIR_SEPARATOR); String[] r1Path = r1.split(DIR_SEPARATOR); String[] r2Path = r2.split(DIR_SEPARATOR); String[] result = calculatePath(absolutePath, r1Path, r2Path); StringBuilder stringBuilder = new StringBuilder(DIR_SEPARATOR); for (String dir : result) { stringBuilder.append(dir); stringBuilder.append("/"); } return stringBuilder.toString(); }
PathCalculator { public String calculate(String absolute, String r1, String r2) { if (absolute == null || r1 == null || r2 == null) { throw new IllegalArgumentException("You can't pass null strings as input."); } String[] absolutePath = absolute.split(DIR_SEPARATOR); String[] r1Path = r1.split(DIR_SEPARATOR); String[] r2Path = r2.split(DIR_SEPARATOR); String[] result = calculatePath(absolutePath, r1Path, r2Path); StringBuilder stringBuilder = new StringBuilder(DIR_SEPARATOR); for (String dir : result) { stringBuilder.append(dir); stringBuilder.append("/"); } return stringBuilder.toString(); } }
PathCalculator { public String calculate(String absolute, String r1, String r2) { if (absolute == null || r1 == null || r2 == null) { throw new IllegalArgumentException("You can't pass null strings as input."); } String[] absolutePath = absolute.split(DIR_SEPARATOR); String[] r1Path = r1.split(DIR_SEPARATOR); String[] r2Path = r2.split(DIR_SEPARATOR); String[] result = calculatePath(absolutePath, r1Path, r2Path); StringBuilder stringBuilder = new StringBuilder(DIR_SEPARATOR); for (String dir : result) { stringBuilder.append(dir); stringBuilder.append("/"); } return stringBuilder.toString(); }  }
PathCalculator { public String calculate(String absolute, String r1, String r2) { if (absolute == null || r1 == null || r2 == null) { throw new IllegalArgumentException("You can't pass null strings as input."); } String[] absolutePath = absolute.split(DIR_SEPARATOR); String[] r1Path = r1.split(DIR_SEPARATOR); String[] r2Path = r2.split(DIR_SEPARATOR); String[] result = calculatePath(absolutePath, r1Path, r2Path); StringBuilder stringBuilder = new StringBuilder(DIR_SEPARATOR); for (String dir : result) { stringBuilder.append(dir); stringBuilder.append("/"); } return stringBuilder.toString(); }  String calculate(String absolute, String r1, String r2); }
PathCalculator { public String calculate(String absolute, String r1, String r2) { if (absolute == null || r1 == null || r2 == null) { throw new IllegalArgumentException("You can't pass null strings as input."); } String[] absolutePath = absolute.split(DIR_SEPARATOR); String[] r1Path = r1.split(DIR_SEPARATOR); String[] r2Path = r2.split(DIR_SEPARATOR); String[] result = calculatePath(absolutePath, r1Path, r2Path); StringBuilder stringBuilder = new StringBuilder(DIR_SEPARATOR); for (String dir : result) { stringBuilder.append(dir); stringBuilder.append("/"); } return stringBuilder.toString(); }  String calculate(String absolute, String r1, String r2); static final String DIR_SEPARATOR; }