Search in sources :

Example 1 with GatewayAccount

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

the class GatewayAccountServiceTest method shouldUpdateMotoMaskCardSecurityCodeInputTrue.

@Test
public void shouldUpdateMotoMaskCardSecurityCodeInputTrue() {
    JsonPatchRequest request = JsonPatchRequest.from(objectMapper.valueToTree(Map.of("op", "replace", "path", "moto_mask_card_security_code_input", "value", true)));
    when(mockGatewayAccountDao.findById(GATEWAY_ACCOUNT_ID)).thenReturn(Optional.of(mockGatewayAccountEntity));
    Optional<GatewayAccount> optionalGatewayAccount = gatewayAccountService.doPatch(GATEWAY_ACCOUNT_ID, request);
    assertThat(optionalGatewayAccount.isPresent(), is(true));
    verify(mockGatewayAccountEntity).setMotoMaskCardSecurityCodeInput(true);
    verify(mockGatewayAccountDao).merge(mockGatewayAccountEntity);
}
Also used : JsonPatchRequest(uk.gov.service.payments.commons.model.jsonpatch.JsonPatchRequest) GatewayAccount(uk.gov.pay.connector.gatewayaccount.model.GatewayAccount) Test(org.junit.jupiter.api.Test)

Example 2 with GatewayAccount

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

the class GatewayAccountServiceTest method shouldUpdateAllowZeroAmountFalse.

@Test
public void shouldUpdateAllowZeroAmountFalse() {
    JsonPatchRequest request = JsonPatchRequest.from(objectMapper.valueToTree(Map.of("op", "replace", "path", "allow_zero_amount", "value", false)));
    when(mockGatewayAccountDao.findById(GATEWAY_ACCOUNT_ID)).thenReturn(Optional.of(mockGatewayAccountEntity));
    Optional<GatewayAccount> optionalGatewayAccount = gatewayAccountService.doPatch(GATEWAY_ACCOUNT_ID, request);
    assertThat(optionalGatewayAccount.isPresent(), is(true));
    verify(mockGatewayAccountEntity).setAllowZeroAmount(false);
    verify(mockGatewayAccountDao).merge(mockGatewayAccountEntity);
}
Also used : JsonPatchRequest(uk.gov.service.payments.commons.model.jsonpatch.JsonPatchRequest) GatewayAccount(uk.gov.pay.connector.gatewayaccount.model.GatewayAccount) Test(org.junit.jupiter.api.Test)

Example 3 with GatewayAccount

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

the class GatewayAccountServiceTest method shouldUpdateProviderSwitchEnabledToTrue.

@Test
public void shouldUpdateProviderSwitchEnabledToTrue() {
    JsonPatchRequest request = JsonPatchRequest.from(objectMapper.valueToTree(Map.of("op", "replace", "path", "provider_switch_enabled", "value", true)));
    when(mockGatewayAccountDao.findById(GATEWAY_ACCOUNT_ID)).thenReturn(Optional.of(mockGatewayAccountEntity));
    when(mockGatewayAccountEntity.getId()).thenReturn(GATEWAY_ACCOUNT_ID);
    when(mockGatewayAccountCredentialsService.hasActiveCredentials(GATEWAY_ACCOUNT_ID)).thenReturn(true);
    Optional<GatewayAccount> optionalGatewayAccount = gatewayAccountService.doPatch(GATEWAY_ACCOUNT_ID, request);
    assertThat(optionalGatewayAccount.isPresent(), is(true));
    verify(mockGatewayAccountEntity).setProviderSwitchEnabled(true);
    verify(mockGatewayAccountDao).merge(mockGatewayAccountEntity);
}
Also used : JsonPatchRequest(uk.gov.service.payments.commons.model.jsonpatch.JsonPatchRequest) GatewayAccount(uk.gov.pay.connector.gatewayaccount.model.GatewayAccount) Test(org.junit.jupiter.api.Test)

Example 4 with GatewayAccount

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

the class GatewayAccountServiceTest method shouldUpdateSendPayerEmailToGatewayToTrue.

@Test
public void shouldUpdateSendPayerEmailToGatewayToTrue() {
    JsonPatchRequest request = JsonPatchRequest.from(objectMapper.valueToTree(Map.of("op", "replace", "path", "send_payer_email_to_gateway", "value", true)));
    when(mockGatewayAccountDao.findById(GATEWAY_ACCOUNT_ID)).thenReturn(Optional.of(mockGatewayAccountEntity));
    Optional<GatewayAccount> optionalGatewayAccount = gatewayAccountService.doPatch(GATEWAY_ACCOUNT_ID, request);
    assertThat(optionalGatewayAccount.isPresent(), is(true));
    verify(mockGatewayAccountEntity).setSendPayerEmailToGateway(true);
    verify(mockGatewayAccountDao).merge(mockGatewayAccountEntity);
}
Also used : JsonPatchRequest(uk.gov.service.payments.commons.model.jsonpatch.JsonPatchRequest) GatewayAccount(uk.gov.pay.connector.gatewayaccount.model.GatewayAccount) Test(org.junit.jupiter.api.Test)

Example 5 with GatewayAccount

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

the class GatewayAccountServiceTest method shouldUpdateAllowMotoFalse.

@Test
public void shouldUpdateAllowMotoFalse() {
    JsonPatchRequest request = JsonPatchRequest.from(objectMapper.valueToTree(Map.of("op", "replace", "path", "allow_moto", "value", false)));
    when(mockGatewayAccountDao.findById(GATEWAY_ACCOUNT_ID)).thenReturn(Optional.of(mockGatewayAccountEntity));
    Optional<GatewayAccount> optionalGatewayAccount = gatewayAccountService.doPatch(GATEWAY_ACCOUNT_ID, request);
    assertThat(optionalGatewayAccount.isPresent(), is(true));
    verify(mockGatewayAccountEntity).setAllowMoto(false);
    verify(mockGatewayAccountDao).merge(mockGatewayAccountEntity);
}
Also used : JsonPatchRequest(uk.gov.service.payments.commons.model.jsonpatch.JsonPatchRequest) GatewayAccount(uk.gov.pay.connector.gatewayaccount.model.GatewayAccount) Test(org.junit.jupiter.api.Test)

Aggregations

GatewayAccount (uk.gov.pay.connector.gatewayaccount.model.GatewayAccount)30 Test (org.junit.jupiter.api.Test)28 JsonPatchRequest (uk.gov.service.payments.commons.model.jsonpatch.JsonPatchRequest)28 InOrder (org.mockito.InOrder)3 Worldpay3dsFlexJwtCredentialsException (uk.gov.pay.connector.charge.exception.Worldpay3dsFlexJwtCredentialsException)2 GET (javax.ws.rs.GET)1 GET (javax.ws.rs.HttpMethod.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 ChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntity)1