Search in sources :

Example 1 with StripeAgreement

use of uk.gov.pay.adminusers.model.StripeAgreement in project pay-adminusers by alphagov.

the class StripeAgreementServiceTest method shouldReturnStripeAgreement.

@Test
public void shouldReturnStripeAgreement() {
    String serviceExternalId = "abc123";
    String ipAddress = "192.0.2.0";
    ZonedDateTime agreementTime = ZonedDateTime.now();
    ServiceEntity mockServiceEntity = mock(ServiceEntity.class);
    StripeAgreementEntity stripeAgreementEntity = new StripeAgreementEntity(mockServiceEntity, ipAddress, agreementTime);
    when(mockedStripeAgreementDao.findByServiceExternalId(serviceExternalId)).thenReturn(Optional.of(stripeAgreementEntity));
    Optional<StripeAgreement> maybeStripeAgreement = stripeAgreementService.findStripeAgreementByServiceId(serviceExternalId);
    assertTrue(maybeStripeAgreement.isPresent());
    assertThat(maybeStripeAgreement.get().getIpAddress().getHostAddress(), is(ipAddress));
    assertThat(maybeStripeAgreement.get().getAgreementTime(), is(agreementTime));
}
Also used : ZonedDateTime(java.time.ZonedDateTime) StripeAgreement(uk.gov.pay.adminusers.model.StripeAgreement) StripeAgreementEntity(uk.gov.pay.adminusers.persistence.entity.StripeAgreementEntity) ServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntity) Test(org.junit.jupiter.api.Test)

Aggregations

ZonedDateTime (java.time.ZonedDateTime)1 Test (org.junit.jupiter.api.Test)1 StripeAgreement (uk.gov.pay.adminusers.model.StripeAgreement)1 ServiceEntity (uk.gov.pay.adminusers.persistence.entity.ServiceEntity)1 StripeAgreementEntity (uk.gov.pay.adminusers.persistence.entity.StripeAgreementEntity)1