Search in sources :

Example 1 with ServiceNameEntity

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;
}
Also used : ServiceNameEntity(uk.gov.pay.adminusers.persistence.entity.service.ServiceNameEntity)

Example 2 with ServiceNameEntity

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);
}
Also used : ServiceNameEntity(uk.gov.pay.adminusers.persistence.entity.service.ServiceNameEntity) 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 ServiceNameEntity

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));
}
Also used : ServiceNameEntity(uk.gov.pay.adminusers.persistence.entity.service.ServiceNameEntity) ServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntity) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 4 with ServiceNameEntity

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;
}
Also used : ServiceNameEntity(uk.gov.pay.adminusers.persistence.entity.service.ServiceNameEntity)

Aggregations

ServiceNameEntity (uk.gov.pay.adminusers.persistence.entity.service.ServiceNameEntity)4 Test (org.junit.jupiter.api.Test)2 ServiceEntity (uk.gov.pay.adminusers.persistence.entity.ServiceEntity)2 HashSet (java.util.HashSet)1 InOrder (org.mockito.InOrder)1 Service (uk.gov.pay.adminusers.model.Service)1 ServiceUpdateRequest (uk.gov.pay.adminusers.model.ServiceUpdateRequest)1 ServiceEntityBuilder.aServiceEntity (uk.gov.pay.adminusers.persistence.entity.ServiceEntityBuilder.aServiceEntity)1