This application seeks to calculate the pricing of individual printing jobs for PaperCut. Print job data is read in through a CSV file and is then processed to display the pricing information for print job(s).
This app is lightweight and very extensible through liberal use of interfaces and a flexible rules engine.
The problem statement for this coding challenge is found under a file called problem.md
- Java 8 - lambdas, functional programming and streams
- Spring Boot
- Maven
- EasyRules - a java rules engine
- The program uses spring boot to quickly auto configure all the beans needed for the container.
- The init class is PrintJobConsoleRunner. It reads a print job csv file and maps them to a list of print job objects
- The print jobs are then sent to a pricing rules engine to determine the pricing algorithm for each print job
- When all algorithms have been determined, each print job will be executed against the algorithm that is stored against it
- Download and install JDK 1.8
- Set up Maven and point to a public repository for dependencies.
- Run a 'mvn clean install' on the pom to ensure you see a successful build
- Open the project in Eclipse as an existing maven application
- Ensure your Eclipse is on JRE8
- Run the Application class as a Java Application on Eclipse. It will output some pricing data to the console.
- Muck around with the Junit tests.
- The rules engine could be made more dynamic i.e. to allow rules to be modified without compiling again
- Better exception handing. The exceptions could be more detailed.
- Concurrency. A little bit more work can be done to ensure the app can handle multi-threading efficiently.
Total Cost of All Print JOBS+++++++++++++++++++++++
+++ $ 64.10
++++++++++++++
Breakdown of costs by job++++++++++++++++++++++++++
+++PrintJob {Id='0', Total Pages='25', Total Colour Pages='10', Paper Size='A4', Paper siding='SINGLE'}: $ 4.75
+++PrintJob {Id='1', Total Pages='55', Total Colour Pages='13', Paper Size='A4', Paper siding='DOUBLE'}: $ 6.80
+++PrintJob {Id='2', Total Pages='502', Total Colour Pages='22', Paper Size='A4', Paper siding='DOUBLE'}: $ 52.40
+++PrintJob {Id='3', Total Pages='1', Total Colour Pages='0', Paper Size='A4', Paper siding='SINGLE'}: $ 0.15