Skip to content

Commit

Permalink
Fixes issue #42, a new fillId property has been added to the Fill dao
Browse files Browse the repository at this point in the history
  • Loading branch information
CCob committed Sep 19, 2018
1 parent 811b7be commit a486210
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/main/java/com/github/ccob/bittrex4j/dao/Fill.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,22 @@ public class Fill {
double quantity;
double total;
ZonedDateTime timeStamp;
int fillId;



@JsonCreator
public Fill(@Nullable @JsonProperty("Id") @JsonAlias("I") Long id, @JsonProperty("OrderType") @JsonAlias("OT") String orderType, @Nullable @JsonProperty("FillType") @JsonAlias("F") String fillType,
@Nullable @JsonProperty("Price") @JsonAlias("P") Double price, @Nullable @JsonProperty("Rate") @JsonAlias("R")Double rate,
@JsonProperty("Quantity") @JsonAlias("Q") double quantity, @Nullable @JsonProperty("Total") @JsonAlias("t") Double total, @JsonProperty("TimeStamp") @JsonAlias("T") ZonedDateTime timeStamp){
@JsonProperty("Quantity") @JsonAlias("Q") double quantity, @Nullable @JsonProperty("Total") @JsonAlias("t") Double total, @JsonProperty("TimeStamp") @JsonAlias("T") ZonedDateTime timeStamp,
@JsonProperty("FI") Integer fillId){

if(rate == null && price == null){
throw new IllegalArgumentException("Either rate or price should be set");
}

this.id = id;
this.fillId = fillId;
this.orderType = orderType;
this.quantity = quantity;
this.timeStamp = timeStamp;
Expand Down Expand Up @@ -89,4 +92,8 @@ public double getTotal() {
public @Nullable String getFillType() {
return fillType;
}

public int getFillId() {
return fillId;
}
}
4 changes: 2 additions & 2 deletions src/test/java/com/github/ccob/bittrex4j/dao/DaoTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public void shouldImplementDaoPojoGetters(){
}

private void assertPojoMethodsForFill(Method method[]){
final Object[] constructorParameters = {1L, "string1", "string2", Double.valueOf(2), null, 4.0, Double.valueOf(5), ZonedDateTime.now()};
final Class[] constructorParameterTypes = {Long.class, String.class, String.class, Double.class, Double.class, double.class, Double.class, ZonedDateTime.class};
final Object[] constructorParameters = {1L, "string1", "string2", Double.valueOf(2), null, 4.0, Double.valueOf(5), ZonedDateTime.now(), Integer.valueOf(2)};
final Class[] constructorParameterTypes = {Long.class, String.class, String.class, Double.class, Double.class, double.class, Double.class, ZonedDateTime.class, Integer.class};
assertPojoMethodsFor(classUnderTest)
.create(classUnderTest, constructorParameters, constructorParameterTypes)
.testing(method)
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/github/ccob/bittrex4j/dao/FillTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public class FillTest {

@Test (expected = IllegalArgumentException.class)
public void shouldThrowWhenConstructedWithBothPriceAndRate(){
new Fill(1L,"ORDER","FILL",1.0,2.0,1.0,1.0, ZonedDateTime.now());
new Fill(1L,"ORDER","FILL",1.0,2.0,1.0,1.0, ZonedDateTime.now(),2);
}

@Test (expected = IllegalArgumentException.class)
public void shouldThrowWhenConstructedWithoutBothPriceAndRate(){
new Fill(1L,"ORDER","FILL",null,null,1.0,1.0, ZonedDateTime.now());
new Fill(1L,"ORDER","FILL",null,null,1.0,1.0, ZonedDateTime.now(),2);
}
}

0 comments on commit a486210

Please sign in to comment.