NodeAgentContextImpl implements NodeAgentContext { @Override public Path pathInNodeFromPathOnHost(Path pathOnHost) { requireValidPath(pathOnHost); if (! pathOnHost.isAbsolute()) throw new IllegalArgumentException("Expected an absolute path on the host, got: " + pathOnHost); if (!pathOnHost.startsWith(pathToNodeRootOnHost)) throw new IllegalArgumentException("Path " + pathOnHost + " does not exist in the container"); return pathOnHost.getRoot().resolve(pathToNodeRootOnHost.relativize(pathOnHost)); } NodeAgentContextImpl(NodeSpec node, Acl acl, AthenzIdentity identity,
                                DockerNetworking dockerNetworking, ZoneApi zone,
                                FileSystem fileSystem, FlagSource flagSource,
                                Path pathToContainerStorage, Path pathToVespaHome,
                                String vespaUser, String vespaUserOnHost, double cpuSpeedup); @Override NodeSpec node(); @Override Acl acl(); @Override ContainerName containerName(); @Override AthenzIdentity identity(); @Override DockerNetworking dockerNetworking(); @Override ZoneApi zone(); @Override String vespaUser(); @Override String vespaUserOnHost(); @Override boolean isDisabled(NodeAgentTask task); @Override double unscaledVcpu(); @Override FileSystem fileSystem(); @Override Path pathOnHostFromPathInNode(Path pathInNode); @Override Path pathInNodeFromPathOnHost(Path pathOnHost); @Override Path pathInNodeUnderVespaHome(Path relativePath); @Override void recordSystemModification(Logger logger, String message); @Override void log(Logger logger, Level level, String message); @Override void log(Logger logger, Level level, String message, Throwable throwable); @Override String toString();  }
@Test(expected=IllegalArgumentException.class) public void path_on_host_must_be_absolute() { context.pathInNodeFromPathOnHost("some/relative/path"); }
@Test(expected=IllegalArgumentException.class) public void path_on_host_must_be_inside_container_storage_of_context() { context.pathInNodeFromPathOnHost(fileSystem.getPath("/home/docker/container-storage/container-2/dev/null")); }
@Test(expected=IllegalArgumentException.class) public void path_on_host_must_be_inside_container_storage() { context.pathInNodeFromPathOnHost(fileSystem.getPath("/home")); }