package quantisan.qte_lmax;

import com.lmax.api.FixedPointNumber;
import com.lmax.api.TimeInForce;
import com.lmax.api.order.AmendStopsRequest;
import com.lmax.api.order.MarketOrderSpecification;
import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class OrderTest {
    @Ignore @Test
    public void testToMarketOrder() throws Exception {
        long instrument = 4001;
        String orderId = "my order 1";
        FixedPointNumber quantity = FixedPointNumber.valueOf("1.0");
        FixedPointNumber stopLossOffset = FixedPointNumber.valueOf("10.0");
        MarketOrderSpecification mos = new MarketOrderSpecification(instrument, orderId, quantity, TimeInForce.IMMEDIATE_OR_CANCEL,stopLossOffset, null);
        // {:instrument "EURUSD", :order-id "my_order_1", :quantity "0.1", :stop-loss-offset "10", :order-type :market}
//        assertEquals(mos.toString(),
//                Order.toMarketOrder("{:instrument \"EURUSD\", :order-id \"my_order_1\", :quantity 1, :stop-loss-offset 10}").toString());
    }

    @Ignore @Test
    public void testToAmendStopOrder() throws Exception {
        long instrument = 4001;
        String orderId = "my order 1";
        FixedPointNumber stopLossOffset = FixedPointNumber.valueOf(10);
        AmendStopsRequest request = new AmendStopsRequest(instrument, orderId, orderId, stopLossOffset, null);
//        assertEquals(request,  // BUG equals useless and no toString
//                Order.toAmendStopOrder("{:order-type :amend-stop, :instrument \"EURUSD\", :order-id \"my order 1\", :stop-loss-offset 10}"));
    }

    @Ignore @Test
    public void testParseOrderType() throws Exception {
        assertEquals(Order.OrderType.MARKET, Order.parseOrderType("{:order-type :market}"));
        assertEquals(Order.OrderType.AMEND_STOP, Order.parseOrderType("{:order-type :amend-stop}"));
        assertEquals(Order.OrderType.UNKNOWN, Order.parseOrderType("{}"));
    }
}
@@ -64,163 +64,8 @@
 er;%0A
-import com.lmax.api.TimeInForce;%0Aimport com.lmax.api.order.AmendStopsRequest;%0Aimport com.lmax.api.order.MarketOrderSpecification;%0Aimport org.junit.Ignore;%0A
 impo
@@ -132,51 +132,8 @@
 als;
-%0Aimport static org.junit.Assert.assertTrue;
 %0A%0Apu
@@ -155,32 +155,24 @@
 rTest %7B%0A    
-@Ignore 
 @Test%0A    pu
@@ -185,18 +185,16 @@
 oid test
-To
 MarketOr
@@ -192,24 +192,35 @@
 tMarketOrder
+Constructor
 () throws Ex
@@ -241,516 +241,349 @@
     
-long instrument = 4001;%0A        String orderId = %22my 
+String message = %22%7B:instrument %5C%22EURUSD%5C%22, :order-id %5C%22my_
 order
- 1%22;%0A        FixedPointNumber quantity = FixedPointNumber.valueOf(%221.0%22);%0A        FixedPointNumber 
+_1%5C%22, :quantity %5C%220.1%5C%22, :
 stop
-LossO
+-loss-o
 ffset 
-= FixedPointNumber.valueOf(%2210.0%22);%0A        MarketOrderSpecification mos = new MarketOrderSpecification(instrument, orderId, quantity, TimeInForce.IMMEDIATE_OR_CANCEL,stopLossOffset, null);%0A        // %7B:instrument %22EURUSD%22, :order-id %22my_order_1%22, :quantity %220.1%22, :stop-loss-offset %2210%22, :order-type :market%7D%0A//        assertEquals(mos
+%5C%2210%5C%22, :order-type :market%7D%22;%0A        Order order = new Order(null, message);%0A        assertEquals(4001, order.getInstrumentId());%0A        assertEquals(%22my_order_1%22, order.getOrderId());%0A        assertEquals(%220.1%22, order.getQuantity()
 .toS
@@ -593,20 +593,19 @@
 ng()
-,%0A//
+);%0A
         
     
@@ -604,123 +604,51 @@
     
-        Order.toMarketOrder(%22%7B:instrument %5C%22EURUSD%5C
+assertEquals(%2210
 %22, 
-:
 order
--id %5C%22my_order_1%5C%22, :quantity 1, :stop-loss-o
+.getStopLossO
 ffset
- 10%7D%22
+(
 ).to
@@ -665,32 +665,24 @@
 %0A    %7D%0A%0A    
-@Ignore 
 @Test%0A    pu
@@ -699,24 +699,29 @@
 test
-To
 Amend
-Stop
 Order
+Constructor
 () t
@@ -750,256 +750,178 @@
     
-long instrument = 4001;%0A        String orderId = %22my 
+String message = %22%7B:instrument %5C%22EURUSD%5C%22, :order-id %5C%22my_
 order
- 1%22;%0A        FixedPointNumber 
+_1%5C%22, :
 stop
-LossO
+-loss-o
 ffset 
-= FixedPointNumber.valueOf(10);%0A        AmendStopsRequest request = new AmendStopsRequest(instrument, orderId, orderId, stopLossOffset, null
+%5C%2220%5C%22, :order-type :amend-stop%7D%22;%0A        Order order = new Order(null, message
 );%0A
-//
     
@@ -941,196 +941,224 @@
 als(
-request,  // BUG equals useless and no toString%0A//                Order.toAmendStopOrder(%22%7B:order-type :amend-stop, :instrument %5C%22EURUSD%5C%22
+4001, order.getInstrumentId());%0A        assertEquals(%22my_order_1%22, order.getOrderId());%0A        assertEquals(FixedPointNumber.ZERO
 , 
-:
 order
--id %5C%22my order 1%5C%22, :stop-loss-o
+.getQuantity());%0A        assertEquals(%2220%22, order.getStopLossO
 ffset
- 10%7D%22
+().toString(
 ));%0A
@@ -1172,16 +1172,8 @@
     
-@Ignore 
 @Tes

update order test check constructor and order types