package com.zoox.util;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class TestingUtils { // path relative to src/test/resources.  See GraphBoardProtoBuilderTest.java
  public static File getFile(ClassLoader classLoader, String first, String... more)
      throws URISyntaxException {
    Path filepath = Paths.get(first, more);
    URL diagram = classLoader.getResource(filepath.toFile().getPath());
    return new File(diagram.toURI());
	}
	
	public static String readFile(ClassLoader classLoader, String first, String... more)
			throws URISyntaxException, IOException
	{
		return readFile(getFile(classLoader, first, more));
	}

  public static String readFile(File file) throws IOException
  {
    return new String(Files.readAllBytes(Paths.get(file.getPath())));
  }

}