/*
 * 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.StringWriter;
import java.util.List;
import java.util.Map;

import org.httprpc.AbstractTest;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

public class FlatFileEncoderTest extends AbstractTest {
    @Test
    @Ignore // TODO
    public void testWrite() throws IOException {
        String expected = ""; // TODO

        List<Map<String, ?>> values = listOf(
            mapOf(
                entry("a", " AB C "),
                entry("b", 1),
                entry("c", 2.0)
            ),
            mapOf(
                entry("a", "  DEFGH IJKL "),
                entry("b", 2),
                entry("c", 4.0)
            )
        );

        StringWriter writer = new StringWriter();

        FlatFileEncoder flatFileEncoder = new FlatFileEncoder(listOf(
            new FlatFileEncoder.Field("a", "%10s"),
            new FlatFileEncoder.Field("b", "%05d"),
            new FlatFileEncoder.Field("c", "%04.2f")
        ));

        flatFileEncoder.write(values, writer);

        Assert.assertEquals(expected, writer.toString());
    }
}

@@ -745,33 +745,8 @@
 rt;%0A
-import org.junit.Ignore;%0A
 impo
@@ -764,16 +764,16 @@
 t.Test;%0A
+
 %0Apublic 
@@ -835,28 +835,8 @@
 est%0A
-    @Ignore // TODO%0A
     
@@ -911,18 +911,73 @@
  = %22
-%22; // TODO
+     AB C 000012.35%5Cr%5Cn%22 +%0A            %22  DEFGH IJ000024.57%5Cr%5Cn%22;
 %0A%0A  
@@ -1137,17 +1137,19 @@
 (%22c%22, 2.
-0
+345
 )%0A      
@@ -1281,17 +1281,20 @@
 (%22c%22, 4.
-0
+5678
 )%0A      
@@ -1426,32 +1426,32 @@
 Encoder(listOf(%0A
-
             new 
@@ -1479,16 +1479,19 @@
 (%22a%22, %22%25
+10.
 10s%22),%0A 

Update flat file encoder test.