use of uk.gov.pay.adminusers.persistence.entity.StripeAgreementEntity in project pay-adminusers by alphagov.
the class StripeAgreementDaoIT method shouldPersistStripeAgreementEntity.
@Test
public void shouldPersistStripeAgreementEntity() {
Service service = serviceDbFixture(databaseHelper).withGatewayAccountIds(randomInt().toString()).insertService();
Optional<ServiceEntity> serviceEntity = serviceDao.findByExternalId(service.getExternalId());
assertThat(serviceEntity.isPresent(), is(true));
StripeAgreementEntity stripeAgreementEntity = new StripeAgreementEntity(serviceEntity.get(), "192.0.2.0", ZonedDateTime.now(ZoneId.of("UTC")));
stripeAgreementDao.persist(stripeAgreementEntity);
assertThat(stripeAgreementEntity.getId(), is(notNullValue()));
List<Map<String, Object>> searchResults = databaseHelper.findStripeAgreementById(stripeAgreementEntity.getId());
assertThat(searchResults.size(), is(1));
assertThat(searchResults.get(0).get("service_id"), is(stripeAgreementEntity.getService().getId()));
assertThat(searchResults.get(0).get("ip_address"), is(stripeAgreementEntity.getIpAddress()));
assertThat(searchResults.get(0).get("id"), is(stripeAgreementEntity.getId()));
assertThat(searchResults.get(0).get("agreement_time"), is(Timestamp.from(stripeAgreementEntity.getAgreementTime().toInstant())));
}
use of uk.gov.pay.adminusers.persistence.entity.StripeAgreementEntity in project pay-adminusers by alphagov.
the class StripeAgreementDaoIT method shouldFindStripeAgreementEntityByServiceId.
@Test
public void shouldFindStripeAgreementEntityByServiceId() {
Service service = serviceDbFixture(databaseHelper).insertService();
ZonedDateTime agreementTime = ZonedDateTime.now(ZoneOffset.UTC);
String ipAddress = "192.0.2.0";
stripeAgreementDbFixture(databaseHelper).withAgreementTime(agreementTime).withIpAddress(ipAddress).withServiceId(service.getId()).insert();
Optional<StripeAgreementEntity> maybeStripeAgreementEntity = stripeAgreementDao.findByServiceExternalId(service.getExternalId());
assertTrue(maybeStripeAgreementEntity.isPresent());
assertThat(maybeStripeAgreementEntity.get().getIpAddress(), is(ipAddress));
assertThat(maybeStripeAgreementEntity.get().getService().getId(), is(service.getId()));
assertThat(maybeStripeAgreementEntity.get().getAgreementTime(), is(agreementTime));
}
Aggregations