Search in sources :

Example 1 with GatewayAccountSearchParams

use of uk.gov.pay.connector.gatewayaccount.model.GatewayAccountSearchParams in project pay-connector by alphagov.

the class GatewayAccountServiceTest method shouldSearchGatewayAccounts.

@Test
public void shouldSearchGatewayAccounts() {
    GatewayAccountSearchParams gatewayAccountSearchParams = new GatewayAccountSearchParams();
    when(mockGatewayAccountDao.search(gatewayAccountSearchParams)).thenReturn(Arrays.asList(getMockGatewayAccountEntity1, getMockGatewayAccountEntity2));
    List<GatewayAccountResourceDTO> gatewayAccounts = gatewayAccountService.searchGatewayAccounts(gatewayAccountSearchParams);
    assertThat(gatewayAccounts, hasSize(2));
    assertThat(gatewayAccounts.get(0).getServiceName(), is("service one"));
    assertThat(gatewayAccounts.get(1).getServiceName(), is("service two"));
}
Also used : GatewayAccountResourceDTO(uk.gov.pay.connector.gatewayaccount.model.GatewayAccountResourceDTO) GatewayAccountSearchParams(uk.gov.pay.connector.gatewayaccount.model.GatewayAccountSearchParams) Test(org.junit.jupiter.api.Test)

Example 2 with GatewayAccountSearchParams

use of uk.gov.pay.connector.gatewayaccount.model.GatewayAccountSearchParams in project pay-connector by alphagov.

the class GatewayAccountDaoIT method shouldSearchForAccountsByPaymentProvider.

@Test
public void shouldSearchForAccountsByPaymentProvider() {
    long gatewayAccountId1 = nextLong();
    long gatewayAccountId2 = nextLong();
    long gatewayAccountId3 = nextLong();
    AddGatewayAccountCredentialsParams account1_credentials1 = anAddGatewayAccountCredentialsParams().withPaymentProvider(WORLDPAY.getName()).withState(CREATED).withGatewayAccountId(gatewayAccountId1).build();
    AddGatewayAccountCredentialsParams account1_credentials2 = anAddGatewayAccountCredentialsParams().withPaymentProvider(STRIPE.getName()).withState(ACTIVE).withGatewayAccountId(gatewayAccountId1).build();
    AddGatewayAccountCredentialsParams account2_credentials = anAddGatewayAccountCredentialsParams().withPaymentProvider(WORLDPAY.getName()).withState(ACTIVE).withGatewayAccountId(gatewayAccountId2).build();
    AddGatewayAccountCredentialsParams account3_credentials = anAddGatewayAccountCredentialsParams().withPaymentProvider(WORLDPAY.getName()).withState(CREATED).withGatewayAccountId(gatewayAccountId3).build();
    databaseTestHelper.addGatewayAccount(anAddGatewayAccountParams().withAccountId(String.valueOf(gatewayAccountId1)).withGatewayAccountCredentials(List.of(account1_credentials1, account1_credentials2)).build());
    databaseTestHelper.addGatewayAccount(anAddGatewayAccountParams().withAccountId(String.valueOf(gatewayAccountId2)).withGatewayAccountCredentials(List.of(account2_credentials)).build());
    databaseTestHelper.addGatewayAccount(anAddGatewayAccountParams().withAccountId(String.valueOf(gatewayAccountId3)).withGatewayAccountCredentials(List.of(account3_credentials)).build());
    var params = new GatewayAccountSearchParams();
    params.setPaymentProvider("worldpay");
    List<GatewayAccountEntity> gatewayAccounts = gatewayAccountDao.search(params);
    assertThat(gatewayAccounts, hasSize(2));
    assertThat(gatewayAccounts, containsInAnyOrder(hasProperty("id", is(gatewayAccountId2)), hasProperty("id", is(gatewayAccountId3))));
}
Also used : GatewayAccountSearchParams(uk.gov.pay.connector.gatewayaccount.model.GatewayAccountSearchParams) GatewayAccountEntity(uk.gov.pay.connector.gatewayaccount.model.GatewayAccountEntity) AddGatewayAccountCredentialsParamsBuilder.anAddGatewayAccountCredentialsParams(uk.gov.pay.connector.util.AddGatewayAccountCredentialsParams.AddGatewayAccountCredentialsParamsBuilder.anAddGatewayAccountCredentialsParams) AddGatewayAccountCredentialsParams(uk.gov.pay.connector.util.AddGatewayAccountCredentialsParams) Test(org.junit.Test)

Aggregations

GatewayAccountSearchParams (uk.gov.pay.connector.gatewayaccount.model.GatewayAccountSearchParams)2 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1 GatewayAccountEntity (uk.gov.pay.connector.gatewayaccount.model.GatewayAccountEntity)1 GatewayAccountResourceDTO (uk.gov.pay.connector.gatewayaccount.model.GatewayAccountResourceDTO)1 AddGatewayAccountCredentialsParams (uk.gov.pay.connector.util.AddGatewayAccountCredentialsParams)1 AddGatewayAccountCredentialsParamsBuilder.anAddGatewayAccountCredentialsParams (uk.gov.pay.connector.util.AddGatewayAccountCredentialsParams.AddGatewayAccountCredentialsParamsBuilder.anAddGatewayAccountCredentialsParams)1