Skip to content

Commit

Permalink
Merge pull request #64 from bunq/#46-Cannot-list-payments-due-to-geol…
Browse files Browse the repository at this point in the history
…ocation

Cannot list payments due to geolocation. (#46 )
  • Loading branch information
OGKevin authored Jan 3, 2018
2 parents c4bf2ef + 8f4d35a commit 25149ea
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/com/bunq/sdk/json/BigDecimalTypeAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public void write(JsonWriter output, BigDecimal value) throws IOException {

@Override
public BigDecimal read(JsonReader input) throws IOException {
if (input.peek() == JsonToken.STRING) {
JsonToken type = input.peek();

if (type == JsonToken.NUMBER) {
return new BigDecimal(input.nextDouble());
} else if (type == JsonToken.STRING) {
return new BigDecimal(input.nextString());
} else {
input.nextNull();
Expand Down
1 change: 1 addition & 0 deletions src/test/config.example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ CASH_REGISTER_ID=xxx
#Same user, alias from other account
SAME_USER_OTHER_ACCOUNT_ALIAS=<Email address>
SAME_USER_OTHER_ACCOUNT_TYPE=EMAIL
PAYMENT_ID_WITH_GEOLOCATION=0
5 changes: 5 additions & 0 deletions src/test/java/com/bunq/sdk/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class Config {
private static final String FIELD_CASH_REGISTER_ID = "CASH_REGISTER_ID";
private static final String FIELD_SAME_USER_OTHER_ACCOUNT_ALIAS = "SAME_USER_OTHER_ACCOUNT_ALIAS";
private static final String FIELD_SAME_USER_OTHER_ACCOUNT_TYPE = "SAME_USER_OTHER_ACCOUNT_TYPE";
private static final String FIELD_PAYMENT_ID_WITH_GEOLOCATION = "PAYMENT_ID_WITH_GEOLOCATION";

private static Properties properties = getProperties();

Expand Down Expand Up @@ -118,4 +119,8 @@ public static Pointer getCounterPartyAliasSelf() {
return new Pointer(type, value);
}

public static Integer getPaymentIdWithGeolocation() {
return Integer.parseInt(properties.getProperty(FIELD_PAYMENT_ID_WITH_GEOLOCATION));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.bunq.sdk.model.generated.object.Pointer;
import java.util.HashMap;
import org.junit.Test;
import org.junit.Assert;
import org.junit.Assume;

/**
* Tests:
Expand All @@ -19,6 +21,7 @@ public class PaymentTest extends BunqSdkTestBase {
*/
private static final int userId = Config.getUserId();
private static final int monetaryAccountId = Config.getMonetaryAccountId();
private static final int paymentIdwithGeolocation = Config.getPaymentIdWithGeolocation();
private static final Pointer counterPartyAliasOther = Config.getCounterPartyAliasOther();
private static final Pointer counterPartyAliasSelf = Config.getCounterPartyAliasSelf();

Expand All @@ -28,6 +31,10 @@ public class PaymentTest extends BunqSdkTestBase {
private static final String CURRENCY = "EUR";
private static final String PAYMENT_DESCRIPTION = "Java test Payment";

private static final int NUMBER_ZERO = 0;

private static final int COMPARE_EQUAL = 0;

/**
* Tests making a payment to another sandbox user
*
Expand Down Expand Up @@ -62,4 +69,14 @@ public void makePaymentToOtherAccount() throws Exception {
Payment.create(apiContext, requestMap, userId, monetaryAccountId);
}

@Test
public void getPaymentWithGeolocationTest() {
Assume.assumeFalse(Integer.compare(paymentIdwithGeolocation, NUMBER_ZERO) == COMPARE_EQUAL);

Payment payment = Payment.get(apiContext, userId, monetaryAccountId, paymentIdwithGeolocation).getValue();

Assert.assertNotNull(payment.getGeolocation());
Assert.assertFalse(payment.getGeolocation().isAllFieldNull());
}

}

0 comments on commit 25149ea

Please sign in to comment.