yatsdev/AllGoTrading — pull request #31 by NeoSephiroth (2014-05-14 10:08:56+00:00)
Title: Update OrderCancelMsg.java

TESTED this way:

package org.yats.trading;

import org.joda.time.DateTime;
import org.yats.common.UniqueId;
import org.yats.messagebus.messages.OrderCancelMsg;

/**
* Created by emiliano on 14/05/2014.
*/
public class testEmiliano {

public static void main (String args[])
{
OrderCancel aa = OrderCancel.create().withExternalAccount("1005390").withBookSide(BookSide.BID).withProductId("4663789").withOrderId(UniqueId.createFromString("12345")).withTimestamp(DateTime.now());
OrderCancel bb = OrderCancel.create().withExternalAccount("1005390").withBookSide(BookSide.BID).withProductId("4663789").withOrderId(UniqueId.createFromString("12345")).withTimestamp(DateTime.now());
OrderCancelMsg a = OrderCancelMsg.createFromOrderCancel(aa);
OrderCancelMsg b = OrderCancelMsg.createFromOrderCancel(bb);

System.out.println(a.isSameAs(b));

}

}

Returns TRUE! If I don't touch UniqueID and let it be automatically generated, like this:

package org.yats.trading;

import org.joda.time.DateTime;
import org.yats.messagebus.messages.OrderCancelMsg;

/**
* Created by emiliano on 14/05/2014.
*/
public class testEmiliano {

public static void main (String args[])
{
OrderCancel aa = OrderCancel.create().withExternalAccount("1005390").withBookSide(BookSide.BID).withProductId("4663789").withTimestamp(DateTime.now());
OrderCancel bb = OrderCancel.create().withExternalAccount("1005390").withBookSide(BookSide.BID).withProductId("4663789").withTimestamp(DateTime.now());
OrderCancelMsg a = OrderCancelMsg.createFromOrderCancel(aa);
OrderCancelMsg b = OrderCancelMsg.createFromOrderCancel(bb);

System.out.println(a.isSameAs(b));

}

}

Returns false, since the UniqueId is generated, and thus differs in OrderCancelMsg a and b.