package de.tblsoft.solr.pipeline.pipeline;

import de.tblsoft.solr.pipeline.PipelineExecuter;
import de.tblsoft.solr.pipeline.test.AbstractPipelineTest;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Test;

import java.io.File;

/**
 * Created by tblsoft on 11.05.16.
 */
public class CsvWriterTest extends AbstractPipelineTest {

    @Test
    public void writeCsv() throws Exception {
        PipelineExecuter executer = new PipelineExecuter("examples/unittest/csv-writer-pipeline.yaml");
        executer.execute();

        String actual = FileUtils.readFileToString(new File("examples/unittest/output.csv"));
        String expected = FileUtils.readFileToString(new File("examples/unittest/expected.csv"));

        System.out.println(actual);
        System.out.println("---------------");
        System.out.println(expected);

        Assert.assertEquals(expected, actual);

        FileUtils.deleteQuietly(new File("examples/unittest/output.csv"));

    }
}

@@ -146,16 +146,60 @@
 neTest;%0A
+import org.apache.commons.codec.binary.Hex;%0A
 import o
@@ -781,24 +781,26 @@
 ed.csv%22));%0A%0A
+%0A%0A
         Syst
@@ -814,23 +814,31 @@
 println(
+getHex(
 actual)
+)
 ;%0A      
@@ -905,16 +905,23 @@
 println(
+getHex(
 expected
@@ -921,16 +921,17 @@
 xpected)
+)
 ;%0A%0A     
@@ -969,24 +969,24 @@
 , actual);%0A%0A
-
         File
@@ -1045,20 +1045,180 @@
 ut.csv%22));%0A%0A
+    %7D%0A%0A    String getHex(String value ) throws Exception %7B%0A        String hexString = Hex.encodeHexString(value.getBytes(%22UTF-8%22));%0A        return hexString;%0A%0A%0A
     %7D%0A%7D%0A

add test for csv writer and implement some bugfixes