Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/quarkus-mvc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies {
implementation 'io.quarkus:quarkus-resteasy-qute'

// TL Java BE library
implementation 'com.truelayer:truelayer-java:0.7.0'
implementation 'com.truelayer:truelayer-java:0.7.5'

testImplementation 'io.quarkus:quarkus-junit5'
testImplementation 'io.rest-assured:rest-assured'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

import com.truelayer.java.ITrueLayerClient;
import com.truelayer.java.entities.CurrencyCode;
import com.truelayer.java.entities.accountidentifier.IbanAccountIdentifier;
import com.truelayer.java.entities.accountidentifier.SortCodeAccountNumberAccountIdentifier;
import com.truelayer.java.entities.beneficiary.ExternalAccount;
import com.truelayer.java.payments.entities.User;
import com.truelayer.java.payments.entities.paymentmethod.BankTransfer;
import com.truelayer.java.payments.entities.paymentmethod.provider.UserSelectedProviderSelection;
import com.truelayer.quarkusmvc.models.DonationResult;
import com.truelayer.quarkusmvc.models.DonationRequest;
import com.truelayer.quarkusmvc.models.DonationResult;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Main properties
group=com.truelayer
archivesBaseName=truelayer-java
version=0.7.4
version=0.7.5

# Artifacts properties
sonatype_repository_url=https://s01.oss.sonatype.org/service/local/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,52 +58,52 @@ public static NrbAccountIdentifier.NrbAccountIdentifierBuilder nrb() {
}

@JsonIgnore
public boolean isSortCodeAccountNumber() {
public boolean isSortCodeAccountNumberIdentifier() {
return this instanceof SortCodeAccountNumberAccountIdentifier;
}

@JsonIgnore
public boolean isIban() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this and below ones: a @JsonIgnore on a isX masks the value of X in the specific type 😱

public boolean isIbanIdentifier() {
return this instanceof IbanAccountIdentifier;
}

@JsonIgnore
public boolean isBban() {
public boolean isBbanIdentifier() {
return this instanceof BbanAccountIdentifier;
}

@JsonIgnore
public boolean isNrb() {
public boolean isNrbIdentifier() {
return this instanceof NrbAccountIdentifier;
}

@JsonIgnore
public SortCodeAccountNumberAccountIdentifier asSortCodeAccountNumber() {
if (!isSortCodeAccountNumber()) {
if (!isSortCodeAccountNumberIdentifier()) {
throw new TrueLayerException(buildErrorMessage());
}
return (SortCodeAccountNumberAccountIdentifier) this;
}

@JsonIgnore
public IbanAccountIdentifier asIban() {
if (!isIban()) {
if (!isIbanIdentifier()) {
throw new TrueLayerException(buildErrorMessage());
}
return (IbanAccountIdentifier) this;
}

@JsonIgnore
public BbanAccountIdentifier asBban() {
if (!isBban()) {
if (!isBbanIdentifier()) {
throw new TrueLayerException(buildErrorMessage());
}
return (BbanAccountIdentifier) this;
}

@JsonIgnore
public NrbAccountIdentifier asNrb() {
if (!isNrb()) {
if (!isNrbIdentifier()) {
throw new TrueLayerException(buildErrorMessage());
}
return (NrbAccountIdentifier) this;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.truelayer.java.entities.accountidentifier;

import static com.truelayer.java.Utils.getObjectMapper;
import static org.junit.jupiter.api.Assertions.*;

import com.truelayer.java.TrueLayerException;
import lombok.SneakyThrows;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

Expand All @@ -13,15 +15,19 @@ class AccountIdentifierTests {
public void shouldYieldTrueIfSortCodeAccNumber() {
AccountIdentifier sut = new SortCodeAccountNumberAccountIdentifier("123456", "12345678");

assertTrue(sut.isSortCodeAccountNumber());
assertTrue(sut.isSortCodeAccountNumberIdentifier());
}

@SneakyThrows
@Test
@DisplayName("It should convert to an instance of class SortCodeAccountNumberAccountIdentifier")
public void shouldConvertToSortCodeAccNumber() {
AccountIdentifier sut = new SortCodeAccountNumberAccountIdentifier("123456", "12345678");

assertDoesNotThrow(sut::asSortCodeAccountNumber);
assertEquals(
"{\"sort_code\":\"123456\",\"account_number\":\"12345678\",\"type\":\"sort_code_account_number\"}",
getObjectMapper().writeValueAsString(sut));
}

@Test
Expand All @@ -39,15 +45,18 @@ public void shouldNotConvertToSortCodeAccNumber() {
public void shouldYieldTrueIfIban() {
AccountIdentifier sut = new IbanAccountIdentifier("12345678");

assertTrue(sut.isIban());
assertTrue(sut.isIbanIdentifier());
}

@SneakyThrows
@Test
@DisplayName("It should convert to an instance of class IbanAccountIdentifier")
public void shouldConvertToIban() {
AccountIdentifier sut = new IbanAccountIdentifier("12345678");

assertDoesNotThrow(sut::asIban);
assertEquals(
"{\"iban\":\"12345678\",\"type\":\"iban\"}", getObjectMapper().writeValueAsString(sut));
}

@Test
Expand All @@ -65,15 +74,18 @@ public void shouldNotConvertToIbanAccountIdentifier() {
public void shouldYieldTrueIfBban() {
AccountIdentifier sut = new BbanAccountIdentifier("12345678");

assertTrue(sut.isBban());
assertTrue(sut.isBbanIdentifier());
}

@SneakyThrows
@Test
@DisplayName("It should convert to an instance of class BbanAccountIdentifier")
public void shouldConvertToBban() {
AccountIdentifier sut = new BbanAccountIdentifier("12345678");

assertDoesNotThrow(sut::asBban);
assertEquals(
"{\"bban\":\"12345678\",\"type\":\"bban\"}", getObjectMapper().writeValueAsString(sut));
}

@Test
Expand All @@ -91,15 +103,18 @@ public void shouldNotConvertToBbanAccountIdentifier() {
public void shouldYieldTrueIfNrb() {
AccountIdentifier sut = new NrbAccountIdentifier("12345678");

assertTrue(sut.isNrb());
assertTrue(sut.isNrbIdentifier());
}

@SneakyThrows
@Test
@DisplayName("It should convert to an instance of class NrbAccountIdentifier")
public void shouldConvertToNrb() {
AccountIdentifier sut = new NrbAccountIdentifier("12345678");

assertDoesNotThrow(sut::asNrb);
assertEquals(
"{\"nrb\":\"12345678\",\"type\":\"nrb\"}", getObjectMapper().writeValueAsString(sut));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.truelayer.java.entities.CurrencyCode;
import java.util.Date;
import java.util.UUID;
import lombok.SneakyThrows;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

Expand All @@ -26,6 +27,7 @@ public void shouldYieldTrueIfMerchantAccountPayment() {
assertTrue(sut.isMerchantAccountPayment());
}

@SneakyThrows
@Test
@DisplayName("It should convert to an instance of class MerchantAccountPayment")
public void shouldConvertToMerchantAccountPayment() {
Expand Down