Search in sources :

Example 6 with IOParser

use of net.petafuel.styx.core.ioprocessing.IOParser in project styx by petafuel.

the class STYX02UnitTest method testApplyNotRequired.

@Test
void testApplyNotRequired() throws ImplementerOptionException {
    styx02Option.setOptions(Collections.singletonMap("required", false));
    aspsp.getConfig().setImplementerOptions(new HashMap<>());
    aspsp.getConfig().getImplementerOptions().put("STYX02", styx02Option);
    ImplementerOption io6 = new ImplementerOption();
    io6.setId("IO6");
    io6.setOptions(Collections.singletonMap("required", false));
    aspsp.getConfig().getImplementerOptions().put("IO6", io6);
    IOParser ioParser = new IOParser(aspsp);
    STYX02 styx02 = new STYX02(ioParser);
    Assertions.assertEquals(IOOrder.POST_CREATION, styx02.order());
    Assertions.assertFalse(styx02.apply(null, null, null));
}
Also used : IOParser(net.petafuel.styx.core.ioprocessing.IOParser) ImplementerOption(net.petafuel.styx.core.banklookup.sad.entities.ImplementerOption) Test(org.junit.jupiter.api.Test)

Example 7 with IOParser

use of net.petafuel.styx.core.ioprocessing.IOParser in project styx by petafuel.

the class STYX08UnitTest method test_STYX08.

@Test
void test_STYX08() throws ImplementerOptionException {
    Assume.assumeNotNull(uniCredit);
    Assume.assumeNotNull(styx08Option);
    styx08Option.setOptions(Collections.singletonMap("required", true));
    uniCredit.getConfig().setImplementerOptions(Collections.singletonMap("STYX08", styx08Option));
    IOParser ioParser = new IOParser(uniCredit);
    STYX08 styx08 = new STYX08(ioParser);
    Assertions.assertEquals(IOOrder.POST_CREATION, styx08.order());
    Assertions.assertFalse(styx08.apply(null, null, null));
    XS2ARequest xs2ARequest = new XS2ARequest() {

        @Override
        public Optional<String> getRawBody() {
            return Optional.empty();
        }

        @Override
        public BasicService.RequestType getHttpMethod() {
            return BasicService.RequestType.GET;
        }

        @Override
        public String getServicePath() {
            return "";
        }
    };
    PSU psu = new PSU("bgdemo");
    psu.setIp("1.2.3.4");
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setPsu(psu);
    Assertions.assertTrue(styx08.apply(xs2AFactoryInput, xs2ARequest, null));
    Assertions.assertNotNull(xs2ARequest.getHeaders().get(XS2AHeader.PSU_IP_ADDRESS));
    Assertions.assertEquals("1.2.3.4", xs2ARequest.getHeaders().get(XS2AHeader.PSU_IP_ADDRESS));
}
Also used : BasicService(net.petafuel.styx.core.xs2a.contracts.BasicService) PSU(net.petafuel.styx.core.xs2a.entities.PSU) IOParser(net.petafuel.styx.core.ioprocessing.IOParser) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) XS2ARequest(net.petafuel.styx.core.xs2a.contracts.XS2ARequest) Test(org.junit.jupiter.api.Test)

Example 8 with IOParser

use of net.petafuel.styx.core.ioprocessing.IOParser in project styx by petafuel.

the class IO2UnitTest method testApplyUnsupportedPaymentProduct.

@Test
void testApplyUnsupportedPaymentProduct() throws ImplementerOptionException {
    io2Option.setOptions(new HashMap<String, Boolean>());
    io2Option.getOptions().put(PaymentProduct.PAIN_001_SEPA_CREDIT_TRANSFERS.getValue(), false);
    io2Option.getOptions().put(PaymentProduct.SEPA_CREDIT_TRANSFERS.getValue(), false);
    aspsp.getConfig().setImplementerOptions(Collections.singletonMap("IO2", io2Option));
    IOParser ioParser = new IOParser(aspsp);
    IO2 io2 = new IO2(ioParser);
    Assertions.assertEquals(IOOrder.PRE_CREATION, io2.order());
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setPaymentService(PaymentService.PERIODIC_PAYMENTS);
    Assertions.assertFalse(io2.apply(xs2AFactoryInput, null, null));
    xs2AFactoryInput.setPaymentService(PaymentService.PAYMENTS);
    xs2AFactoryInput.setPaymentProduct(PaymentProduct.SEPA_CREDIT_TRANSFERS);
    Assertions.assertThrows(StyxException.class, () -> io2.apply(xs2AFactoryInput, null, null));
}
Also used : IOParser(net.petafuel.styx.core.ioprocessing.IOParser) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) Test(org.junit.jupiter.api.Test)

Example 9 with IOParser

use of net.petafuel.styx.core.ioprocessing.IOParser in project styx by petafuel.

the class IO2UnitTest method testApplyXMLWithValidData.

@Test
void testApplyXMLWithValidData() throws ImplementerOptionException {
    io2Option.setOptions(new HashMap<String, Boolean>());
    io2Option.getOptions().put(PaymentProduct.PAIN_001_SEPA_CREDIT_TRANSFERS.getValue(), true);
    io2Option.getOptions().put(PaymentProduct.SEPA_CREDIT_TRANSFERS.getValue(), false);
    aspsp.getConfig().setImplementerOptions(Collections.singletonMap("IO2", io2Option));
    IOParser ioParser = new IOParser(aspsp);
    IO2 io2 = new IO2(ioParser);
    Assertions.assertEquals(IOOrder.PRE_CREATION, io2.order());
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setPaymentService(PaymentService.PERIODIC_PAYMENTS);
    Assertions.assertFalse(io2.apply(xs2AFactoryInput, null, null));
    xs2AFactoryInput.setPaymentService(PaymentService.PAYMENTS);
    xs2AFactoryInput.setPaymentProduct(PaymentProduct.SEPA_CREDIT_TRANSFERS);
    Assertions.assertTrue(io2.apply(xs2AFactoryInput, null, null));
    Assertions.assertEquals(PaymentProduct.PAIN_001_SEPA_CREDIT_TRANSFERS, xs2AFactoryInput.getPaymentProduct());
}
Also used : IOParser(net.petafuel.styx.core.ioprocessing.IOParser) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) Test(org.junit.jupiter.api.Test)

Example 10 with IOParser

use of net.petafuel.styx.core.ioprocessing.IOParser in project styx by petafuel.

the class STYX04UnitTest method test_STYX04_config_is_true.

@Test
void test_STYX04_config_is_true() throws ImplementerOptionException {
    Assume.assumeNotNull(sparda);
    Assume.assumeNotNull(styx04Option);
    styx04Option.setOptions(Collections.singletonMap("required", true));
    sparda.getConfig().setImplementerOptions(Collections.singletonMap("STYX04", styx04Option));
    IOParser ioParser = new IOParser(sparda);
    STYX04 styx04 = new STYX04(ioParser);
    Assertions.assertEquals(IOOrder.POST_CREATION, styx04.order());
    XS2ARequest anonymouseRequest = new XS2ARequest() {

        @Override
        public Optional<String> getRawBody() {
            return Optional.empty();
        }

        @Override
        public BasicService.RequestType getHttpMethod() {
            return BasicService.RequestType.GET;
        }

        @Override
        public String getServicePath() {
            return "";
        }
    };
    styx04.apply(null, anonymouseRequest, null);
    Assertions.assertNotNull(anonymouseRequest.getHeaders().get("X-BIC"));
    Assertions.assertEquals(TEST_BIC, anonymouseRequest.getHeaders().get("X-BIC"));
}
Also used : BasicService(net.petafuel.styx.core.xs2a.contracts.BasicService) IOParser(net.petafuel.styx.core.ioprocessing.IOParser) XS2ARequest(net.petafuel.styx.core.xs2a.contracts.XS2ARequest) Test(org.junit.jupiter.api.Test)

Aggregations

IOParser (net.petafuel.styx.core.ioprocessing.IOParser)13 Test (org.junit.jupiter.api.Test)11 BasicService (net.petafuel.styx.core.xs2a.contracts.BasicService)8 XS2ARequest (net.petafuel.styx.core.xs2a.contracts.XS2ARequest)8 XS2AFactoryInput (net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput)8 PSU (net.petafuel.styx.core.xs2a.entities.PSU)5 ImplementerOption (net.petafuel.styx.core.banklookup.sad.entities.ImplementerOption)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1 IntegrationTest (net.petafuel.styx.api.IntegrationTest)1 StyxRESTTest (net.petafuel.styx.api.StyxRESTTest)1 ResponseEntity (net.petafuel.styx.api.exception.ResponseEntity)1 StyxException (net.petafuel.styx.api.exception.StyxException)1 XS2AStandard (net.petafuel.styx.core.banklookup.XS2AStandard)1 PersistenceEmptyResultSetException (net.petafuel.styx.core.persistence.PersistenceEmptyResultSetException)1 PersistentOAuthSession (net.petafuel.styx.core.persistence.layers.PersistentOAuthSession)1 OAuthTokenExpiredException (net.petafuel.styx.core.xs2a.exceptions.OAuthTokenExpiredException)1 OAuthSession (net.petafuel.styx.core.xs2a.oauth.entities.OAuthSession)1 Test (org.junit.Test)1