- Downlaod the repo.
- Import the Java Project
- Right click on project->properties->java Build Path->libraries->Add libraries -> Select JUnit 5-> Select Junit5.
- Execute TradeOperationsApplicationTests.java & TradeServiceTest.java with Junit Test.
There is a scenario where thousands of trades are flowing into one store, assume any way of transmission of trades. We need to create a one trade store, which stores the trade in the following order.
| First Header | Second Header | Second Header | Second Header | Second Header | Second Header | Second Header |
|---|---|---|---|---|---|---|
| Tl | 1 | CP-1 | B1 | 20/05/2020 | N | |
| T2 | 2 | CP-2 | B1 | 20/05/2021 | N | |
| T2 | 1 | CP-1 | B1 | 20/05/2021 | 20/05/2021 | N |
| T2 | 3 | CP-3 | B2 | 20/05/2014 | Y |
- During transmission if the lower version is being received by the store it will reject the trade and throw an exception. If the version is same it will override the existing record.
- Store should not allow the trade which has less maturity date then today date.
- Store should automatically update the expire flag if in a store the trade crosses the maturity date.
- Spring boot application with maven.
- Java Version Used:-JDK 1.8,JRE 1.8
- Junt Version Used- JUnit 5
http://localhost:8081/api/trade ####[{ "tradeId" : "T1", "version" : 1, "counterPartyId" : "CP-1","bookId" : "B1","maturityDate" : "2022-04-18","createdDate" :"2017-04-22","expired" : "N"}]
http://localhost:8081/h2-console
- 1st Trade is added with maturity date greater than today's date
- If version is high and maturity date is greater than today's date then record will be added
- If version is lower then reject with expcetion.
- If version is equals to existing version then update 5.Check if Version is Same and date is lower the trade is not updated. 6.Check if Maturity Date is Same as Todays Date the list will be added. 7.Check if version is high but maturity date is low the trade will be rejected. 8.Check If Maturity Date is Expired it will update the Expired Flag
- Check with T1 1 CP-1 B1 20/05/2020 N
- Check With T2 2 CP-2 B1 20/05/2021 N
- Check With T2 1 CP-1 B1 20/05/2021 14/03/2015 N
- Check Expired T3 3 CP-3 B2 20/05/2014 Y
- All test Case Passed.