// Path: java-runtime-builder-app/src/test/java/com/google/cloud/runtimes/builder/TestUtils.java
// public static class TestWorkspaceBuilder {
// 
//   private final Path workspaceDir;
// 
//   public TestWorkspaceBuilder() throws IOException {
//     this.workspaceDir = Files.createTempDirectory(null);
//   }
// 
//   public FileBuilder file(String path) {
//     return new FileBuilder(this, workspaceDir.resolve(path));
//   }
// 
//   public Path build() {
//     return workspaceDir;
//   }
// 
//   public class FileBuilder {
//     private final Path path;
//     private final TestWorkspaceBuilder workspaceBuilder;
//     private String contents = "";
//     private boolean isExecutable = false;
// 
//     private FileBuilder(TestWorkspaceBuilder workspaceBuilder, Path path) {
//       this.workspaceBuilder = workspaceBuilder;
//       this.path = path;
//     }
// 
//     public FileBuilder withContents(String contents) {
//       this.contents = contents;
//       return this;
//     }
// 
//     public FileBuilder setIsExecutable(boolean isExecutable) {
//       this.isExecutable = isExecutable;
//       return this;
//     }
// 
//     public TestWorkspaceBuilder build() throws IOException {
//       // mkdir -p
//       Files.createDirectories(path.getParent());
// 
//       try (Writer out = Files.newBufferedWriter(path, Charset.defaultCharset())) {
//         out.write(contents);
//       }
// 
//       Set<PosixFilePermission> permissions = Sets.newHashSet(
//           PosixFilePermission.OWNER_READ,
//           PosixFilePermission.OWNER_WRITE);
//       if (isExecutable) {
//         permissions.add(PosixFilePermission.OWNER_EXECUTE);
//       }
// 
//       Files.setPosixFilePermissions(path, permissions);
//       return workspaceBuilder;
//     }
//   }
// }


import static com.google.cloud.runtimes.builder.config.domain.Artifact.ArtifactType.COMPAT_EXPLODED_WAR;
import static com.google.cloud.runtimes.builder.config.domain.Artifact.ArtifactType.EXPLODED_WAR;
import static com.google.cloud.runtimes.builder.config.domain.Artifact.ArtifactType.JAR;
import static com.google.cloud.runtimes.builder.config.domain.Artifact.ArtifactType.WAR;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.google.cloud.runtimes.builder.TestUtils.TestWorkspaceBuilder;
import com.google.common.collect.ImmutableList;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
package com.google.cloud.runtimes.builder.config.domain;





public class ArtifactTest {

  private List<Path> invalidArtifacts = ImmutableList.of(
      Paths.get("foo.txt"),
      Paths.get("foo.java"),
      Paths.get("some_dir/"),
      Paths.get("WEB-INF/appengine-web.xml"),
      Paths.get("WEB-INF/web.xml")
  );

  @Test
  public void testNonExistentWar() {
    Path path = Paths.get("/foo/bar.war");
    assertTrue(Artifact.isAnArtifact(path));

    Artifact result = Artifact.fromPath(path);
    assertEquals(path, result.getPath());
    assertEquals(WAR, result.getType());
  }

  @Test
  public void testExistingWar() throws IOException {
// Path: java-runtime-builder-app/src/test/java/com/google/cloud/runtimes/builder/TestUtils.java
// public static class TestWorkspaceBuilder {
// 
//   private final Path workspaceDir;
// 
//   public TestWorkspaceBuilder() throws IOException {
//     this.workspaceDir = Files.createTempDirectory(null);
//   }
// 
//   public FileBuilder file(String path) {
//     return new FileBuilder(this, workspaceDir.resolve(path));
//   }
// 
//   public Path build() {
//     return workspaceDir;
//   }
// 
//   public class FileBuilder {
//     private final Path path;
//     private final TestWorkspaceBuilder workspaceBuilder;
//     private String contents = "";
//     private boolean isExecutable = false;
// 
//     private FileBuilder(TestWorkspaceBuilder workspaceBuilder, Path path) {
//       this.workspaceBuilder = workspaceBuilder;
//       this.path = path;
//     }
// 
//     public FileBuilder withContents(String contents) {
//       this.contents = contents;
//       return this;
//     }
// 
//     public FileBuilder setIsExecutable(boolean isExecutable) {
//       this.isExecutable = isExecutable;
//       return this;
//     }
// 
//     public TestWorkspaceBuilder build() throws IOException {
//       // mkdir -p
//       Files.createDirectories(path.getParent());
// 
//       try (Writer out = Files.newBufferedWriter(path, Charset.defaultCharset())) {
//         out.write(contents);
//       }
// 
//       Set<PosixFilePermission> permissions = Sets.newHashSet(
//           PosixFilePermission.OWNER_READ,
//           PosixFilePermission.OWNER_WRITE);
//       if (isExecutable) {
//         permissions.add(PosixFilePermission.OWNER_EXECUTE);
//       }
// 
//       Files.setPosixFilePermissions(path, permissions);
//       return workspaceBuilder;
//     }
//   }
// }


// Path: java-runtime-builder-app/src/test/java/com/google/cloud/runtimes/builder/config/domain/ArtifactTest.java
import static com.google.cloud.runtimes.builder.config.domain.Artifact.ArtifactType.COMPAT_EXPLODED_WAR;
import static com.google.cloud.runtimes.builder.config.domain.Artifact.ArtifactType.EXPLODED_WAR;
import static com.google.cloud.runtimes.builder.config.domain.Artifact.ArtifactType.JAR;
import static com.google.cloud.runtimes.builder.config.domain.Artifact.ArtifactType.WAR;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.google.cloud.runtimes.builder.TestUtils.TestWorkspaceBuilder;
import com.google.common.collect.ImmutableList;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

package com.google.cloud.runtimes.builder.config.domain;





public class ArtifactTest {

  private List<Path> invalidArtifacts = ImmutableList.of(
      Paths.get("foo.txt"),
      Paths.get("foo.java"),
      Paths.get("some_dir/"),
      Paths.get("WEB-INF/appengine-web.xml"),
      Paths.get("WEB-INF/web.xml")
  );

  @Test
  public void testNonExistentWar() {
    Path path = Paths.get("/foo/bar.war");
    assertTrue(Artifact.isAnArtifact(path));

    Artifact result = Artifact.fromPath(path);
    assertEquals(path, result.getPath());
    assertEquals(WAR, result.getType());
  }

  @Test
  public void testExistingWar() throws IOException {
    Path workspace = new TestWorkspaceBuilder()