|
@@ -54,7 +54,7 @@ class OmgPaymentCreateServiceTest {
|
|
|
@Test
|
|
@Test
|
|
|
void rejectsExistingCreatedAttemptBeforeCredentialOrFormWork() {
|
|
void rejectsExistingCreatedAttemptBeforeCredentialOrFormWork() {
|
|
|
when(attempts.selectOrderForUpdate("DD-1")).thenReturn(payableOrder());
|
|
when(attempts.selectOrderForUpdate("DD-1")).thenReturn(payableOrder());
|
|
|
- when(attempts.selectActiveCreatedByDdId("DD-1")).thenReturn(new OmgPaymentAttempt());
|
|
|
|
|
|
|
+ when(attempts.selectActiveCreatedByDdIdForUpdate("DD-1")).thenReturn(new OmgPaymentAttempt());
|
|
|
OmgPaymentBusinessException error = assertThrows(OmgPaymentBusinessException.class,
|
|
OmgPaymentBusinessException error = assertThrows(OmgPaymentBusinessException.class,
|
|
|
() -> service.create(5L, "DD-1"));
|
|
() -> service.create(5L, "DD-1"));
|
|
|
assertEquals(PAYMENT_ATTEMPT_EXISTS, error.getCode());
|
|
assertEquals(PAYMENT_ATTEMPT_EXISTS, error.getCode());
|
|
@@ -82,7 +82,7 @@ class OmgPaymentCreateServiceTest {
|
|
|
assertTrue(outcome.response().formFields().containsKey("CheckMacValue"));
|
|
assertTrue(outcome.response().formFields().containsKey("CheckMacValue"));
|
|
|
var orderOfCalls = inOrder(attempts, credentials, generator, formFactory);
|
|
var orderOfCalls = inOrder(attempts, credentials, generator, formFactory);
|
|
|
orderOfCalls.verify(attempts).selectOrderForUpdate("DD-1");
|
|
orderOfCalls.verify(attempts).selectOrderForUpdate("DD-1");
|
|
|
- orderOfCalls.verify(attempts).selectActiveCreatedByDdId("DD-1");
|
|
|
|
|
|
|
+ orderOfCalls.verify(attempts).selectActiveCreatedByDdIdForUpdate("DD-1");
|
|
|
orderOfCalls.verify(credentials).getEnabledCredential(77L);
|
|
orderOfCalls.verify(credentials).getEnabledCredential(77L);
|
|
|
orderOfCalls.verify(generator).generate();
|
|
orderOfCalls.verify(generator).generate();
|
|
|
orderOfCalls.verify(formFactory).create("DD-1", 100, "1000031", "KEY", "IV",
|
|
orderOfCalls.verify(formFactory).create("DD-1", 100, "1000031", "KEY", "IV",
|
|
@@ -99,7 +99,7 @@ class OmgPaymentCreateServiceTest {
|
|
|
.thenReturn(new OmgPaymentForm("stage", Map.of()));
|
|
.thenReturn(new OmgPaymentForm("stage", Map.of()));
|
|
|
when(attempts.createCreated(anyString(), anyString(), anyLong(), anyString(), anyInt()))
|
|
when(attempts.createCreated(anyString(), anyString(), anyLong(), anyString(), anyInt()))
|
|
|
.thenThrow(new DuplicateKeyException("collision"));
|
|
.thenThrow(new DuplicateKeyException("collision"));
|
|
|
- when(attempts.selectActiveCreatedByDdId("DD-1")).thenReturn(null, new OmgPaymentAttempt());
|
|
|
|
|
|
|
+ when(attempts.selectActiveCreatedByDdIdForUpdate("DD-1")).thenReturn(null, new OmgPaymentAttempt());
|
|
|
|
|
|
|
|
OmgPaymentBusinessException error = assertThrows(OmgPaymentBusinessException.class,
|
|
OmgPaymentBusinessException error = assertThrows(OmgPaymentBusinessException.class,
|
|
|
() -> service.create(5L, "DD-1"));
|
|
() -> service.create(5L, "DD-1"));
|
|
@@ -118,7 +118,8 @@ class OmgPaymentCreateServiceTest {
|
|
|
inserted.setId(11L);
|
|
inserted.setId(11L);
|
|
|
when(attempts.createCreated(anyString(), anyString(), anyLong(), anyString(), anyInt()))
|
|
when(attempts.createCreated(anyString(), anyString(), anyLong(), anyString(), anyInt()))
|
|
|
.thenThrow(new DuplicateKeyException("trade collision")).thenReturn(inserted);
|
|
.thenThrow(new DuplicateKeyException("trade collision")).thenReturn(inserted);
|
|
|
- when(attempts.selectByMerchantTradeNo("OMG11111111111111111")).thenReturn(new OmgPaymentAttempt());
|
|
|
|
|
|
|
+ when(attempts.selectByMerchantTradeNoForUpdate("OMG11111111111111111"))
|
|
|
|
|
+ .thenReturn(new OmgPaymentAttempt());
|
|
|
|
|
|
|
|
assertEquals(11L, service.create(5L, "DD-1").attemptId());
|
|
assertEquals(11L, service.create(5L, "DD-1").attemptId());
|
|
|
verify(generator, times(2)).generate();
|
|
verify(generator, times(2)).generate();
|
|
@@ -135,7 +136,7 @@ class OmgPaymentCreateServiceTest {
|
|
|
.thenReturn(new OmgPaymentForm("stage", Map.of()));
|
|
.thenReturn(new OmgPaymentForm("stage", Map.of()));
|
|
|
when(attempts.createCreated(anyString(), anyString(), anyLong(), anyString(), anyInt()))
|
|
when(attempts.createCreated(anyString(), anyString(), anyLong(), anyString(), anyInt()))
|
|
|
.thenThrow(new DuplicateKeyException("trade collision"));
|
|
.thenThrow(new DuplicateKeyException("trade collision"));
|
|
|
- when(attempts.selectByMerchantTradeNo(anyString())).thenReturn(new OmgPaymentAttempt());
|
|
|
|
|
|
|
+ when(attempts.selectByMerchantTradeNoForUpdate(anyString())).thenReturn(new OmgPaymentAttempt());
|
|
|
|
|
|
|
|
OmgPaymentBusinessException error = assertThrows(OmgPaymentBusinessException.class,
|
|
OmgPaymentBusinessException error = assertThrows(OmgPaymentBusinessException.class,
|
|
|
() -> service.create(5L, "DD-1"));
|
|
() -> service.create(5L, "DD-1"));
|