use of uk.gov.service.payments.commons.model.jsonpatch.JsonPatchRequest in project pay-connector by alphagov.
the class GatewayAccountCredentialsServiceTest method shouldChangeStateToActive_whenCredentialsInCreatedStateUpdated_andOnlyOneCredential.
@Test
void shouldChangeStateToActive_whenCredentialsInCreatedStateUpdated_andOnlyOneCredential() {
GatewayAccountEntity gatewayAccountEntity = aGatewayAccountEntity().build();
GatewayAccountCredentialsEntity credentialsEntity = aGatewayAccountCredentialsEntity().withGatewayAccountEntity(gatewayAccountEntity).withState(CREATED).build();
gatewayAccountEntity.setGatewayAccountCredentials(List.of(credentialsEntity));
JsonPatchRequest patchRequest = JsonPatchRequest.from(objectMapper.valueToTree(Map.of("path", "credentials", "op", "replace", "value", Map.of("merchant_id", "new-merchant-id"))));
gatewayAccountCredentialsService.updateGatewayAccountCredentials(credentialsEntity, Collections.singletonList(patchRequest));
assertThat(credentialsEntity.getState(), is(ACTIVE));
}
use of uk.gov.service.payments.commons.model.jsonpatch.JsonPatchRequest in project pay-connector by alphagov.
the class GatewayAccountServiceTest method shouldUpdateSendPayerEmailToGatewayToFalse.
@Test
public void shouldUpdateSendPayerEmailToGatewayToFalse() {
JsonPatchRequest request = JsonPatchRequest.from(objectMapper.valueToTree(Map.of("op", "replace", "path", "send_payer_email_to_gateway", "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).setSendPayerEmailToGateway(false);
verify(mockGatewayAccountDao).merge(mockGatewayAccountEntity);
}
use of uk.gov.service.payments.commons.model.jsonpatch.JsonPatchRequest in project pay-connector by alphagov.
the class GatewayAccountServiceTest method shouldThrowWrongGatewayAccountExceptionWhenAccountIsNotWorldpay.
@Test
public void shouldThrowWrongGatewayAccountExceptionWhenAccountIsNotWorldpay() {
JsonPatchRequest request = JsonPatchRequest.from(objectMapper.valueToTree(Map.of("op", "replace", "path", FIELD_WORLDPAY_EXEMPTION_ENGINE_ENABLED, "value", true)));
when(mockGatewayAccountEntity.getGatewayName()).thenReturn(EPDQ.getName());
when(mockGatewayAccountDao.findById(GATEWAY_ACCOUNT_ID)).thenReturn(Optional.of(mockGatewayAccountEntity));
var thrown = assertThrows(NotSupportedGatewayAccountException.class, () -> gatewayAccountService.doPatch(GATEWAY_ACCOUNT_ID, request));
assertThat(thrown.getMessage(), is(BAD_REQUEST_MESSAGE));
}
use of uk.gov.service.payments.commons.model.jsonpatch.JsonPatchRequest in project pay-connector by alphagov.
the class GatewayAccountServiceTest method shouldUpdateSendReferenceToGatewayToTrue.
@Test
public void shouldUpdateSendReferenceToGatewayToTrue() {
JsonPatchRequest request = JsonPatchRequest.from(objectMapper.valueToTree(Map.of("op", "replace", "path", "send_reference_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).setSendReferenceToGateway(true);
verify(mockGatewayAccountDao).merge(mockGatewayAccountEntity);
}
use of uk.gov.service.payments.commons.model.jsonpatch.JsonPatchRequest in project pay-connector by alphagov.
the class GatewayAccountServiceTest method shouldUpdateIntegrationVersion3ds.
@Test
public void shouldUpdateIntegrationVersion3ds() {
JsonPatchRequest request = JsonPatchRequest.from(objectMapper.valueToTree(Map.of("op", "replace", "path", "integration_version_3ds", "value", 2)));
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).setIntegrationVersion3ds(2);
verify(mockGatewayAccountDao).merge(mockGatewayAccountEntity);
}
Aggregations