package com.github.violetlaw.citegen;

import java.io.File;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.LinkedList;
import java.util.List;

import com.google.auto.value.AutoValue;
import com.google.common.collect.Lists;

public class CitationGeneratorTest {

  // TODO(nnaze): Implement parameterized tests at this point.

  private static Path GOLDEN_TESTS = Paths.get("src/test/resources/goldentests");
  private static Path INPUT = GOLDEN_TESTS.resolve("input");
  private static Path OUTPUT = GOLDEN_TESTS.resolve("output");

  @AutoValue
  static abstract class GoldenTestCase {
    static GoldenTestCase create(File input, File output) {
      return new AutoValue_TestCase(input, output);
    }

    abstract File input();

    abstract File output();
  }

  private static List<GoldenTestCase> getTestCases() throws IOException {
    List<GoldenTestCase> testCases = Lists.newLinkedList();
    DirectoryStream<Path> inputPaths = Files.newDirectoryStream(INPUT, "*.json");
    for (Path inputPath : inputPaths) {
      Path outputPath = OUTPUT.resolve(inputPath.getFileName());

      testCases.add(GoldenTestCase.create(inputPath.toFile(), outputPath.toFile()));
    }

    return testCases;
  }
}

@@ -368,16 +368,107 @@
 t.Lists;
+%0Aimport org.junit.runners.Parameterized;%0Aimport org.junit.runners.Parameterized.Parameters;
 %0A%0Apublic
@@ -641,24 +641,25 @@
 dentests%22);%0A
+%0A
   private st
@@ -771,16 +771,130 @@
 put%22);%0A%0A
+ @Parameters%0A  public static Iterable%3CGoldenTestData%3E data() throws IOException %7B%0A    return getTestCases();%0A  %7D%0A%0A
   @AutoV
@@ -900,16 +900,23 @@
 Value%0A  
+public 
 static a
@@ -939,20 +939,20 @@
 ldenTest
-Case
+Data
  %7B%0A    s
@@ -971,20 +971,20 @@
 Test
-Case
+Data
  create(
 File
@@ -983,31 +983,39 @@
 ate(
-File
+Path
  input
-, File
+Path, Path
  output
+Path
 ) %7B%0A
@@ -1045,30 +1045,62 @@
 lue_
-TestCase
+CitationGeneratorTest_GoldenTestData
 (input
+Path
 , output
 );%0A 
@@ -1095,16 +1095,20 @@
 , output
+Path
 );%0A    %7D
@@ -1126,18 +1126,22 @@
 act 
-File
+Path
  input
+Path
 ();%0A
@@ -1158,19 +1158,23 @@
 act 
-File
+Path
  output
+Path
 ();%0A
@@ -1210,20 +1210,20 @@
 ldenTest
-Case
+Data
 %3E getTes
@@ -1271,20 +1271,20 @@
 ldenTest
-Case
+Data
 %3E testCa
@@ -1530,20 +1530,20 @@
 ldenTest
-Case
+Data
 .create(
@@ -1551,25 +1551,16 @@
 nputPath
-.toFile()
 , output
@@ -1567,17 +1567,8 @@
 Path
-.toFile()
 ));%0A

update test names in preparation for Parameterized runner