use of uk.gov.pay.adminusers.model.ServiceUpdateRequest in project pay-adminusers by alphagov.
the class ServiceUpdaterTest method shouldSuccess_updateCustomBranding_whenBrandingNotProvided.
@Test
public void shouldSuccess_updateCustomBranding_whenBrandingNotProvided() {
ServiceUpdateRequest request = mock(ServiceUpdateRequest.class);
ServiceEntity serviceEntity = mock(ServiceEntity.class);
when(request.getPath()).thenReturn("custom_branding");
when(request.valueAsObject()).thenReturn(null);
when(serviceDao.findByExternalId(SERVICE_ID)).thenReturn(of(serviceEntity));
when(serviceEntity.toService()).thenReturn(Service.from());
Optional<Service> maybeService = updater.doUpdate(SERVICE_ID, request);
assertThat(maybeService.isPresent(), is(true));
verify(serviceEntity).setCustomBranding(null);
verify(serviceDao).merge(serviceEntity);
}
use of uk.gov.pay.adminusers.model.ServiceUpdateRequest in project pay-adminusers by alphagov.
the class ServiceUpdaterTest method shouldUpdateWentLiveDateSuccessfully.
@Test
public void shouldUpdateWentLiveDateSuccessfully() {
ServiceUpdateRequest request = serviceUpdateRequest("replace", "went_live_date", "2020-02-28T01:02:03Z");
ServiceEntity serviceEntity = mock(ServiceEntity.class);
when(serviceDao.findByExternalId(SERVICE_ID)).thenReturn(of(serviceEntity));
when(serviceEntity.toService()).thenReturn(Service.from());
Optional<Service> maybeService = updater.doUpdate(SERVICE_ID, request);
assertThat(maybeService.isPresent(), is(true));
InOrder inOrder = inOrder(serviceEntity, serviceDao);
inOrder.verify(serviceEntity).setWentLiveDate(ZonedDateTime.of(2020, 2, 28, 1, 2, 3, 0, UTC));
inOrder.verify(serviceDao).merge(serviceEntity);
}
use of uk.gov.pay.adminusers.model.ServiceUpdateRequest in project pay-adminusers by alphagov.
the class ServiceUpdaterTest method shouldUpdateSectorSuccessfully.
@Test
public void shouldUpdateSectorSuccessfully() {
ServiceUpdateRequest request = serviceUpdateRequest("replace", "sector", "local government");
ServiceEntity serviceEntity = mock(ServiceEntity.class);
when(serviceDao.findByExternalId(SERVICE_ID)).thenReturn(of(serviceEntity));
when(serviceEntity.toService()).thenReturn(Service.from());
Optional<Service> maybeService = updater.doUpdate(SERVICE_ID, request);
assertThat(maybeService.isPresent(), is(true));
InOrder inOrder = inOrder(serviceEntity, serviceDao);
inOrder.verify(serviceEntity).setSector("local government");
inOrder.verify(serviceDao).merge(serviceEntity);
}
use of uk.gov.pay.adminusers.model.ServiceUpdateRequest in project pay-adminusers by alphagov.
the class ServiceUpdaterTest method shouldUpdateArchivedSuccessfully.
@Test
public void shouldUpdateArchivedSuccessfully() {
ServiceUpdateRequest request = serviceUpdateRequest("replace", "archived", true);
ServiceEntity serviceEntity = mock(ServiceEntity.class);
when(serviceDao.findByExternalId(SERVICE_ID)).thenReturn(of(serviceEntity));
when(serviceEntity.toService()).thenReturn(Service.from());
Optional<Service> maybeService = updater.doUpdate(SERVICE_ID, request);
assertThat(maybeService.isPresent(), is(true));
InOrder inOrder = inOrder(serviceEntity, serviceDao);
inOrder.verify(serviceEntity).setArchived(true);
inOrder.verify(serviceDao).merge(serviceEntity);
}
use of uk.gov.pay.adminusers.model.ServiceUpdateRequest in project pay-adminusers by alphagov.
the class ServiceUpdaterTest method shouldUpdateDefaultBillingAddressCountrySuccessfully.
@Test
public void shouldUpdateDefaultBillingAddressCountrySuccessfully() {
ServiceUpdateRequest request = serviceUpdateRequest("replace", "default_billing_address_country", "IE");
ServiceEntity serviceEntity = mock(ServiceEntity.class);
when(serviceDao.findByExternalId(SERVICE_ID)).thenReturn(of(serviceEntity));
when(serviceEntity.toService()).thenReturn(Service.from());
Optional<Service> maybeService = updater.doUpdate(SERVICE_ID, request);
assertThat(maybeService.isPresent(), is(true));
InOrder inOrder = inOrder(serviceEntity, serviceDao);
inOrder.verify(serviceEntity).setDefaultBillingAddressCountry("IE");
inOrder.verify(serviceDao).merge(serviceEntity);
}
Aggregations