use of uk.gov.pay.adminusers.persistence.entity.GatewayAccountIdEntity in project pay-adminusers by alphagov.
the class ServiceDaoIT method shouldMergePSPTestAccountStage.
@Test
void shouldMergePSPTestAccountStage() {
GatewayAccountIdEntity gatewayAccountIdEntity = new GatewayAccountIdEntity();
String gatewayAccountId = randomUuid();
gatewayAccountIdEntity.setGatewayAccountId(gatewayAccountId);
ServiceEntity insertedServiceEntity = ServiceEntityBuilder.aServiceEntity().withGatewayAccounts(Collections.singletonList(gatewayAccountIdEntity)).build();
gatewayAccountIdEntity.setService(insertedServiceEntity);
databaseHelper.insertServiceEntity(insertedServiceEntity);
Optional<ServiceEntity> optionalService = serviceDao.findByGatewayAccountId(insertedServiceEntity.getGatewayAccountId().getGatewayAccountId());
assertThat(optionalService.isPresent(), is(true));
assertThat(optionalService.get().getCurrentPspTestAccountStage(), is(PspTestAccountStage.NOT_STARTED));
optionalService.get().setCurrentPspTestAccountStage(PspTestAccountStage.REQUEST_SUBMITTED);
serviceDao.merge(optionalService.get());
optionalService = serviceDao.findByGatewayAccountId(insertedServiceEntity.getGatewayAccountId().getGatewayAccountId());
assertThat(optionalService.isPresent(), is(true));
assertThat(optionalService.get().getCurrentPspTestAccountStage(), is(PspTestAccountStage.REQUEST_SUBMITTED));
}
use of uk.gov.pay.adminusers.persistence.entity.GatewayAccountIdEntity in project pay-adminusers by alphagov.
the class ServiceDaoIT method shouldFindByGatewayAccountId.
@Test
void shouldFindByGatewayAccountId() {
GatewayAccountIdEntity gatewayAccountIdEntity = new GatewayAccountIdEntity();
String gatewayAccountId = randomUuid();
gatewayAccountIdEntity.setGatewayAccountId(gatewayAccountId);
ServiceEntity insertedServiceEntity = ServiceEntityBuilder.aServiceEntity().withGatewayAccounts(Collections.singletonList(gatewayAccountIdEntity)).build();
gatewayAccountIdEntity.setService(insertedServiceEntity);
databaseHelper.insertServiceEntity(insertedServiceEntity);
Optional<ServiceEntity> optionalService = serviceDao.findByGatewayAccountId(insertedServiceEntity.getGatewayAccountId().getGatewayAccountId());
assertThat(optionalService.isPresent(), is(true));
ServiceEntity foundServiceEntity = optionalService.get();
assertServiceEntity(insertedServiceEntity, foundServiceEntity);
}
use of uk.gov.pay.adminusers.persistence.entity.GatewayAccountIdEntity in project pay-adminusers by alphagov.
the class ServiceInviteCompleterTest method shouldCreateServiceAndUser_withGatewayAccounts_whenPassedValidServiceInviteCode.
@Test
public void shouldCreateServiceAndUser_withGatewayAccounts_whenPassedValidServiceInviteCode() {
ServiceEntity service = new ServiceEntity();
service.setId(serviceId);
InviteEntity anInvite = createInvite();
anInvite.setType(InviteType.SERVICE);
when(mockUserDao.findByEmail(email)).thenReturn(Optional.empty());
when(mockInviteDao.findByCode(inviteCode)).thenReturn(Optional.of(anInvite));
InviteCompleteRequest data = new InviteCompleteRequest();
data.setGatewayAccountIds(asList("1", "2"));
InviteCompleteResponse inviteResponse = serviceInviteCompleter.withData(data).complete(anInvite.getCode()).get();
verify(mockServiceDao).persist(expectedService.capture());
verify(mockUserDao).merge(expectedInvitedUser.capture());
verify(mockInviteDao).merge(expectedInvite.capture());
ServiceEntity serviceEntity = expectedService.getValue();
assertThat(serviceEntity.getGatewayAccountIds().stream().map(GatewayAccountIdEntity::getGatewayAccountId).collect(toUnmodifiableList()), hasItems("2", "1"));
assertThat(serviceEntity.getServiceNames().get(SupportedLanguage.ENGLISH).getName(), is(Service.DEFAULT_NAME_VALUE));
assertThat(serviceEntity.isRedirectToServiceImmediatelyOnTerminalState(), is(false));
assertThat(serviceEntity.isCollectBillingAddress(), is(true));
assertThat(serviceEntity.getDefaultBillingAddressCountry(), is("GB"));
assertThat(inviteResponse.getInvite().isDisabled(), is(true));
assertThat(inviteResponse.getInvite().getLinks().size(), is(1));
assertThat(inviteResponse.getInvite().getLinks().get(0).getRel(), is(Link.Rel.USER));
assertThat(inviteResponse.getInvite().getLinks().get(0).getHref(), matchesPattern("^" + baseUrl + "/v1/api/users/[0-9a-z]{32}$"));
}
use of uk.gov.pay.adminusers.persistence.entity.GatewayAccountIdEntity in project pay-adminusers by alphagov.
the class ServiceCreatorTest method shouldSuccess_whenProvidedWith_multipleValidNames_andNoGatewayAccountIds.
@Test
public void shouldSuccess_whenProvidedWith_multipleValidNames_andNoGatewayAccountIds() {
Map<SupportedLanguage, String> serviceNames = new HashMap<>();
serviceNames.put(SupportedLanguage.ENGLISH, EN_SERVICE_NAME);
serviceNames.put(SupportedLanguage.WELSH, CY_SERVICE_NAME);
Service service = serviceCreator.doCreate(Collections.emptyList(), serviceNames);
verify(mockedServiceDao, never()).checkIfGatewayAccountsUsed(anyList());
verify(mockedServiceDao, times(1)).persist(persistedServiceEntity.capture());
assertThat(service.getName(), is(EN_SERVICE_NAME));
List<GatewayAccountIdEntity> persistedGatewayIds = persistedServiceEntity.getValue().getGatewayAccountIds();
assertThat(persistedGatewayIds.size(), is(0));
assertEnServiceNameMap(service, EN_SERVICE_NAME);
assertThat(service.getServiceNames(), hasKey(SupportedLanguage.WELSH.toString()));
assertThat(service.getServiceNames(), hasValue(CY_SERVICE_NAME));
assertSelfLink(service);
}
use of uk.gov.pay.adminusers.persistence.entity.GatewayAccountIdEntity in project pay-adminusers by alphagov.
the class ServiceCreatorTest method shouldSuccess_whenProvidedWith_onlyAValidName.
@Test
public void shouldSuccess_whenProvidedWith_onlyAValidName() {
Service service = serviceCreator.doCreate(Collections.emptyList(), Map.of(SupportedLanguage.ENGLISH, EN_SERVICE_NAME));
verify(mockedServiceDao, never()).checkIfGatewayAccountsUsed(anyList());
verify(mockedServiceDao, times(1)).persist(persistedServiceEntity.capture());
assertThat(service.getName(), is(EN_SERVICE_NAME));
List<GatewayAccountIdEntity> persistedGatewayIds = persistedServiceEntity.getValue().getGatewayAccountIds();
assertThat(persistedGatewayIds.size(), is(0));
assertEnServiceNameMap(service, EN_SERVICE_NAME);
assertSelfLink(service);
}
Aggregations