ImageDirectoryLocator { public static File locateImagesDirectoryInUnpackedDistDirectory(String parentImagesPackageResourceLocation) { log.info("locateImagesDirectoryInUnpackedDistDirectory : parentImagesPackageResourceLocation = {}", parentImagesPackageResourceLocation); final File workingDirectory = new File("."); log.info("locateImagesDirectoryInUnpackedDistDirectory : workingDirectory = {}", workingDirectory.getAbsolutePath()); final String workingDirectoryName; try { workingDirectoryName = workingDirectory.getCanonicalFile().getName(); } catch (IOException e) { throw new RuntimeException(e); } log.info("locateImagesDirectoryInUnpackedDistDirectory : workingDirectoryName = {}", workingDirectoryName); File imagesDirectory = new File(workingDirectory, parentImagesPackageResourceLocation); boolean checked = checkImageDirectory(imagesDirectory); if (checked) { log.info("locateImagesDirectoryInUnpackedDistDirectory : imagesDirectory = {}", imagesDirectory.getAbsolutePath()); return imagesDirectory; } else { log.debug("locateImagesDirectoryInUnpackedDistDirectory : could not locate images directory at {}", imagesDirectory.getAbsolutePath()); imagesDirectory = new File(workingDirectory, "/gazeplay/src/main/resources/" + parentImagesPackageResourceLocation); checked = checkImageDirectory(imagesDirectory); if (checked) { log.info("locateImagesDirectoryInUnpackedDistDirectory : imagesDirectory = {}", imagesDirectory.getAbsolutePath()); return imagesDirectory; } } if (workingDirectoryName.equals("bin")) { imagesDirectory = new File(workingDirectory, "../" + parentImagesPackageResourceLocation); log.info("locateImagesDirectoryInUnpackedDistDirectory : imagesDirectory = {}", imagesDirectory.getAbsolutePath()); checked = checkImageDirectory(imagesDirectory); if (checked) { return imagesDirectory; } } return null; }  static File locateImagesDirectoryInUnpackedDistDirectory(String parentImagesPackageResourceLocation); static File locateImagesDirectoryInExplodedClassPath(String parentImagesPackageResourceLocation);  }
@Test void canLocateImagesDirectoryInUnpackedDistDirectory() { final File expected = new File("." + FILESEPARATOR, folderName); final File result = ImageDirectoryLocator.locateImagesDirectoryInUnpackedDistDirectory(folderName); assert (result.equals(expected)); }