### Question:
FileReadWriteUtils { public static String toFullPath(@Nonnull final String dirPath, @Nonnull final String fileName) { final String dirPathWithSeparator = dirPath.endsWith(File.separator) ? dirPath : dirPath + File.separator; final String fullFileName = dirPathWithSeparator + fileName; if (!getCanonicalName(fullFileName).startsWith(getCanonicalName(dirPathWithSeparator))) { throw new IllegalArgumentException("Invalid file name: " + fileName); } return fullFileName; } private  FileReadWriteUtils(); static File getOrCreateDirectory(@Nonnull final String path); static String readResourceAsString(@Nonnull final String resourceFileName); static String readFileAsString(@Nonnull final File file); static String toFullPath(@Nonnull final String dirPath, @Nonnull final String fileName); static void writeToFile(final String fileName, final Consumer<Writer> writeHandler);  }### Answer:
@Test public void testToFullPath() { assertThat(toFullPath("/tmp/jarviz/jars", "fooBar123.jar")) .isEqualTo("/tmp/jarviz/jars" + File.separator + "fooBar123.jar"); assertThat(toFullPath("/tmp/jarviz/jars/", "fooBar123.jar")) .isEqualTo("/tmp/jarviz/jars" + File.separator + "fooBar123.jar"); }
@Test public void testToFullPath_ValidationFailure() { final String oneLevelUp = File.separator + ".." + File.separator; assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> toFullPath("/tmp/jarviz/jars", oneLevelUp + "fooBar123.jar")); }