Trying the commands

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]

It behaves as expected.

Go ahead hero- implementing the other commands

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:

  • Add a book:get command to retrieve the book information from an exact ISBN match
  • Add a book:remove command to remove a book from the bookshelf based on its ISBN
  • Add a book:started command to mark a book as just started, given its ISBN
  • Add a book:finished command to mark a book as just finished, giving it a rating
  • Improve the search command to allow multiple simultaneous search criteria

The goal is to allow a full management of your bookshelf through the command-line interface.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.139.168