### Question:
TildeInPathResolver implements PathResolver { @Override public Path resolvePath(final String filePath) { final String resolved; if (filePath.startsWith("~/")) { resolved = systemUserHome + filePath.substring(1); } else { resolved = filePath; } if (!resolved.equals(filePath)) { logger.trace(String.format("We have resolved %s to %s. If this is not expected, please revise the path provided, or specify --detect.resolve.tilde.in.paths=false.", filePath, resolved)); } return Paths.get(resolved); } TildeInPathResolver(final String systemUserHome); @Override Path resolvePath(final String filePath);  }### Answer:
@Test @DisabledOnOs(WINDOWS) public void testResolvingTilde() { final TildeInPathResolver resolver = new TildeInPathResolver("/Users/ekerwin"); final Path resolved = resolver.resolvePath("~/Documents/source/funtional/detect"); Assertions.assertNotNull(resolved, "Resolved path should not be null."); Assertions.assertEquals("/Users/ekerwin/Documents/source/funtional/detect", resolved.toString(), "Tilde's should be resolved on Unix operating systems."); }
@Test @DisabledOnOs(WINDOWS) public void testResolvingTildeInTheMiddleOfAPath() { final TildeInPathResolver resolver = new TildeInPathResolver("/Users/ekerwin"); final String filePath = "/Documents/~source/~/funtional/detect"; final Path resolved = resolver.resolvePath(filePath); Assertions.assertNotNull(resolved, "Resolved path should not be null."); Assertions.assertEquals(filePath, resolved.toString(), "Tilde's in the middle of the path should not be resolved."); }
@Test public void testBlankPath() { final TildeInPathResolver resolver = new TildeInPathResolver("/Users/ekerwin"); Assertions.assertEquals("", resolver.resolvePath("").toString()); }
@Test @EnabledOnOs(WINDOWS) public void testWhitespacePath() { final TildeInPathResolver resolver = new TildeInPathResolver("/Users/ekerwin"); Assertions.assertThrows(InvalidPathException.class, () -> { resolver.resolvePath(" "); }); }