diff --git a/src/main/java/com/bunq/sdk/json/BigDecimalTypeAdapter.java b/src/main/java/com/bunq/sdk/json/BigDecimalTypeAdapter.java index 97f6626a..f14f54c7 100644 --- a/src/main/java/com/bunq/sdk/json/BigDecimalTypeAdapter.java +++ b/src/main/java/com/bunq/sdk/json/BigDecimalTypeAdapter.java @@ -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(); diff --git a/src/test/config.example.properties b/src/test/config.example.properties index ea6ae92c..123bfdad 100644 --- a/src/test/config.example.properties +++ b/src/test/config.example.properties @@ -19,3 +19,4 @@ CASH_REGISTER_ID=xxx #Same user, alias from other account SAME_USER_OTHER_ACCOUNT_ALIAS= SAME_USER_OTHER_ACCOUNT_TYPE=EMAIL +PAYMENT_ID_WITH_GEOLOCATION=0 diff --git a/src/test/java/com/bunq/sdk/Config.java b/src/test/java/com/bunq/sdk/Config.java index 2dba63a7..9d4266ef 100644 --- a/src/test/java/com/bunq/sdk/Config.java +++ b/src/test/java/com/bunq/sdk/Config.java @@ -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(); @@ -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)); + } + } diff --git a/src/test/java/com/bunq/sdk/model/generated/endpoint/PaymentTest.java b/src/test/java/com/bunq/sdk/model/generated/endpoint/PaymentTest.java index 4cd2ec34..d0b6a7d5 100644 --- a/src/test/java/com/bunq/sdk/model/generated/endpoint/PaymentTest.java +++ b/src/test/java/com/bunq/sdk/model/generated/endpoint/PaymentTest.java @@ -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: @@ -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(); @@ -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 * @@ -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()); + } + }