package fr.insee.pogues.transforms;

import org.junit.Test;

import java.util.Map;

import static org.junit.Assert.assertEquals;

public class TestPipeline {

    @Test
    public void passThroughTest() throws Exception {
        String input = "";
        PipeLine pipeline = new PipeLine();
        String output = pipeline.from(input).transform();
        assertEquals(input, output);
    }

    @Test
    public void mappingTest() throws Exception {
        String input = "";
        PipeLine.Transform<String, String> t0 = (String i, Map<String, Object> params) -> i + "concat";
        PipeLine pipeline = new PipeLine();
        String output = pipeline.from(input).map(t0, null).transform();
        assertEquals("concat", output);
    }
}

@@ -41,22 +41,143 @@
 ort 
-org.junit.Test
+fr.insee.pogues.webservice.rest.PoguesException;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.ExpectedException
 ;%0A%0Ai
@@ -273,16 +273,94 @@
 line %7B%0A%0A
+    @Rule%0A    public ExpectedException exception = ExpectedException.none();%0A%0A
     @Tes
@@ -381,16 +381,18 @@
 oid pass
+es
 ThroughT
@@ -622,12 +622,9 @@
  map
-ping
+s
 Test
@@ -937,11 +937,598 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void throwsExceptionTest() throws Exception %7B%0A        exception.expect(RuntimeException.class);%0A        exception.expectMessage(%22Exception occured while executing mapping function: Expected error%22);%0A        String input = %22%22;%0A        PipeLine.Transform%3CString, String%3E t0 = (String i, Map%3CString, Object%3E params) -%3E %7B%0A            throw new PoguesException(500, %22Expected error%22, %22Mapping function exception correctly propagates through pipeline%22);%0A        %7D;%0A        PipeLine pipeline = new PipeLine();%0A        pipeline.from(input).map(t0, null).transform();%0A    %7D
 %0A%7D%0A

Add Pipeline Unit Test: Exception should propagate through pipeline