Giter Club home page Giter Club logo

library-community's Introduction

Book-Lending Library

Stories:

  • As a library user, I would like to be able to find books by my favourite author, so that I know if they are available in the library.
  • As a library user, I would like to be able to find books by title, so that I know if they are available in the library.
  • As a library user, I would like to be able to find books by ISBN, so that I know if they are available in the library.
  • As a library user, I would like to be able to borrow a book, so I can read it at home.
  • As the library owner, I would like to know how many books are being borrowed, so I can see how many are outstanding.
  • As a library user, I should be to prevented from borrowing reference books, so that they are always available.

Installation

When the application starts up the h2 database is initialized with the following data: data.sql

Setup

To run the application

mvn spring-boot:run

Test

To run the unit test:

mvn test

The follwing file contains the test test.sh Below are the contents:

INSERT INTO person (email,role) VALUES ('[email protected]','USER');
INSERT INTO person (email,role) VALUES ('[email protected]','OWNER');

INSERT INTO book (isbn,author,title,book_type) VALUES ('isbn1','kodjo','title1','REFERENCE');
INSERT INTO book (isbn,author,title,book_type) VALUES ('isbn5','kodjo','title2','NORMAL');
INSERT INTO book (isbn,author,title,book_type) VALUES ('isbn2','mark','title2','NORMAL');
INSERT INTO book (isbn,author,title,book_type) VALUES ('isbn3','chris','title3', 'NORMAL');
INSERT INTO book (isbn,author,title,book_type) VALUES ('isbn4','mathew','title4', 'NORMAL');

Output from running the tests

  library ./test.sh          
----- Finding books using the author kodjo ---
[{"isbn":"isbn1","author":"kodjo","title":"title1","availability":"AVAILABLE"},{"isbn":"isbn5","author":"kodjo","title":"title2","availability":"AVAILABLE"}]

----- Finding books using the author kodjo ---
[{"isbn":"isbn4","author":"mathew","title":"title4","availability":"AVAILABLE"}]

----- Finding books using isbn1  ---
[{"isbn":"isbn1","author":"kodjo","title":"title1","availability":"AVAILABLE"}]

----- Finding books using isbn2  ---
[{"isbn":"isbn2","author":"mark","title":"title2","availability":"AVAILABLE"}]

----- Finding books using title1  ---
[{"isbn":"isbn1","author":"kodjo","title":"title1","availability":"AVAILABLE"}]

----- Finding books using title2  ---
[{"isbn":"isbn5","author":"kodjo","title":"title2","availability":"AVAILABLE"},{"isbn":"isbn2","author":"mark","title":"title2","availability":"AVAILABLE"}]

----- Trying to borrow a reference book  ---
{"status":401,"message":"The book can not be borrowed it is only for reference purposes BorrowBook([email protected], isbn=isbn1)"}

----- Borrowing book with isbn2 for [email protected] ---
{"email":"[email protected]","books":[{"isbn":"isbn2","author":"mark","title":"title2","bookType":"NORMAL","borrower":{"email":"[email protected]","role":"USER"}}]}

----- Trying to borrow the same book again. ---
{"status":401,"message":"Some one has already borrowed this book BorrowBook([email protected], isbn=isbn2)"}

----- Borrowing another book with isbn3 for [email protected] ---
{"email":"[email protected]","books":[{"isbn":"isbn2","author":"mark","title":"title2","bookType":"NORMAL","borrower":{"email":"[email protected]","role":"USER"}},{"isbn":"isbn3","author":"chris","title":"title3","bookType":"NORMAL","borrower":{"email":"[email protected]","role":"USER"}}]}

----- Getting list books borrowed by the user [email protected]  ---
{"email":"[email protected]","books":[{"isbn":"isbn2","author":"mark","title":"title2","bookType":"NORMAL","borrower":{"email":"[email protected]","role":"USER"}},{"isbn":"isbn3","author":"chris","title":"title3","bookType":"NORMAL","borrower":{"email":"[email protected]","role":"USER"}}]}

----- Borrowing another book with isbn4 for user [email protected]  ---
{"email":"[email protected]","books":[{"isbn":"isbn4","author":"mathew","title":"title4","bookType":"NORMAL","borrower":{"email":"[email protected]","role":"OWNER"}}]}

----- Getting list books borrowed by the user [email protected]  ---
{"email":"[email protected]","books":[{"isbn":"isbn4","author":"mathew","title":"title4","bookType":"NORMAL","borrower":{"email":"[email protected]","role":"OWNER"}}]}

----- Getting list of all borrowed books. ---
[{"isbn":"isbn2","author":"mark","title":"title2","availability":"UNAVAILABLE"},{"isbn":"isbn3","author":"chris","title":"title3","availability":"UNAVAILABLE"},{"isbn":"isbn4","author":"mathew","title":"title4","availability":"UNAVAILABLE"}]
โžœ  library 

library-community's People

Contributors

kodjobaah avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.