Now that we've updated the code with the add
command and cleaned up the bookshelf-service
code, we can give it an end-to-end test.
To empty our memory-based inventory, it's enough to refresh the bookshelf-inventory-impl-mock
bundle by running the following:
g! refresh 6
Stoping Book Inventory Mock Impl
Starting Book Inventory Mock Impl
Let's add a couple of books to test the add command using the following:
g! add admin admin 9789079350018 "OSGi Service Platform, Core Specification, Release 4, Version 4.1" "OSGi Alliance" Reference 8
9789079350018
g!
g! add admin admin 9789079350025 "OSGi Service Platform, Service Compendium, Release 4, Version 4.1" "OSGi Alliance" Reference 6
9789079350025
Of course, the ratings have been assigned for the sake of the example. Both of these books are very good.
Searching for any author would return the following:
g! search admin admin author %
Reference: OSGi Service Platform, Service Compendium, Release 4, Version 4.1 from OSGi Alliance [6]
Reference: OSGi Service Platform, Core Specification, Release 4, Version 4.1 from OSGi Alliance [8]
Searching for books with a rating between 5 and 7:
g! search admin admin rating 5 7
Reference: OSGi Service Platform, Service Compendium, Release 4, Version 4.1 from OSGi Alliance [6]
The two commands, book:search
and book:add
, are enough for the tasks in this chapter, so we won't go any further in implementing others. However, that does not mean that you should not go ahead and add them on your own!
This is a good place for you to practice what you've learned by implementing some more commands. Here are a few suggestions:
book:get
command to retrieve the book information from an exact ISBN match book:remove
command to remove a book from the bookshelf based on its ISBN book:started
command to mark a book as just started, given its ISBN book:finished
command to mark a book as just finished, giving it a rating search
command to allow multiple simultaneous search criteriaThe goal is to allow a full management of your bookshelf through the command-line interface.