TASKS 1-4 COMPLETE - #300
Open
keneijeh760-ship-it wants to merge 12 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR wires up Kafka-driven transaction processing with persistence and an external “incentive” HTTP call, and adds the required Spring dependencies/test configuration to support it.
Changes:
- Add a Kafka listener that consumes
Transactionmessages and routes them to a newTransactionService. - Implement
TransactionServiceto load users, apply balance changes, call an incentive endpoint, and persist aTransactionsentity. - Add Spring Web/JPA/H2/Kafka dependencies and test
application.ymlconfiguration.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/resources/application.yml | Adds test-only Kafka + H2 + JPA settings and topic configuration. |
| src/test/java/com/jpmc/midascore/TaskThreeTests.java | Adds UserRepository injection to the Task 3 test harness. |
| src/main/java/com/jpmc/midascore/Service/TransactionService.java | New transactional service that applies transfers, calls incentive endpoint, and persists transactions. |
| src/main/java/com/jpmc/midascore/repository/UserRepository.java | Updates repository imports / custom finder signature. |
| src/main/java/com/jpmc/midascore/repository/TransactionsRepository.java | Adds repository for new Transactions entity. |
| src/main/java/com/jpmc/midascore/MidasCoreApplication.java | Registers a RestTemplate bean for HTTP calls. |
| src/main/java/com/jpmc/midascore/listener/Listener.java | Adds Kafka listener that invokes TransactionService. |
| src/main/java/com/jpmc/midascore/foundation/Transactions.java | Introduces persisted Transactions entity capturing sender/recipient/amount/incentive. |
| src/main/java/com/jpmc/midascore/foundation/Transaction.java | Updates Transaction DTO imports/formatting. |
| src/main/java/com/jpmc/midascore/foundation/Incentives.java | Adds DTO for incentive response. |
| pom.xml | Adds web/JPA/H2/Kafka/test dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+36
to
+56
| UserRecord reciepinet = userRepository.findById(transaction.getRecipientId()); | ||
|
|
||
| if (reciepinet == null) { | ||
| return; | ||
| } | ||
|
|
||
|
|
||
| if (sender.getBalance() < transaction.getAmount()) { | ||
| return; | ||
| } | ||
|
|
||
| Incentives incentives = restTemplate.postForObject("http://localhost:8080/incentive", transaction, Incentives.class); | ||
|
|
||
|
|
||
| sender.setBalance(sender.getBalance() - transaction.getAmount()); | ||
| reciepinet.setBalance(reciepinet.getBalance() + transaction.getAmount() + incentives.getAmount()); | ||
|
|
||
| Transactions transactions = new Transactions(sender, reciepinet, transaction.getAmount(), incentives.getAmount()); | ||
| userRepository.save(sender); | ||
| userRepository.save(reciepinet); | ||
| transactionsRepository.save(transactions); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.