You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Open feeCalculation-applicationOverview.xml in https://www.draw.io/ to get an overview class diagram
LoadFeeCalculator.java is the entry point which takes in input (all input transaction files are dropped in to this directory),
error (erroneous records are wrtten to this directory) and summaryReport (summary reports are written to this directory) directories.
TransactionProcessFactoryHandler.java is called which returns the csv handler.
All common code that are not specific to file format but that are responsible for processing records are in AbstractTransactionProcessHandler.java
TransactionProcessCsvHandlerImpl reads from CSV file. They are then converted to RawTransaction which is then validated. If there are any errors then RawTransaction is written to error directory else they are converted to Transaction object.
FeeCalculatorServiceImpl.java is used to apply the intra day charge fee and nominal charge fee to the Transaction Object.
Summary report is then written to summaryReport directory
How to run the jar
Run mvn clean install.
Run the uber jar
2.1 Navigate to feeCalculator/target
2.2 Create three directories input, error and summaryReport
2.3 Run :- java -jar calculator-1.0-SNAPSHOT.jar input/ error/ summaryReport/
To check the log navigate to feeCalculator/target/log
Improvements if given more time
Write more Junit tests to have good code coverage. Use Mockito for mocking the services / objects
Modify the code to run handlers in parallel there by reducing the process time.
Add more logging that will help production support team during troubleshooting.
Present a better intuitive class diagram.
Assumptions
Validated only Transaction type and Priority flag as I know the valid values. I would like to validate all the fields if I know the possible range / allowed values for them.
If there is bad data I write that record to the error directory. There is a possibility that it has a pair and needs $10 to be charged as part of intraday transactions but I assume I do not have to write it's pair as well to error directory.
Supporting other file types
Create a new handler and extend AbstractTransactionProcessHandler
Re-use validate and calulate fee code in AbstractTransactionProcessHandler
Add new file type in FileType.java
Amend TransactionProcessFactoryHandler to return the new handler for the new file type.
Code used to read the records from new file type, writing to erroneous and summary report file should be in the new handler.