use of uk.gov.pay.adminusers.persistence.entity.service.ServiceNameEntity in project pay-adminusers by alphagov.
the class ServiceEntityBuilder method withServiceNameEntity.
public ServiceEntityBuilder withServiceNameEntity(SupportedLanguage language, String name) {
ServiceNameEntity entity = new ServiceNameEntity();
entity.setLanguage(language);
entity.setName(name);
this.serviceName.add(entity);
return this;
}
use of uk.gov.pay.adminusers.persistence.entity.service.ServiceNameEntity in project pay-adminusers by alphagov.
the class ServiceUpdaterTest method shouldUpdateServiceNameSuccessfully.
@Test
public void shouldUpdateServiceNameSuccessfully() {
String nameToUpdate = "new-cy-name";
ServiceUpdateRequest request = serviceUpdateRequest("replace", "service_name/cy", nameToUpdate);
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));
ServiceNameEntity serviceNameEntity = ServiceNameEntity.from(SupportedLanguage.WELSH, nameToUpdate);
InOrder inOrder = inOrder(ignoreStubs(serviceDao, serviceEntity));
inOrder.verify(serviceEntity).addOrUpdateServiceName(serviceNameEntity);
inOrder.verify(serviceDao).merge(serviceEntity);
}
use of uk.gov.pay.adminusers.persistence.entity.service.ServiceNameEntity in project pay-adminusers by alphagov.
the class ServiceDaoIT method shouldFindServiceWithMultipleLanguage_byServiceExternalId.
@Test
void shouldFindServiceWithMultipleLanguage_byServiceExternalId() {
Set<ServiceNameEntity> serviceNames = new HashSet<>(List.of(createServiceName(SupportedLanguage.ENGLISH, EN_NAME), createServiceName(SupportedLanguage.WELSH, CY_NAME)));
ServiceEntity insertedServiceEntity = ServiceEntityBuilder.aServiceEntity().withServiceName(serviceNames).build();
databaseHelper.insertServiceEntity(insertedServiceEntity);
Optional<ServiceEntity> serviceEntity = serviceDao.findByExternalId(insertedServiceEntity.getExternalId());
assertTrue(serviceEntity.isPresent());
ServiceEntity foundServiceEntity = serviceEntity.get();
assertServiceEntity(insertedServiceEntity, foundServiceEntity);
assertMerchantDetails(insertedServiceEntity.getMerchantDetailsEntity(), foundServiceEntity.getMerchantDetailsEntity());
assertCustomBranding(foundServiceEntity);
assertThat(foundServiceEntity.getServiceNames().size(), is(2));
assertThat(foundServiceEntity.getServiceNames(), hasKey(SupportedLanguage.ENGLISH));
assertThat(foundServiceEntity.getServiceNames(), hasKey(SupportedLanguage.WELSH));
}
use of uk.gov.pay.adminusers.persistence.entity.service.ServiceNameEntity in project pay-adminusers by alphagov.
the class ServiceDaoIT method createServiceName.
private static ServiceNameEntity createServiceName(SupportedLanguage language, String name) {
ServiceNameEntity serviceNameEntity = ServiceNameEntity.from(language, name);
serviceNameEntity.setId((long) RandomUtils.nextInt());
return serviceNameEntity;
}
Aggregations