use of net.petafuel.styx.core.xs2a.entities.Consent 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);
}
}
use of net.petafuel.styx.core.xs2a.entities.Consent 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);
}
}
use of net.petafuel.styx.core.xs2a.entities.Consent 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());
}
use of net.petafuel.styx.core.xs2a.entities.Consent 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());
}
use of net.petafuel.styx.core.xs2a.entities.Consent 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());
}
Aggregations