This software manages live orders in a system and provides access to a summary of orders netted by price;
It uses Concurrent Skip Lists in order to avoid explicit management of Threadsafety.
There is an assumption that orders are added/cancelled more often than report summaries are requested;
if this turns out to be a bad assumption, we could easily look at caching a generated report until new orders render it stale.
The following functionality is supported by exercise.controller.LiveOrderBoardImpl
An Order must be created using the exercise.model.Order.create
factory method.
Once created it can be added to the Live Board via the register
method.
a boolean is returned to indicate whether we already had that order registered
pass the orders Id into the cancel
method and the order will be remove from
the live list.
when call the summarize
method on the LiveOrderBoard a 'exercise.model.OrdersSummary'
is returned.
You can ask it to give you Netted orders, sorted by price as in the specification,
It also has a buildReport
method that will provide the summmary as a String.
you can run the test using Maven
mvn test
from the same directory as the pom.xml
When I do this I see the output
ben@vorpal-XPS-15-9560:~/dev/vorpalsystems/silverbars$ mvn test ... trimmed for brevity [INFO] ------------------------< exercise:silverbars >------------------------- [INFO] Building silverbars 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- ... trimmed for brevity [INFO] [INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] Running exercise.controller.LiveOrderBoardImplTest [INFO] Tests run: 22, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.143 s - in exercise.controller.LiveOrderBoardImplTest [INFO] [INFO] Results: [INFO] [INFO] Tests run: 22, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.544 s [INFO] Finished at: 2020-02-19T17:06:31Z [INFO] ------------------------------------------------------------------------