add order and order test classes
This commit is contained in:
46
src/test/java/ats/orders/TakeProfitDetailsTest.java
Normal file
46
src/test/java/ats/orders/TakeProfitDetailsTest.java
Normal file
@ -0,0 +1,46 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user