package org.jvirtanen.philadelphia;

import static org.junit.Assert.*;
import static org.jvirtanen.philadelphia.fix42.FIX42Tags.*;

import java.nio.ByteBuffer;
import org.joda.time.MutableDateTime;
import org.junit.Before;
import org.junit.Test;

public class FIXMessageTest {

    private FIXMessage message;

    @Before
    public void setUp() {
        message = new FIXMessage(32, 32);
    }

    @Test
    public void format() {
        MutableDateTime timestamp = new MutableDateTime(2015, 9, 24, 9, 30, 5, 250);

        message.addField(ClOrdID).setString("123");
        message.addField(HandlInst).setChar('1');
        message.addField(Symbol).setString("FOO");
        message.addField(Side).setChar('1');
        message.addField(TransactTime).setTimestamp(timestamp, true);
        message.addField(OrderQty).setInt(100);
        message.addField(OrdType).setChar('2');
        message.addField(Price).setFloat(150.25, 2);

        ByteBuffer buffer = ByteBuffer.allocate(256);

        message.put(buffer);
        buffer.flip();

        assertEquals("11=123\u000121=1\u000155=FOO\u000154=1\u0001" +
                "60=20150924-09:30:05.250\u000138=100\u000140=2\u0001" +
                "44=150.25\u0001", ByteBuffers.getString(buffer));
    }

}

@@ -64,16 +64,84 @@
 sert.*;%0A
+import static org.jvirtanen.philadelphia.fix42.FIX42Enumerations.*;%0A
 import s
@@ -670,35 +670,80 @@
 dlInst).setChar(
-'1'
+HandlInstValues.AutomatedExecutionNoIntervention
 );%0A        messa
@@ -823,11 +823,22 @@
 har(
-'1'
+SideValues.Buy
 );%0A 
@@ -1000,11 +1000,27 @@
 har(
-'2'
+OrdTypeValues.Limit
 );%0A 

Use FIX 4.2 enumerations in FIX message test