An open API service indexing awesome lists of open source software.

https://github.com/fcbento/java-junit-oop-study-case

Java console-based library management system with user, book, and loan management, featuring unit and E2E tests with high coverage
https://github.com/fcbento/java-junit-oop-study-case

jacoco java junit5 maven mockito

Last synced: 29 days ago
JSON representation

Java console-based library management system with user, book, and loan management, featuring unit and E2E tests with high coverage

Awesome Lists containing this project

README

          

# Library Management System

![Coverage](https://img.shields.io/badge/Coverage-93%25-brightgreen)

## Description

This project is a smalll **library management system** built in Java. It is built to practice some of the oop concepts as it's been kind of a while I don't actually pay due attention to them. Like both polymorphism and abstraction for example. There's definitely though a lot to build in this project yet as I covered only the basics for now. It's been fun playing a little with ``` Scanner(System.in)``` and ```System.out.println()```again. It felt a lot like university.

Current features are:

- Create users
- Loan books
- See loaned books
- List available books

The project uses model, repository, service, controller, and view layers for a more clean structure.

---

## Project Structure

```text
src/main/java/com/library
├── controller # System controllers
├── enums # Enums used in the system
├── model # Data models
├── repository # Data storage
├── service # Business logic
├── util # Utilities (e.g., BookGenerator to display random books)
└── view # Console interfaces
```

```text
src/test/java/com/library
├── controller # Controller unit tests
├── repository # Repository unit tests
├── service # Service unit tests
└── view # Console integration e2e
```

---

## How to Run

1. Clone the repository and run the project:

```bash
git clone https://github.com/fcbento/java-junit-oop-study-case.git

cd java-junit-oop-study-case

mvn compile

mvn exec:java -Dexec.mainClass="src.main.java.com.library.Main"
```
2. Run tests
```
mvn test
```

## Code coverage

| Package / Element | Instructions | Branches | Lines | Methods | Classes |
| ------------------------------------ | ------------ | -------- | ----- | ------- | ------- |
| src.main.java.com.library.model | 60% | 0% | 44 | 23 | 3 |
| src.main.java.com.library | 95% | 77% | 38 | 7 | 1 |
| src.main.java.com.library.view | 98% | 100% | 75 | 12 | 4 |
| src.main.java.com.library.util | 98% | 100% | 13 | 3 | 1 |
| src.main.java.com.library.repository | 100% | 100% | 29 | 13 | 3 |
| src.main.java.com.library.controller | 100% | n/a | 16 | 8 | 3 |
| src.main.java.com.library.service | 100% | n/a | 16 | 9 | 3 |
| src.main.java.com.library.enums | 100% | n/a | 5 | 1 | 1 |

![Overall coverage](https://img.shields.io/badge/Overall-93%25-brightgreen)
![Main business layers](https://img.shields.io/badge/Main-100%25-brightgreen)

## Technologies

- Java 17
- JUnit 5
- Mockito
- Maven
- JaCoCo

## Some notes

- Views were refactored to allow Scanner dependency injection, making automated testing possible.

- Data is stored in memory; there is no database persistence but maybe it wouldn't be a bad idea to plug the repository layer to an actual database.

- This project is only intended as a learning exercise for best practices, OOP, and mostly test coverage.

## Author


contrib.rocks image

## Contact

[![linkedin](https://skillicons.dev/icons?i=linkedin)](https://linkedin.com/in/felipe-bento)
[![discord](https://skillicons.dev/icons?i=discord)](https://discordapp.com/users/413141379074490369)
[![gmail](https://skillicons.dev/icons?i=gmail)](mailto:felipe.16costa@gmail.com)