This project is a simple Library Management System that allows users to perform basic operations such as adding books, borrowing books, returning books, and viewing available books. The project is implemented using Java, with a focus on clean code, TDD (Test-Driven Development), and proper usage of Git for version control.
- Objective
- Technologies Used
- Requirements
- Installation Process
- Development Guidelines
- Running Tests
- Features
- Project Structure
- Key Test Cases
- Notes
- Test Coverage
- Programming Language: Java
- Testing Framework: JUnit 5
- Build Tool: Maven
- Version Control: Git
- Java JDK: Make sure you have Java Development Kit (JDK) installed on your system.
- JUnit 5: Ensure JUnit 5 is set up for running the tests.
- IDE: You can use any IDE like IntelliJ IDEA, Eclipse, or VS Code for development.
Follow these steps to set up the Library Management System on your local machine:
- Clone the Repository:
git clone https://github.com/Vishal-Piprotar/library-management-system.git cd library-management-system
- Install Java JDK: Make sure you have Java Development Kit (JDK) installed. Download it from the Oracle website or use your system's package manager
java -version
- Install Maven: Download and install Maven from the official website or use your system's package manager.
mvn -version
- Set Up JUnit 5: Ensure JUnit 5 is included in the pom.xml file under the section:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
- Import Project into Your IDE:
### IntelliJ IDEA
1. Open IntelliJ IDEA and navigate to `File` > `New` > `Project from Existing Sources...`
2. Select the `library-management-system` folder from your local machine.
3. Choose "Import project from external model" and select `Maven`.
4. Click `Next` and follow the prompts to complete the import process.
- Build the Project:
mvn clean install
- Run Tests:
mvn test
- Test-Driven Development (TDD): Follow the TDD process by writing tests before implementing features. Aim for high test coverage.
- Clean Code: Write clean, maintainable, and well-documented code. Follow SOLID principles and other best practices.
- Git Usage: Commit frequently with meaningful messages. Use branches for new features and merge them after review.
The project uses JUnit 5 for unit testing. To run the tests, make sure you have JUnit 5 in your classpath and execute the test classes.
- Add Books: Users can add new books to the library with a unique identifier (ISBN), title, author, and publication year.
- Borrow Books: Users can borrow books if they are available in the library. If a book is not available or already borrowed, an error is raised.
- Return Books: Users can return borrowed books, and the system will update the book's availability.
- View Available Books: Users can view a list of all available books in the library.
The project consists of the following main classes:
Library
: Manages the collection of books and operations like adding, borrowing, and returning books.Book
: Represents a book with properties like ISBN, title, author, and publication year.
Test classes:
LibraryTest
: Contains unit tests for theLibrary
class.BookTest
: Contains unit tests for theBook
class.
-
Adding books
- Adding a valid book
- Attempting to add a null book
- Attempting to add a book with a duplicate ISBN
-
Borrowing books
- Borrowing an available book
- Attempting to borrow an already borrowed book
- Attempting to borrow a non-existent book
- Attempting to borrow with null or empty ISBNs
-
Returning books
- Returning a borrowed book
- Attempting to return a book that was never borrowed
- Attempting to return a book with null or empty ISBNs
-
Viewing available books
- Viewing books after adding them
- Viewing books after borrowing
- Viewing books after returning
-
ISBN validation
- ISBN should not be null
- ISBN should not be empty
-
Title validation
- Title should not be null
- Title should not be empty
-
Author validation
- Author should not be null
- Author should not be empty
-
Publication year validation
- Publication year should not be zero
- Publication year should not be negative
- The system uses ISBNs to uniquely identify books.
- Error handling is implemented for various edge cases and invalid inputs.
- The
viewAvailableBooks()
method in theLibrary
class prints the available books to the console.