47 lines
1.4 KiB
Java
47 lines
1.4 KiB
Java
package ats.orders;
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
import org.joda.time.DateTime;
|
|
import org.json.JSONException;
|
|
import org.junit.Test;
|
|
|
|
/**
|
|
* TakeProfitDetailsTest tests JSON format serialization of
|
|
* TakeProfitDetails objects.
|
|
*/
|
|
public class TakeProfitDetailsTest extends OrderSerializationTestBase {
|
|
|
|
|
|
/**
|
|
* Test the simplest form, including default values.
|
|
*/
|
|
@Test
|
|
public void testToJSONSmall() throws JsonProcessingException, JSONException {
|
|
TakeProfitDetails obj = new TakeProfitDetails();
|
|
obj.price = "12.34";
|
|
|
|
String expected = "{\"price\":\"12.34\",\"timeInForce\":\"GTC\"}";
|
|
doTest(obj, expected);
|
|
}
|
|
|
|
/**
|
|
* Test a fully filled out object.
|
|
*/
|
|
@Test
|
|
public void testToJSONLarge() throws JsonProcessingException, JSONException {
|
|
TakeProfitDetails obj = new TakeProfitDetails();
|
|
obj.price = "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 = "{\"price\":\"12.34\",\"timeInForce\":\"GFD\",\"gtdTime\":\"2000-09-17T18:02:52.957Z\",\"clientExtensions\":{\"id\":\"my id\",\"tag\":\"my tag\",\"comment\":\"my comment\"}}";
|
|
doTest(obj, expected);
|
|
}
|
|
}
|