-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2561 from alphagov/pp_6988_expunge_refunds
PP-6988 Fix ledger refund transaction mapping
- Loading branch information
Showing
10 changed files
with
69 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,8 @@ | |
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
import static uk.gov.pay.connector.util.TestTemplateResourceLoader.LEDGER_GET_REFUNDS_FOR_PAYMENT; | ||
import static uk.gov.pay.connector.util.TestTemplateResourceLoader.LEDGER_GET_TRANSACTION; | ||
import static uk.gov.pay.connector.util.TestTemplateResourceLoader.LEDGER_PAYMENT_TRANSACTION; | ||
import static uk.gov.pay.connector.util.TestTemplateResourceLoader.LEDGER_REFUND_TRANSACTION; | ||
import static uk.gov.pay.connector.util.TestTemplateResourceLoader.load; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
|
@@ -60,8 +61,8 @@ public void setUp() { | |
} | ||
|
||
@Test | ||
public void getTransaction_shouldSerialiseLedgerTransaction() throws JsonProcessingException { | ||
when(mockResponse.readEntity(LedgerTransaction.class)).thenReturn(objectMapper.readValue(load(LEDGER_GET_TRANSACTION), LedgerTransaction.class)); | ||
public void getTransaction_shouldSerialiseLedgerPaymentTransactionCorrectly() throws JsonProcessingException { | ||
when(mockResponse.readEntity(LedgerTransaction.class)).thenReturn(objectMapper.readValue(load(LEDGER_PAYMENT_TRANSACTION), LedgerTransaction.class)); | ||
|
||
String externalId = "external-id"; | ||
Optional<LedgerTransaction> mayBeTransaction = ledgerService.getTransaction("external-id"); | ||
|
@@ -74,6 +75,26 @@ public void getTransaction_shouldSerialiseLedgerTransaction() throws JsonProcess | |
assertThat(transaction.getExternalMetaData(), is(notNullValue())); | ||
} | ||
|
||
@Test | ||
public void getTransaction_shouldSerialiseLedgerRefundTransactionCorrectly() throws JsonProcessingException { | ||
when(mockResponse.readEntity(LedgerTransaction.class)) | ||
.thenReturn(objectMapper.readValue(load(LEDGER_REFUND_TRANSACTION), LedgerTransaction.class)); | ||
|
||
String externalId = "external-id"; | ||
Optional<LedgerTransaction> mayBeTransaction = ledgerService.getTransaction("external-id"); | ||
|
||
assertThat(mayBeTransaction.isPresent(), is(true)); | ||
LedgerTransaction transaction = mayBeTransaction.get(); | ||
assertThat(transaction.getTransactionId(), is(externalId)); | ||
assertThat(transaction.getAmount(), is(1000L)); | ||
assertThat(transaction.getGatewayTransactionId(), is("re_1H6zDTHj08j2jFuBtG6maiHK11")); | ||
assertThat(transaction.getParentTransactionId(), is("64pcdagc9c13vgi7n904aio3n9")); | ||
assertThat(transaction.getRefundedBy(), is("refunded-by-external-id")); | ||
assertThat(transaction.getRefundedByUserEmail(), is("[email protected]")); | ||
assertThat(transaction.getCreatedDate(), is("2020-07-20T13:39:38.940Z")); | ||
assertThat(transaction.getState().getStatus(), is("success")); | ||
} | ||
|
||
@Test | ||
public void getRefundsFromLedgerShouldSerialiseResponseCorrectly() throws JsonProcessingException { | ||
when(mockResponse.readEntity(RefundTransactionsForPayment.class)). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
15 changes: 15 additions & 0 deletions
15
src/test/resources/templates/ledger/refund_transaction.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"gateway_account_id": "1821", | ||
"amount": 1000, | ||
"state": { | ||
"finished": true, | ||
"status": "success" | ||
}, | ||
"created_date": "2020-07-20T13:39:38.940Z", | ||
"gateway_transaction_id": "re_1H6zDTHj08j2jFuBtG6maiHK11", | ||
"transaction_type": "REFUND", | ||
"transaction_id": "external-id", | ||
"parent_transaction_id": "64pcdagc9c13vgi7n904aio3n9", | ||
"refunded_by": "refunded-by-external-id", | ||
"refunded_by_user_email": "[email protected]" | ||
} |