use of uk.gov.pay.adminusers.persistence.entity.GatewayAccountIdEntity in project pay-adminusers by alphagov.
the class ServiceCreatorTest method shouldSuccess_whenProvidedWith_noParameters.
@Test
public void shouldSuccess_whenProvidedWith_noParameters() {
Service service = serviceCreator.doCreate(Collections.emptyList(), Collections.emptyMap());
verify(mockedServiceDao, never()).checkIfGatewayAccountsUsed(anyList());
verify(mockedServiceDao, times(1)).persist(persistedServiceEntity.capture());
assertThat(service.getName(), is("System Generated"));
assertThat(service.isRedirectToServiceImmediatelyOnTerminalState(), is(false));
assertThat(service.isCollectBillingAddress(), is(true));
assertThat(service.getDefaultBillingAddressCountry(), is("GB"));
List<GatewayAccountIdEntity> persistedGatewayIds = persistedServiceEntity.getValue().getGatewayAccountIds();
assertThat(persistedGatewayIds.size(), is(0));
assertEnServiceNameMap(service, "System Generated");
assertSelfLink(service);
}
use of uk.gov.pay.adminusers.persistence.entity.GatewayAccountIdEntity in project pay-adminusers by alphagov.
the class ServiceResourceFindTest method shouldFind_existingServiceByGatewayAccountId.
@Test
public void shouldFind_existingServiceByGatewayAccountId() {
GatewayAccountIdEntity gatewayAccountIdEntity = new GatewayAccountIdEntity();
String gatewayAccountId = randomUuid();
gatewayAccountIdEntity.setGatewayAccountId(gatewayAccountId);
ServiceEntity serviceEntity = ServiceEntityBuilder.aServiceEntity().withGatewayAccounts(Collections.singletonList(gatewayAccountIdEntity)).withRedirectToServiceImmediatelyOnTerminalState(true).withCreatedDate(ZonedDateTime.parse("2020-01-31T12:30:00Z")).withWentLiveDate(ZonedDateTime.parse("2020-02-01T09:00:00Z")).withSector("police").build();
gatewayAccountIdEntity.setService(serviceEntity);
given(mockedServiceDao.findByGatewayAccountId(gatewayAccountId)).willReturn(Optional.of(serviceEntity));
Response response = RESOURCES.target("/v1/api/services").queryParam("gatewayAccountId", gatewayAccountId).request().get();
assertThat(response.getStatus(), is(200));
String body = response.readEntity(String.class);
JsonPath json = JsonPath.from(body);
assertThat(json.get("name"), is(serviceEntity.getServiceNames().get(SupportedLanguage.ENGLISH).getName()));
assertEnServiceNameJson(serviceEntity.getServiceNames().get(SupportedLanguage.ENGLISH).getName(), json);
assertMerchantDetails(serviceEntity.getMerchantDetailsEntity(), json);
assertLinks(serviceEntity.getExternalId(), json);
assertThat(json.get("redirect_to_service_immediately_on_terminal_state"), is(serviceEntity.isRedirectToServiceImmediatelyOnTerminalState()));
assertThat(json.get("collect_billing_address"), is(serviceEntity.isCollectBillingAddress()));
assertThat(json.get("default_billing_address_country"), is(serviceEntity.getDefaultBillingAddressCountry()));
assertThat(json.get("current_go_live_stage"), is(String.valueOf(serviceEntity.getCurrentGoLiveStage())));
assertThat(json.get("created_date"), is("2020-01-31T12:30:00.000Z"));
assertThat(json.get("went_live_date"), is("2020-02-01T09:00:00.000Z"));
assertThat(json.get("sector"), is("police"));
assertThat(json.get("internal"), is(false));
assertThat(json.get("archived"), is(false));
}
use of uk.gov.pay.adminusers.persistence.entity.GatewayAccountIdEntity in project pay-adminusers by alphagov.
the class ServiceResourceUpdateTest method shouldSuccess_whenAddGatewayAccountIds_whereThereIsGatewayAccountIds.
@Test
public void shouldSuccess_whenAddGatewayAccountIds_whereThereIsGatewayAccountIds() {
GatewayAccountIdEntity gatewayAccountIdEntity = new GatewayAccountIdEntity();
String gatewayAccountId = randomUuid();
gatewayAccountIdEntity.setGatewayAccountId(gatewayAccountId);
ServiceEntity thisServiceEntity = ServiceEntityBuilder.aServiceEntity().withGatewayAccounts(Collections.singletonList(gatewayAccountIdEntity)).build();
gatewayAccountIdEntity.setService(thisServiceEntity);
String jsonPayload = fixture("fixtures/resource/service/patch/array-add-gateway-account-ids.json");
when(mockedServiceDao.findByExternalId(thisServiceEntity.getExternalId())).thenReturn(Optional.of(thisServiceEntity));
when(mockedServiceDao.merge(thisServiceEntity)).thenReturn(thisServiceEntity);
when(mockedServiceDao.checkIfGatewayAccountsUsed(Collections.singletonList("1014748185"))).thenReturn(false);
Response response = RESOURCES.target(format(API_PATH, thisServiceEntity.getExternalId())).request().method("PATCH", Entity.json(jsonPayload));
assertThat(response.getStatus(), is(200));
String body = response.readEntity(String.class);
JsonPath json = JsonPath.from(body);
assertThat(json.getList("gateway_account_ids"), containsInAnyOrder("1014748185", gatewayAccountId));
}
use of uk.gov.pay.adminusers.persistence.entity.GatewayAccountIdEntity in project pay-adminusers by alphagov.
the class ServiceDaoIT method shouldMergeGoLiveStage.
@Test
void shouldMergeGoLiveStage() {
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().getCurrentGoLiveStage(), is(GoLiveStage.NOT_STARTED));
optionalService.get().setCurrentGoLiveStage(GoLiveStage.CHOSEN_PSP_STRIPE);
serviceDao.merge(optionalService.get());
optionalService = serviceDao.findByGatewayAccountId(insertedServiceEntity.getGatewayAccountId().getGatewayAccountId());
assertThat(optionalService.isPresent(), is(true));
assertThat(optionalService.get().getCurrentGoLiveStage(), is(GoLiveStage.CHOSEN_PSP_STRIPE));
}
Aggregations