/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.httprpc.io;

import java.io.IOException;
import java.io.StringReader;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import org.httprpc.AbstractTest;
import org.httprpc.io.CSVDecoder;
import org.junit.Assert;
import org.junit.Test;

public class CSVDecoderTest extends AbstractTest {
    private String text = "\"a\",\"b\",\"c\",\"d\"\r\n"
        + "\"A,B,\"\"C\"\" \",1,2.0,true\r\n"
        + "\" D\rE\nF\r\n\",2,4.0,false\n";

    @Test
    public void testRead() throws IOException {
        List<Map<String, ?>> expected = listOf(
            mapOf(
                entry("a", "A,B,\"C\" "),
                entry("b", "1"),
                entry("c", "2.0"),
                entry("d", "true")
            ),
            mapOf(
                entry("a", " D\rE\nF\r\n"),
                entry("b", "2"),
                entry("c", "4.0"),
                entry("d", "false")
            )
        );

        StringReader reader = new StringReader(text);

        CSVDecoder csvDecoder = new CSVDecoder();

        Iterable<Map<String, String>> cursor = csvDecoder.read(reader);
        List<Map<String, String>> actual = StreamSupport.stream(cursor.spliterator(), false).collect(Collectors.toList());

        Assert.assertEquals(expected, actual);
    }
}

@@ -933,15 +933,69 @@
     
-private
+@Test%0A    public void testRead() throws IOException %7B%0A       
  Str
@@ -1039,24 +1039,28 @@
 %5Cn%22%0A        
+    
 + %22%5C%22A,B,%5C%22%5C
@@ -1089,24 +1089,28 @@
 %5Cn%22%0A        
+  
+  
 + %22%5C%22 D%5CrE%5Cn
@@ -1102,25 +1102,25 @@
    + %22%5C%22 D%5Cr
-E
+%C3%89
 %5CnF%5Cr%5Cn%5C%22,2,
@@ -1138,66 +1138,8 @@
 %22;%0A%0A
-    @Test%0A    public void testRead() throws IOException %7B%0A
     
@@ -1412,17 +1412,17 @@
 %22, %22 D%5Cr
-E
+%C3%89
 %5CnF%5Cr%5Cn%22

Update tests.