FilesystemFacadeImpl implements IFilesystemFacade { @Override public IPath joinPaths(final IPath first, final IPath... rest) throws InvalidArgumentException { if (first == null || Arrays.asList(rest).indexOf(null) >= 0) { throw new InvalidArgumentException("One of arguments is null."); } java.nio.file.Path path = Paths.get(first.getPath()); for (IPath p : rest) { path = path.resolve(p.getPath()); } return new Path(path.toString()); }  @Override Collection<IPath> listSubdirectories(final IPath directory); @Override Collection<IPath> listFiles(final IPath directory, final IPathFilter filter); @Override IPath joinPaths(final IPath first, final IPath... rest); @Override String readToString(final IPath path);  }
@Test(expected = InvalidArgumentException.class) public void Should_joinPaths_throwWhenAnyOfPathsIsNull() throws Exception { assertNotNull(filesystemFacade.joinPaths(new Path("/"), new Path("."), null)); }
@Test public void Should_joinPaths_joinPaths() throws Exception { IPath joined = filesystemFacade.joinPaths(new Path("foo"), new Path("bar"), new Path("baz")); assertNotNull(joined); assertEquals(String.format("foo%sbar%sbaz", File.separator, File.separator), joined.getPath()); }