Skip to content

Commit

Permalink
Merge pull request #68 from bunq/#49-getCounterpartyAlias-returns-nul…
Browse files Browse the repository at this point in the history
…l-when-printed

Fixed MonetaryAccountReferenceTypeAdapter to output proper value. (#49)
  • Loading branch information
andrederoos authored Jan 8, 2018
2 parents a664630 + 852c755 commit 8417df4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ public class MonetaryAccountReferenceTypeAdapter extends TypeAdapter<MonetaryAcc

@Override
public void write(JsonWriter out, MonetaryAccountReference value) throws IOException {
if (value == null || value.getPointer() == null) {
if (value == null || value.isAllFieldNull()) {
out.nullValue();
} else if (value.getLabelMonetaryAccount() != null) {
LabelMonetaryAccount labelMonetaryAccount = value.getLabelMonetaryAccount();

BunqGsonBuilder.buildDefault().create().toJson(labelMonetaryAccount, LabelMonetaryAccount.class, out);
} else {
Pointer pointer = value.getPointer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,31 @@ public class PaymentTest extends BunqSdkTestBase {
private static final int paymentIdwithGeolocation = Config.getPaymentIdWithGeolocation();
private static final Pointer counterPartyAliasOther = Config.getCounterPartyAliasOther();
private static final Pointer counterPartyAliasSelf = Config.getCounterPartyAliasSelf();

private static final ApiContext apiContext = getApiContext();

/**
* Payment field value constants.
*/
private static final String AMOUNT_EUR = "0.01";
private static final String CURRENCY = "EUR";
private static final String PAYMENT_DESCRIPTION = "Java test Payment";
private static final int PAGE_SIZE = 200;
private static final int PAGE_SIZE = 100;

/**
* Number constants.
*/
private static final int NUMBER_ZERO = 0;

/**
* Comparison constants.
*/
private static final int COMPARE_EQUAL = 0;

/**
* String constants.
*/
private static final String STRING_NULL = "null";

/**
* Tests making a payment to another sandbox user
*
Expand Down Expand Up @@ -89,16 +102,18 @@ public void counterPartyAliasNotNullTest() {
for (Payment payment : allPayment) {
Assert.assertNotNull(payment.getCounterpartyAlias());
Assert.assertFalse(payment.getCounterpartyAlias().isAllFieldNull());
Assert.assertNotEquals(payment.getCounterpartyAlias().toString(), STRING_NULL);
}
}

@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 8417df4

Please sign in to comment.