Search in sources :

Example 1 with PersistentConsent

use of net.petafuel.styx.core.persistence.layers.PersistentConsent in project styx by petafuel.

the class BerlinGroupCS method deleteConsent.

@Override
public Consent deleteConsent(AISRequest consentDeleteRequest) throws BankRequestFailedException {
    this.setUrl(this.url + consentDeleteRequest.getServicePath());
    this.createBody(RequestType.DELETE);
    this.createHeaders(consentDeleteRequest);
    try (Response response = this.execute()) {
        extractResponseBody(response, 204, false);
        Consent consent = new Consent();
        consent.setId(consentDeleteRequest.getConsentId());
        return new PersistentConsent().updateState(consent, ConsentStatus.TERMINATED_BY_TPP);
    } catch (IOException e) {
        throw new BankRequestFailedException(e.getMessage(), e);
    }
}
Also used : Response(okhttp3.Response) Consent(net.petafuel.styx.core.xs2a.entities.Consent) PersistentConsent(net.petafuel.styx.core.persistence.layers.PersistentConsent) IOException(java.io.IOException) PersistentConsent(net.petafuel.styx.core.persistence.layers.PersistentConsent) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException)

Example 2 with PersistentConsent

use of net.petafuel.styx.core.persistence.layers.PersistentConsent in project styx by petafuel.

the class BerlinGroupCS method getStatus.

@Override
public ConsentStatus getStatus(AISRequest consentStatusRequest) throws BankRequestFailedException {
    this.setUrl(this.url + consentStatusRequest.getServicePath());
    this.createBody(RequestType.GET);
    this.createHeaders(consentStatusRequest);
    try (Response response = this.execute();
        Jsonb jsonb = JsonbBuilder.create()) {
        String responseBody = extractResponseBody(response, 200);
        PersistentConsent persistentConsent = new PersistentConsent();
        Consent consent = jsonb.fromJson(responseBody, Consent.class);
        consent.setId(consentStatusRequest.getConsentId());
        persistentConsent.updateState(consent, consent.getState());
        return consent.getState();
    } catch (Exception e) {
        throw new BankRequestFailedException(e.getMessage(), e);
    }
}
Also used : Response(okhttp3.Response) Jsonb(javax.json.bind.Jsonb) Consent(net.petafuel.styx.core.xs2a.entities.Consent) PersistentConsent(net.petafuel.styx.core.persistence.layers.PersistentConsent) PersistentConsent(net.petafuel.styx.core.persistence.layers.PersistentConsent) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException) IOException(java.io.IOException) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException)

Example 3 with PersistentConsent

use of net.petafuel.styx.core.persistence.layers.PersistentConsent in project styx by petafuel.

the class PersistentConsentIntegrationTest method updateConsent.

@Test
@Order(4)
void updateConsent() {
    consent.setCombinedServiceIndicator(true);
    consent.setFrequencyPerDay(1);
    consent.getSca().setApproach(SCA.Approach.DECOUPLED);
    consent.setState(ConsentStatus.VALID);
    Consent updatedConsent = new PersistentConsent().update(consent);
    Assert.assertNotNull(updatedConsent.getId());
    Assert.assertEquals(consent.getId(), updatedConsent.getId());
    Assert.assertEquals(ConsentStatus.VALID, updatedConsent.getState());
    Assert.assertEquals(SCA.Approach.DECOUPLED, updatedConsent.getSca().getApproach());
    Assert.assertFalse(updatedConsent.isRecurringIndicator());
    Assert.assertEquals(1, updatedConsent.getFrequencyPerDay());
    Assert.assertTrue(updatedConsent.isCombinedServiceIndicator());
    Assert.assertEquals("PSU-ID-33241", updatedConsent.getPsu().getId());
    Assert.assertEquals("PSU-ID-TYPE-33241", updatedConsent.getPsu().getIdType());
    Assert.assertEquals("127.0.0.1", updatedConsent.getPsu().getIp());
    Assert.assertEquals(java.util.Optional.of(9999).get(), updatedConsent.getPsu().getPort());
    Assert.assertEquals("PSU-CO-ID-TYPE-33242", updatedConsent.getPsu().getCorporateIdType());
    Assert.assertEquals("PSU-CO-ID-33242", updatedConsent.getPsu().getCorporateId());
    Assert.assertEquals("48.3938:11.7331", updatedConsent.getPsu().getGeoLocation());
    Assert.assertEquals("VIMpay 1.2.3", updatedConsent.getPsu().getUserAgent());
}
Also used : PersistentConsent(net.petafuel.styx.core.persistence.layers.PersistentConsent) Consent(net.petafuel.styx.core.xs2a.entities.Consent) PersistentConsent(net.petafuel.styx.core.persistence.layers.PersistentConsent) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 4 with PersistentConsent

use of net.petafuel.styx.core.persistence.layers.PersistentConsent in project styx by petafuel.

the class PersistentConsentIntegrationTest method saveConsents.

@Test
@Order(2)
void saveConsents() {
    Consent fromDatabase = new PersistentConsent().create(consent);
    Assert.assertNotNull(fromDatabase.getId());
    Assert.assertEquals(consent.getId(), fromDatabase.getId());
    Assert.assertEquals(ConsentStatus.RECEIVED, fromDatabase.getState());
    Assert.assertEquals(SCA.Approach.REDIRECT, fromDatabase.getSca().getApproach());
    Assert.assertFalse(fromDatabase.isRecurringIndicator());
    Assert.assertEquals(4, fromDatabase.getFrequencyPerDay());
    Assert.assertFalse(fromDatabase.isCombinedServiceIndicator());
    Assert.assertEquals("PSU-ID-33241", fromDatabase.getPsu().getId());
    Assert.assertEquals("PSU-ID-TYPE-33241", fromDatabase.getPsu().getIdType());
    Assert.assertEquals("127.0.0.1", fromDatabase.getPsu().getIp());
    Assert.assertEquals(java.util.Optional.of(9999).get(), fromDatabase.getPsu().getPort());
    Assert.assertEquals("PSU-CO-ID-TYPE-33242", fromDatabase.getPsu().getCorporateIdType());
    Assert.assertEquals("PSU-CO-ID-33242", fromDatabase.getPsu().getCorporateId());
    Assert.assertEquals("48.3938:11.7331", fromDatabase.getPsu().getGeoLocation());
    Assert.assertEquals("VIMpay 1.2.3", fromDatabase.getPsu().getUserAgent());
}
Also used : PersistentConsent(net.petafuel.styx.core.persistence.layers.PersistentConsent) Consent(net.petafuel.styx.core.xs2a.entities.Consent) PersistentConsent(net.petafuel.styx.core.persistence.layers.PersistentConsent) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 5 with PersistentConsent

use of net.petafuel.styx.core.persistence.layers.PersistentConsent in project styx by petafuel.

the class PersistentConsentIntegrationTest method deleteConsent.

@Test
@Order(6)
void deleteConsent() {
    Consent fromDatabase = new PersistentConsent().delete(consent);
    Assert.assertEquals(consent.getId(), fromDatabase.getId());
}
Also used : PersistentConsent(net.petafuel.styx.core.persistence.layers.PersistentConsent) Consent(net.petafuel.styx.core.xs2a.entities.Consent) PersistentConsent(net.petafuel.styx.core.persistence.layers.PersistentConsent) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Aggregations

PersistentConsent (net.petafuel.styx.core.persistence.layers.PersistentConsent)10 Consent (net.petafuel.styx.core.xs2a.entities.Consent)10 Order (org.junit.jupiter.api.Order)5 Test (org.junit.jupiter.api.Test)5 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)5 IOException (java.io.IOException)4 BankRequestFailedException (net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException)4 Response (okhttp3.Response)4 Jsonb (javax.json.bind.Jsonb)3 JsonbConfig (javax.json.bind.JsonbConfig)1 CSInterface (net.petafuel.styx.core.xs2a.contracts.CSInterface)1 IXS2AHttpSigner (net.petafuel.styx.core.xs2a.contracts.IXS2AHttpSigner)1