Search in sources :

Example 1 with ServiceUpdateRequest

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);
}
Also used : ServiceUpdateRequest(uk.gov.pay.adminusers.model.ServiceUpdateRequest) ServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntity) ServiceEntityBuilder.aServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntityBuilder.aServiceEntity) Service(uk.gov.pay.adminusers.model.Service) Test(org.junit.jupiter.api.Test)

Example 2 with ServiceUpdateRequest

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);
}
Also used : InOrder(org.mockito.InOrder) ServiceUpdateRequest(uk.gov.pay.adminusers.model.ServiceUpdateRequest) ServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntity) ServiceEntityBuilder.aServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntityBuilder.aServiceEntity) Service(uk.gov.pay.adminusers.model.Service) Test(org.junit.jupiter.api.Test)

Example 3 with ServiceUpdateRequest

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);
}
Also used : InOrder(org.mockito.InOrder) ServiceUpdateRequest(uk.gov.pay.adminusers.model.ServiceUpdateRequest) ServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntity) ServiceEntityBuilder.aServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntityBuilder.aServiceEntity) Service(uk.gov.pay.adminusers.model.Service) Test(org.junit.jupiter.api.Test)

Example 4 with ServiceUpdateRequest

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);
}
Also used : InOrder(org.mockito.InOrder) ServiceUpdateRequest(uk.gov.pay.adminusers.model.ServiceUpdateRequest) ServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntity) ServiceEntityBuilder.aServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntityBuilder.aServiceEntity) Service(uk.gov.pay.adminusers.model.Service) Test(org.junit.jupiter.api.Test)

Example 5 with ServiceUpdateRequest

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);
}
Also used : InOrder(org.mockito.InOrder) ServiceUpdateRequest(uk.gov.pay.adminusers.model.ServiceUpdateRequest) ServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntity) ServiceEntityBuilder.aServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntityBuilder.aServiceEntity) Service(uk.gov.pay.adminusers.model.Service) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)18 ServiceUpdateRequest (uk.gov.pay.adminusers.model.ServiceUpdateRequest)18 ServiceEntity (uk.gov.pay.adminusers.persistence.entity.ServiceEntity)18 ServiceEntityBuilder.aServiceEntity (uk.gov.pay.adminusers.persistence.entity.ServiceEntityBuilder.aServiceEntity)18 Service (uk.gov.pay.adminusers.model.Service)17 InOrder (org.mockito.InOrder)8 MerchantDetailsEntity (uk.gov.pay.adminusers.persistence.entity.MerchantDetailsEntity)1 MerchantDetailsEntityBuilder.aMerchantDetailsEntity (uk.gov.pay.adminusers.persistence.entity.MerchantDetailsEntityBuilder.aMerchantDetailsEntity)1 ServiceNameEntity (uk.gov.pay.adminusers.persistence.entity.service.ServiceNameEntity)1