package de.tuberlin.dima.schubotz.fse;

import de.tuberlin.dima.schubotz.utils.TestUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.io.File;
import java.util.Arrays;
import java.util.Collection;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

public class PreprocessIT {
    @Rule
    public TemporaryFolder testFolder = new TemporaryFolder();
    @Test
    public void TestLocalExecution() throws Exception {
        final String inputModule = "ArxivRawInput";
        final String algoModule = "RawToPreprocessed";
        final String rawDataFile = "file://" + getClass().getClassLoader().getResources(
                TestUtils.getTestFile10StringPath()).nextElement().getPath();
        final String rawQueryFile = "file://" + getClass().getClassLoader().getResources(
                TestUtils.getFQueryStringPath()).nextElement().getPath();
        final String runtag = "mainTest10";
        final String numSubTasks = "1";
        final File outputFileFolder = testFolder.newFolder("testMain10");
        final String outputDir = "file://" + outputFileFolder.getCanonicalPath();

        final String[] params = {algoModule, inputModule, "-DATARAW_FILE", rawDataFile,
                "-QUERY_FILE", rawQueryFile, "-RUNTAG", runtag,
                "-NUM_SUB_TASKS", numSubTasks, "-OUTPUT_DIR", outputDir};

        MainProgram.main(params);

        assertEquals(2, (long) outputFileFolder.listFiles().length);

    }
}

@@ -258,20 +258,17 @@
 java.io.
-File
+*
 ;%0Aimport
@@ -357,24 +357,67 @@
 sertEquals;%0A
+import static org.junit.Assert.assertTrue;%0A
 import stati
@@ -1143,155 +1143,982 @@
     
-final File outputFileFolder = testFolder.newFolder(%22testMain10%22);%0A        final String outputDir = %22file://%22 + outputFileFolder.getCanonicalPath
+File%5B%5D files = %7BtestFolder.newFolder(%22testMain10%22),%0A                testFolder.newFile(%22preprocessedData.csv%22),%0A                testFolder.newFile(%22preprocessedQueries.csv%22),%0A                testFolder.newFile(%22latexCounts.csv%22),%0A                testFolder.newFile(%22numDocs.csv%22),%0A                testFolder.newFile(%22keywordCounts.csv%22)%7D;%0A        for (File file : files) %7B%0A            file.setWritable(true);%0A            if (!file.canWrite() %7C%7C !file.canRead()) %7B%0A                fail(%22Unable to write to files, test cannot be run.%22);%0A                return;%0A            %7D;%0A        %7D%0A%0A        String outputDir = testFolder.getRoot().getCanonicalPath();%0A        outputDir = outputDir.replaceAll(%22%5C%5C%5C%5C%22,%22/%22);%0A%0A        try (BufferedWriter out = new BufferedWriter(new FileWriter(outputDir + %22/%22 + %22numDocs.csv%22))) %7B%0A            out.write(%22asdfasdf%22);%0A        %7D catch (Exception e) %7B%0A            fail(%22Could not write to numDocs: %22 + outputDir + %22 %22 + e.getMessage
 ()
+)
 ;
+%0A        %7D
 %0A%0A  
@@ -2389,68 +2389,225 @@
     
-assertEquals(2, (long) outputFileFolder.listFiles().length);
+for (File file : files) %7B%0A            try (BufferedReader br = new BufferedReader(new FileReader(file))) %7B%0A                br.readLine();%0A                assertTrue(br.readLine().length() %3E 0);%0A            %7D%0A        %7D
 %0A%0A  

Fix bug in integration test with backslashes Still unable to write (throws FileNotFound)