Credit card fraud check

How to run the application

I don't have an demo application to run the method because I think the unit tests are enough to show how to run it already.

How to run the tests

With Docker

docker-compose run app

If you have JAVA 8+ installed

./gradlew clean test

Jacoco test coverage

docker-compose run app gradle jacocoTestReport

Then go to build/reports/jacoco/test/html/index.html to see the result.

How the method works

The fraudulentCreditCards method in com.github.wahyd4.creditcard.service.FraudChecker receives list of transactions string and threshold to calculate all the credit cards which exceed the money threshold.

  1. First, all the transaction string records will be parsed into a TransactionEntry object.
  2. Then loops the entries, it groups all the transactions by hashed credit card id, the value of the key is all the records for that hashed id.
  3. During this time, the program analyses all the records for the specific card comes from the current entry. If the records overs one 24 hours windows, then only keep the most recent 24 hours records. If the card has been marked as fraudulent, then it will skipped.
  4. Calculates the total amount against the most recent 24 hours records, if the value greater than the threshold then mark the card as fraudulent and put it into the map.
  5. Returns all the matched hashed credit cards as a list.

Assumptions

  • a sequence of transactions in chronological order means the first item in the list is the oldest record.

Highlights

  • Wrote code with TDD
  • Docker-compose to make run the code in local much easier
S
Description
No description provided
Readme
102 KiB
Languages
Java 100%