Skip to content

agutierrezreginodev/NovaBook_SkillsTest_JavaM5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NovaBook Library Management System

A layered Java 17 application with JOptionPane UI, built in NetBeans 27.
Implements JDBC repositories with a Singleton connection manager, secure password hashing, and custom exception handling.

Key Features

  • User Management: Multi-user system with Admin and Member roles
  • Security: BCrypt password hashing and role-based access control
  • Book Operations: Browse, search, and manage book inventory
  • Lending System: Borrow, return, and track book loans
  • Member Management: Registration and profile management
  • Admin Features: System configuration and advanced management options
  • Comprehensive Testing: JUnit 5 test suite with Mockito for service layer testing

Testing Infrastructure

The project includes comprehensive unit tests for the service layer using JUnit 5 and Mockito:

Service Layer Tests

  • BookServiceImplTest: Tests for book management operations

    • Book addition with ISBN validation
    • Duplicate ISBN checks
    • Stock management validation
    • Book search functionality
  • LendingServiceImplTest: Tests for lending operations

    • Book lending process
    • Return book functionality
    • Lending limits enforcement
    • Due date management
  • MemberServiceImplTest: Tests for member management

    • Member registration
    • Role validation
    • Member search functionality
    • Active/inactive member management

Test Coverage

  • Service layer business logic
  • Input validation
  • Error handling
  • Business rules enforcement
  • Edge cases

Testing Tools

  • JUnit 5 for test framework
  • Mockito for dependency mocking
  • AssertJ for fluent assertions

🧩 Project Structure

com.codeup.novabook
β”œβ”€ domain/           # Domain models (POJOs)
β”‚  β”œβ”€ Book.java
β”‚  β”œβ”€ Member.java
β”‚  β”œβ”€ Lending.java
β”‚  └─ User.java
β”œβ”€ exceptions/       # Custom exceptions
β”‚  └─ DatabaseException.java
β”œβ”€ repository/       # Repository interfaces
β”‚  β”œβ”€ BookRepository.java
β”‚  β”œβ”€ MemberRepository.java
β”‚  β”œβ”€ LendingRepository.java
β”‚  └─ UserRepository.java
β”œβ”€ repository/jdbc/  # JDBC implementations
β”‚  β”œβ”€ BookRepositoryJDBC.java
β”‚  β”œβ”€ MemberRepositoryJDBC.java
β”‚  β”œβ”€ LendingRepositoryJDBC.java
β”‚  └─ UserRepositoryJDBC.java
β”œβ”€ service/          # Service interfaces
β”‚  β”œβ”€ BookService.java
β”‚  β”œβ”€ MemberService.java
β”‚  β”œβ”€ LendingService.java
β”‚  └─ UserService.java
β”œβ”€ service/impl/     # Service implementations
β”‚  β”œβ”€ BookServiceImpl.java
β”‚  β”œβ”€ MemberServiceImpl.java
β”‚  β”œβ”€ LendingServiceImpl.java
β”‚  └─ UserServiceImpl.java
β”œβ”€ connection/       # Database connection (Singleton)
β”‚  β”œβ”€ ConnectionFactory.java
β”‚  └─ TestConnection.java
β”œβ”€ infra/config/     # Configuration
β”‚  └─ AppConfig.java
β”œβ”€ ui/               # JOptionPane UI layer
β”‚  └─ NovaBookUI.java
└─ NovaBook.java     # Main application class

βš™οΈ Requirements

  • JDK: 17
  • IDE: NetBeans 27 (recommended)
  • Database: MySQL 8.0+
  • Maven: for dependency management and build
  • MySQL Connector/J: 8.0+

πŸš€ Run the Application

1. Database Setup

First, create the database and tables:

-- Run the SQL script in src/main/java/com/codeup/novabook/db/NovaBookDBSchema.sql
CREATE DATABASE IF NOT EXISTS novabook_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE novabook_db;

-- The script will create all necessary tables and user

2. Configuration

Configure the database connection in src/main/resources/application.properties:

db.vendor=mysql
db.host=localhost
db.port=3306
db.name=novabook_db
db.user=root
db.password=Qwe.123*
db.useSSL=false

3. Run Tests

The project includes a comprehensive test suite. You can run the tests using Maven:

# Run all tests
mvn test

# Run specific test class
mvn test -Dtest=BookServiceImplTest
mvn test -Dtest=LendingServiceImplTest
mvn test -Dtest=MemberServiceImplTest

Test results will be available in the target/surefire-reports directory.

4. Build and Run

Using Maven:

mvn clean compile
mvn exec:java -Dexec.mainClass="com.codeup.novabook.NovaBook"

Using NetBeans:

  1. Open the project in NetBeans 27
  2. Right-click on the project β†’ Run Project
  3. Or run the NovaBook main class directly

Using Command Line:

# Compile
javac -cp "target/classes:lib/*" src/main/java/com/codeup/novabook/*.java

# Run
java -cp "target/classes:lib/*" com.codeup.novabook.NovaBook

🎯 Features

Book Management

  • βœ… Add new books with ISBN validation
  • βœ… Search books by title, author, or availability
  • βœ… Update book information
  • βœ… Remove books from library
  • βœ… Stock management

Member Management

  • βœ… Register new members (Regular/Premium)
  • βœ… Search members by name
  • βœ… Update member information
  • βœ… Deactivate/activate members
  • βœ… Role management

Lending Management

  • βœ… Lend books to members
  • βœ… Return books
  • βœ… Track active lendings
  • βœ… View overdue lendings
  • βœ… Extend lending periods
  • βœ… Automatic fine calculation

User Management

  • βœ… Register system users (User/Admin)
  • βœ… User authentication
  • βœ… Update user profiles
  • βœ… Deactivate users
  • βœ… Role-based access control

Reports & Statistics

  • βœ… Library statistics
  • βœ… Member statistics
  • βœ… Lending statistics
  • βœ… Overdue tracking

🧱 Design Patterns Used

1. Layered Architecture

  • Domain Layer: Entity classes (Book, Member, Lending, User)
  • Repository Layer: Data access interfaces and JDBC implementations
  • Service Layer: Business logic interfaces and implementations
  • UI Layer: JOptionPane-based user interface

2. Singleton Pattern

  • ConnectionFactory ensures only one database connection instance
  • Thread-safe implementation with double-checked locking

3. Mock Objects Pattern (Testing)

  • Using Mockito for dependency injection in tests
  • Isolation of system under test
  • Controlled testing environment

4. Repository Pattern

  • Abstracts data access operations
  • Easy to switch between different data sources
  • Clean separation of concerns

4. Custom Exception Handling

  • DatabaseException for database-related errors
  • Proper error propagation and handling

πŸ”§ Technical Details

Database Schema

  • Users Table: System users with roles and access levels
  • Book Table: Library books with ISBN, title, author, and stock
  • Member Table: Library members with roles and status
  • Lending Table: Book lending transactions with due dates

Key Components

  • ConnectionFactory: Singleton database connection manager
  • AppConfig: Configuration management using Properties
  • Repository Interfaces: Define data access contracts
  • Service Layer: Business logic and validation
  • UI Layer: User-friendly JOptionPane dialogs

Validation Rules

  • Email format validation
  • ISBN format validation
  • Stock cannot be negative
  • Member/user name validation
  • Business rule enforcement (max books per member, etc.)

πŸ“ Usage Examples

Adding a Book

  1. Select "Book Management" β†’ "Add Book"
  2. Enter ISBN, title, author, and stock
  3. System validates ISBN format and saves book

Lending a Book

  1. Select "Lending Management" β†’ "Lend Book"
  2. Enter member ID, book ID, and lending days
  3. System checks availability and creates lending record

Viewing Statistics

  1. Select "Reports" β†’ "Library Statistics"
  2. View total books, members, users, and lendings

πŸ› Troubleshooting

Database Connection Issues

  • Verify MySQL is running
  • Check database credentials in app.props
  • Ensure novabook_db database exists
  • Run the schema script to create tables

Compilation Issues

  • Ensure JDK 17 is installed
  • Check MySQL Connector/J is in classpath
  • Verify all dependencies are available

Runtime Issues

  • Check database connection
  • Verify user permissions
  • Review error messages in console

πŸ“˜ Author

Developed by AdriΓ‘n GutiΓ©rrez


οΏ½ Recent Updates

Security Enhancements (October 2025)

  • Implemented BCrypt password hashing with work factor 12
  • Added salted password storage
  • Improved password verification process

System Improvements

  • Fixed loan management functionality
  • Updated method naming for consistency (lending β†’ loan)
  • Improved user session handling
  • Enhanced input validation
  • Fixed date handling in database operations

Bug Fixes

  • Resolved date casting issues in lending operations
  • Fixed user session management
  • Corrected method name inconsistencies
  • Improved error handling and user feedback

οΏ½πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages