Search in sources :

Example 1 with SAD

use of net.petafuel.styx.core.banklookup.sad.SAD in project styx by petafuel.

the class SADTest method testXS2AStandardInitialisationProduction.

@ParameterizedTest
@MethodSource("BICProvider")
@DisplayName("testXS2AStandardInitialisationProduction() -> Check if PRODUCTION XS2AStandards can be created for all available BICs in SAD")
public void testXS2AStandardInitialisationProduction(String bic) throws BankNotFoundException, BankLookupFailedException {
    SAD sad = new SAD();
    Aspsp bank = PersistentSAD.getByBIC(bic);
    XS2AStandard xs2AStandard = sad.getBankByBIC(bic);
    try {
        Assertions.assertAll(() -> {
            if (bank.getProductionUrl().getCommonUrl() == null) {
                if (bank.getProductionUrl().getAisUrl() != null) {
                    Assert.assertTrue("AIS Url was specified but no Consent Service was initialized", xs2AStandard.isCSImplemented());
                    Assert.assertTrue("AIS Url was specified but no related Service was initialized", xs2AStandard.isAISImplemented());
                }
                if (bank.getProductionUrl().getPisUrl() != null) {
                    Assert.assertTrue("PIS Url was specified but no related Service was initialized", xs2AStandard.isPISImplemented());
                }
                if (bank.getProductionUrl().getPiisUrl() != null) {
                    Assert.assertTrue("PIIS Url was specified but no related Service was initialized", xs2AStandard.isPIISImplemented());
                }
            } else {
                boolean atLeastOneServiceImplemented = false;
                if ((xs2AStandard.isAISImplemented() && xs2AStandard.isCSImplemented()) || xs2AStandard.isPIISImplemented() || xs2AStandard.isPISImplemented()) {
                    atLeastOneServiceImplemented = true;
                }
                Assert.assertTrue("General Url was specified but no related Service was initialized", atLeastOneServiceImplemented);
            }
        });
    } catch (MultipleFailuresError e) {
        if (!bank.isActive()) {
            System.err.println("Test failed for bic=" + bic + " but bank is deactivated in styx: ");
            e.getFailures().forEach(throwable -> System.err.println(throwable.getMessage()));
            Assert.assertTrue(true);
        } else {
            System.err.println("Test failed for bic=" + bic + ": " + e.getMessage());
            e.getFailures().forEach(throwable -> System.err.println(throwable.getMessage()));
            Assert.fail();
        }
    }
}
Also used : Persistence(net.petafuel.styx.core.persistence.Persistence) Connection(java.sql.Connection) MultipleFailuresError(org.opentest4j.MultipleFailuresError) BankNotFoundException(net.petafuel.styx.core.banklookup.exceptions.BankNotFoundException) Aspsp(net.petafuel.styx.core.banklookup.sad.entities.Aspsp) Arguments(org.junit.jupiter.params.provider.Arguments) PreparedStatement(java.sql.PreparedStatement) DisplayName(org.junit.jupiter.api.DisplayName) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) SQLException(java.sql.SQLException) Stream(java.util.stream.Stream) ResultSet(java.sql.ResultSet) Assertions(org.junit.jupiter.api.Assertions) Tag(org.junit.jupiter.api.Tag) Assert(org.junit.Assert) Arguments.arguments(org.junit.jupiter.params.provider.Arguments.arguments) SAD(net.petafuel.styx.core.banklookup.sad.SAD) PersistentSAD(net.petafuel.styx.core.persistence.layers.PersistentSAD) BankLookupFailedException(net.petafuel.styx.core.banklookup.exceptions.BankLookupFailedException) MethodSource(org.junit.jupiter.params.provider.MethodSource) Aspsp(net.petafuel.styx.core.banklookup.sad.entities.Aspsp) SAD(net.petafuel.styx.core.banklookup.sad.SAD) PersistentSAD(net.petafuel.styx.core.persistence.layers.PersistentSAD) MultipleFailuresError(org.opentest4j.MultipleFailuresError) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with SAD

use of net.petafuel.styx.core.banklookup.sad.SAD in project styx by petafuel.

the class ConsorsAISTest method testTransactions.

@Test
@Order(4)
public void testTransactions() throws BankLookupFailedException, BankNotFoundException, ParseException, BankRequestFailedException {
    XS2AStandard standard = (new SAD()).getBankByBIC(BIC, true);
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    Date from = format.parse("2019-03-03");
    Date to = new Date();
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setAccountId(ACCOUNT_ID);
    xs2AFactoryInput.setConsentId(CONSENT);
    xs2AFactoryInput.setBookingStatus("booked");
    xs2AFactoryInput.setDateFrom(from);
    xs2AFactoryInput.setDateTo(to);
    AISRequest aisRequest = new AISRequestFactory().create(standard.getRequestClassProvider().accountTransactionList(), xs2AFactoryInput);
    TransactionContainer result = standard.getAis().getTransactionsByAccount(aisRequest);
    Assertions.assertNotNull(result);
    Assertions.assertNotNull(result.getTransactions());
}
Also used : XS2AStandard(net.petafuel.styx.core.banklookup.XS2AStandard) AISRequest(net.petafuel.styx.core.xs2a.contracts.AISRequest) SAD(net.petafuel.styx.core.banklookup.sad.SAD) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) TransactionContainer(net.petafuel.styx.core.xs2a.entities.TransactionContainer) AISRequestFactory(net.petafuel.styx.core.xs2a.factory.AISRequestFactory) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 3 with SAD

use of net.petafuel.styx.core.banklookup.sad.SAD in project styx by petafuel.

the class ConsorsAISTest method testBalances.

@Test
@Order(3)
public void testBalances() throws BankRequestFailedException, BankLookupFailedException, BankNotFoundException {
    XS2AStandard standard = (new SAD()).getBankByBIC(BIC, true);
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setAccountId(ACCOUNT_ID);
    xs2AFactoryInput.setConsentId(CONSENT);
    AISRequest aisRequest = new AISRequestFactory().create(standard.getRequestClassProvider().accountBalances(), xs2AFactoryInput);
    BalanceContainer result = standard.getAis().getBalancesByAccount(aisRequest);
    Assertions.assertNotNull(result);
    Assertions.assertTrue(result.getBalances().size() >= 1);
}
Also used : XS2AStandard(net.petafuel.styx.core.banklookup.XS2AStandard) AISRequest(net.petafuel.styx.core.xs2a.contracts.AISRequest) SAD(net.petafuel.styx.core.banklookup.sad.SAD) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) AISRequestFactory(net.petafuel.styx.core.xs2a.factory.AISRequestFactory) BalanceContainer(net.petafuel.styx.core.xs2a.entities.BalanceContainer) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 4 with SAD

use of net.petafuel.styx.core.banklookup.sad.SAD in project styx by petafuel.

the class ConsorsAISTest method testAccountList.

@Test
@Order(1)
public void testAccountList() throws BankRequestFailedException, BankLookupFailedException, BankNotFoundException {
    XS2AStandard standard = (new SAD()).getBankByBIC(BIC, true);
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setConsentId(CONSENT);
    AISRequest aisRequest = new AISRequestFactory().create(standard.getRequestClassProvider().accountList(), xs2AFactoryInput);
    aisRequest.setWithBalance(true);
    List<AccountDetails> list = standard.getAis().getAccountList(aisRequest);
    Assertions.assertTrue(list.size() >= 1);
}
Also used : XS2AStandard(net.petafuel.styx.core.banklookup.XS2AStandard) AISRequest(net.petafuel.styx.core.xs2a.contracts.AISRequest) SAD(net.petafuel.styx.core.banklookup.sad.SAD) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) AISRequestFactory(net.petafuel.styx.core.xs2a.factory.AISRequestFactory) AccountDetails(net.petafuel.styx.core.xs2a.entities.AccountDetails) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 5 with SAD

use of net.petafuel.styx.core.banklookup.sad.SAD in project styx by petafuel.

the class ConsorsAISTest method testTransactionDetails.

@Test
@Order(5)
public void testTransactionDetails() throws BankRequestFailedException, BankLookupFailedException, BankNotFoundException {
    XS2AStandard standard = (new SAD()).getBankByBIC(BIC, true);
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setAccountId(ACCOUNT_ID);
    xs2AFactoryInput.setTransactionId(TRANSACTION_ID);
    xs2AFactoryInput.setConsentId(CONSENT);
    AISRequest aisRequest = new AISRequestFactory().create(standard.getRequestClassProvider().accountTransactionDetails(), xs2AFactoryInput);
    Transaction result = standard.getAis().getTransaction(aisRequest);
    Assertions.assertNotNull(result);
    Assertions.assertNotNull(result.getDebtorAccount());
}
Also used : XS2AStandard(net.petafuel.styx.core.banklookup.XS2AStandard) Transaction(net.petafuel.styx.core.xs2a.entities.Transaction) AISRequest(net.petafuel.styx.core.xs2a.contracts.AISRequest) SAD(net.petafuel.styx.core.banklookup.sad.SAD) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) AISRequestFactory(net.petafuel.styx.core.xs2a.factory.AISRequestFactory) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Aggregations

SAD (net.petafuel.styx.core.banklookup.sad.SAD)10 Test (org.junit.jupiter.api.Test)8 XS2AStandard (net.petafuel.styx.core.banklookup.XS2AStandard)7 XS2AFactoryInput (net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput)6 AISRequest (net.petafuel.styx.core.xs2a.contracts.AISRequest)5 AISRequestFactory (net.petafuel.styx.core.xs2a.factory.AISRequestFactory)5 Order (org.junit.jupiter.api.Order)5 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)5 BankLookupFailedException (net.petafuel.styx.core.banklookup.exceptions.BankLookupFailedException)4 BankNotFoundException (net.petafuel.styx.core.banklookup.exceptions.BankNotFoundException)4 PersistentSAD (net.petafuel.styx.core.persistence.layers.PersistentSAD)3 DisplayName (org.junit.jupiter.api.DisplayName)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Stream (java.util.stream.Stream)2 Aspsp (net.petafuel.styx.core.banklookup.sad.entities.Aspsp)2 Persistence (net.petafuel.styx.core.persistence.Persistence)2