add order and order test classes
This commit is contained in:
53
src/test/java/ats/orders/StopLossDetailsTest.java
Normal file
53
src/test/java/ats/orders/StopLossDetailsTest.java
Normal file
@ -0,0 +1,53 @@
|
||||
package ats.orders;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.json.JSONException;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* StopLossDetailsTest tests JSON format serialization of
|
||||
* StopLossDetails objects.
|
||||
*/
|
||||
public class StopLossDetailsTest extends OrderSerializationTestBase {
|
||||
|
||||
|
||||
/**
|
||||
* Test the simplest form, including default values.
|
||||
*/
|
||||
@Test
|
||||
public void testToJSONSmall()
|
||||
throws JsonProcessingException, JSONException
|
||||
{
|
||||
StopLossDetails obj = new StopLossDetails();
|
||||
obj.price = "12.34";
|
||||
|
||||
String expected = "{\"price\":\"12.34\",\"timeInForce\":\"GTC\",\"guaranteed\":false}";
|
||||
|
||||
doTest(obj, expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a fully filled out object.
|
||||
*/
|
||||
@Test
|
||||
public void testToJSONLarge()
|
||||
throws JsonProcessingException, JSONException
|
||||
{
|
||||
StopLossDetails obj = new StopLossDetails();
|
||||
obj.distance = new BigDecimal("12.34");
|
||||
obj.timeInForce = TimeInForce.GFD;
|
||||
obj.gtdTime = new DateTime("2000-09-17T18:02:52.957Z");
|
||||
|
||||
obj.clientExtensions = new ClientExtensions();
|
||||
obj.clientExtensions.id = "my id";
|
||||
obj.clientExtensions.tag = "my tag";
|
||||
obj.clientExtensions.comment = "my comment";
|
||||
|
||||
String expected = "{\"distance\":12.34,\"timeInForce\":\"GFD\",\"gtdTime\":\"2000-09-17T18:02:52.957Z\",\"clientExtensions\":{\"id\":\"my id\",\"tag\":\"my tag\",\"comment\":\"my comment\"},\"guaranteed\":false}";
|
||||
doTest(obj, expected);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user