From 630575d499bcc3fe2ce2083d2b4db8275a7688ef Mon Sep 17 00:00:00 2001 From: Anderson Porto Date: Thu, 10 Oct 2024 23:28:29 -0300 Subject: [PATCH] Refactor: project struct --- .../ClientController.java | 13 +++++------ .../{dto => client}/ClientDto.java | 2 +- .../{entities => client}/ClientEntity.java | 4 +++- .../{mapper => client}/ClientMapper.java | 4 +--- .../ClientRepository.java | 3 +-- .../{service => client}/ClientService.java | 14 ++++------- .../common/aspect/LoggerAspect.java | 11 +++++++++ .../{ => common}/entities/AddressEntity.java | 2 +- .../exceptions/ClientDuplicatedException.java | 2 +- .../exceptions/ClientNotFoundException.java | 2 +- .../exceptions/LoanNotFoundException.java | 2 +- .../exceptions/MaxLoanException.java | 2 +- .../handler/GlobalExceptionHandler.java | 10 ++++---- .../{ => common}/types/Membership.java | 2 +- .../{controller => loan}/LoanController.java | 15 ++++++------ .../emprestimoapi/{dto => loan}/LoanDto.java | 4 ++-- .../{entities => loan}/LoanEntity.java | 5 ++-- .../{mapper => loan}/LoanMapper.java | 4 +--- .../LoanRepository.java | 3 +-- .../{service => loan}/LoanService.java | 18 ++++++--------- src/main/resources/application.properties | 1 + .../EmprestimoApiApplicationTests.java | 4 ++-- .../service/ClientServiceTest.java | 13 ++++++----- .../service/LoanServiceTest.java | 23 ++++++++----------- .../emprestimoapi/types/MembershipTest.java | 1 + 25 files changed, 81 insertions(+), 83 deletions(-) rename src/main/java/dev/anderson/emprestimoapi/{controller => client}/ClientController.java (79%) rename src/main/java/dev/anderson/emprestimoapi/{dto => client}/ClientDto.java (96%) rename src/main/java/dev/anderson/emprestimoapi/{entities => client}/ClientEntity.java (92%) rename src/main/java/dev/anderson/emprestimoapi/{mapper => client}/ClientMapper.java (90%) rename src/main/java/dev/anderson/emprestimoapi/{repositories => client}/ClientRepository.java (67%) rename src/main/java/dev/anderson/emprestimoapi/{service => client}/ClientService.java (85%) create mode 100644 src/main/java/dev/anderson/emprestimoapi/common/aspect/LoggerAspect.java rename src/main/java/dev/anderson/emprestimoapi/{ => common}/entities/AddressEntity.java (93%) rename src/main/java/dev/anderson/emprestimoapi/{ => common}/exceptions/ClientDuplicatedException.java (85%) rename src/main/java/dev/anderson/emprestimoapi/{ => common}/exceptions/ClientNotFoundException.java (85%) rename src/main/java/dev/anderson/emprestimoapi/{ => common}/exceptions/LoanNotFoundException.java (87%) rename src/main/java/dev/anderson/emprestimoapi/{ => common}/exceptions/MaxLoanException.java (85%) rename src/main/java/dev/anderson/emprestimoapi/{exceptions => common}/handler/GlobalExceptionHandler.java (88%) rename src/main/java/dev/anderson/emprestimoapi/{ => common}/types/Membership.java (97%) rename src/main/java/dev/anderson/emprestimoapi/{controller => loan}/LoanController.java (73%) rename src/main/java/dev/anderson/emprestimoapi/{dto => loan}/LoanDto.java (92%) rename src/main/java/dev/anderson/emprestimoapi/{entities => loan}/LoanEntity.java (84%) rename src/main/java/dev/anderson/emprestimoapi/{mapper => loan}/LoanMapper.java (81%) rename src/main/java/dev/anderson/emprestimoapi/{repositories => loan}/LoanRepository.java (66%) rename src/main/java/dev/anderson/emprestimoapi/{service => loan}/LoanService.java (83%) diff --git a/src/main/java/dev/anderson/emprestimoapi/controller/ClientController.java b/src/main/java/dev/anderson/emprestimoapi/client/ClientController.java similarity index 79% rename from src/main/java/dev/anderson/emprestimoapi/controller/ClientController.java rename to src/main/java/dev/anderson/emprestimoapi/client/ClientController.java index 6e83782..13d5f4c 100644 --- a/src/main/java/dev/anderson/emprestimoapi/controller/ClientController.java +++ b/src/main/java/dev/anderson/emprestimoapi/client/ClientController.java @@ -1,9 +1,8 @@ -package dev.anderson.emprestimoapi.controller; +package dev.anderson.emprestimoapi.client; -import dev.anderson.emprestimoapi.dto.ClientDto; -import dev.anderson.emprestimoapi.exceptions.ClientDuplicatedException; -import dev.anderson.emprestimoapi.exceptions.ClientNotFoundException; -import dev.anderson.emprestimoapi.service.ClientService; +import dev.anderson.emprestimoapi.common.exceptions.ClientDuplicatedException; +import dev.anderson.emprestimoapi.common.exceptions.ClientNotFoundException; +import dev.anderson.emprestimoapi.common.handler.GlobalExceptionHandler; import lombok.AllArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; @@ -13,9 +12,9 @@ @RestController @CrossOrigin(origins = "*") -@RequestMapping("/api/v1/clientes") +@RequestMapping("/clientes") @AllArgsConstructor -public class ClientController { +public class ClientController extends GlobalExceptionHandler { private ClientService clientService; diff --git a/src/main/java/dev/anderson/emprestimoapi/dto/ClientDto.java b/src/main/java/dev/anderson/emprestimoapi/client/ClientDto.java similarity index 96% rename from src/main/java/dev/anderson/emprestimoapi/dto/ClientDto.java rename to src/main/java/dev/anderson/emprestimoapi/client/ClientDto.java index a0590c6..29a6952 100644 --- a/src/main/java/dev/anderson/emprestimoapi/dto/ClientDto.java +++ b/src/main/java/dev/anderson/emprestimoapi/client/ClientDto.java @@ -1,4 +1,4 @@ -package dev.anderson.emprestimoapi.dto; +package dev.anderson.emprestimoapi.client; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; diff --git a/src/main/java/dev/anderson/emprestimoapi/entities/ClientEntity.java b/src/main/java/dev/anderson/emprestimoapi/client/ClientEntity.java similarity index 92% rename from src/main/java/dev/anderson/emprestimoapi/entities/ClientEntity.java rename to src/main/java/dev/anderson/emprestimoapi/client/ClientEntity.java index df3b9b0..aeb6658 100644 --- a/src/main/java/dev/anderson/emprestimoapi/entities/ClientEntity.java +++ b/src/main/java/dev/anderson/emprestimoapi/client/ClientEntity.java @@ -1,5 +1,7 @@ -package dev.anderson.emprestimoapi.entities; +package dev.anderson.emprestimoapi.client; +import dev.anderson.emprestimoapi.common.entities.AddressEntity; +import dev.anderson.emprestimoapi.loan.LoanEntity; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/dev/anderson/emprestimoapi/mapper/ClientMapper.java b/src/main/java/dev/anderson/emprestimoapi/client/ClientMapper.java similarity index 90% rename from src/main/java/dev/anderson/emprestimoapi/mapper/ClientMapper.java rename to src/main/java/dev/anderson/emprestimoapi/client/ClientMapper.java index e8baa77..879d686 100644 --- a/src/main/java/dev/anderson/emprestimoapi/mapper/ClientMapper.java +++ b/src/main/java/dev/anderson/emprestimoapi/client/ClientMapper.java @@ -1,7 +1,5 @@ -package dev.anderson.emprestimoapi.mapper; +package dev.anderson.emprestimoapi.client; -import dev.anderson.emprestimoapi.dto.ClientDto; -import dev.anderson.emprestimoapi.entities.ClientEntity; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.MappingTarget; diff --git a/src/main/java/dev/anderson/emprestimoapi/repositories/ClientRepository.java b/src/main/java/dev/anderson/emprestimoapi/client/ClientRepository.java similarity index 67% rename from src/main/java/dev/anderson/emprestimoapi/repositories/ClientRepository.java rename to src/main/java/dev/anderson/emprestimoapi/client/ClientRepository.java index 3436139..23b9c01 100644 --- a/src/main/java/dev/anderson/emprestimoapi/repositories/ClientRepository.java +++ b/src/main/java/dev/anderson/emprestimoapi/client/ClientRepository.java @@ -1,6 +1,5 @@ -package dev.anderson.emprestimoapi.repositories; +package dev.anderson.emprestimoapi.client; -import dev.anderson.emprestimoapi.entities.ClientEntity; import org.springframework.data.jpa.repository.JpaRepository; public interface ClientRepository extends JpaRepository { diff --git a/src/main/java/dev/anderson/emprestimoapi/service/ClientService.java b/src/main/java/dev/anderson/emprestimoapi/client/ClientService.java similarity index 85% rename from src/main/java/dev/anderson/emprestimoapi/service/ClientService.java rename to src/main/java/dev/anderson/emprestimoapi/client/ClientService.java index dd7730f..fbf304a 100644 --- a/src/main/java/dev/anderson/emprestimoapi/service/ClientService.java +++ b/src/main/java/dev/anderson/emprestimoapi/client/ClientService.java @@ -1,12 +1,8 @@ -package dev.anderson.emprestimoapi.service; - -import dev.anderson.emprestimoapi.dto.ClientDto; -import dev.anderson.emprestimoapi.entities.ClientEntity; -import dev.anderson.emprestimoapi.entities.LoanEntity; -import dev.anderson.emprestimoapi.exceptions.ClientDuplicatedException; -import dev.anderson.emprestimoapi.exceptions.ClientNotFoundException; -import dev.anderson.emprestimoapi.mapper.ClientMapper; -import dev.anderson.emprestimoapi.repositories.ClientRepository; +package dev.anderson.emprestimoapi.client; + +import dev.anderson.emprestimoapi.loan.LoanEntity; +import dev.anderson.emprestimoapi.common.exceptions.ClientDuplicatedException; +import dev.anderson.emprestimoapi.common.exceptions.ClientNotFoundException; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; diff --git a/src/main/java/dev/anderson/emprestimoapi/common/aspect/LoggerAspect.java b/src/main/java/dev/anderson/emprestimoapi/common/aspect/LoggerAspect.java new file mode 100644 index 0000000..28abb00 --- /dev/null +++ b/src/main/java/dev/anderson/emprestimoapi/common/aspect/LoggerAspect.java @@ -0,0 +1,11 @@ +package dev.anderson.emprestimoapi.common.aspect; + +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; + +@Aspect +@Component +public class LoggerAspect { + + +} diff --git a/src/main/java/dev/anderson/emprestimoapi/entities/AddressEntity.java b/src/main/java/dev/anderson/emprestimoapi/common/entities/AddressEntity.java similarity index 93% rename from src/main/java/dev/anderson/emprestimoapi/entities/AddressEntity.java rename to src/main/java/dev/anderson/emprestimoapi/common/entities/AddressEntity.java index 728c3b2..bf7c04c 100644 --- a/src/main/java/dev/anderson/emprestimoapi/entities/AddressEntity.java +++ b/src/main/java/dev/anderson/emprestimoapi/common/entities/AddressEntity.java @@ -1,4 +1,4 @@ -package dev.anderson.emprestimoapi.entities; +package dev.anderson.emprestimoapi.common.entities; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/dev/anderson/emprestimoapi/exceptions/ClientDuplicatedException.java b/src/main/java/dev/anderson/emprestimoapi/common/exceptions/ClientDuplicatedException.java similarity index 85% rename from src/main/java/dev/anderson/emprestimoapi/exceptions/ClientDuplicatedException.java rename to src/main/java/dev/anderson/emprestimoapi/common/exceptions/ClientDuplicatedException.java index 3d06b3d..8f64b9f 100644 --- a/src/main/java/dev/anderson/emprestimoapi/exceptions/ClientDuplicatedException.java +++ b/src/main/java/dev/anderson/emprestimoapi/common/exceptions/ClientDuplicatedException.java @@ -1,4 +1,4 @@ -package dev.anderson.emprestimoapi.exceptions; +package dev.anderson.emprestimoapi.common.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/src/main/java/dev/anderson/emprestimoapi/exceptions/ClientNotFoundException.java b/src/main/java/dev/anderson/emprestimoapi/common/exceptions/ClientNotFoundException.java similarity index 85% rename from src/main/java/dev/anderson/emprestimoapi/exceptions/ClientNotFoundException.java rename to src/main/java/dev/anderson/emprestimoapi/common/exceptions/ClientNotFoundException.java index 643e68f..b2c340e 100644 --- a/src/main/java/dev/anderson/emprestimoapi/exceptions/ClientNotFoundException.java +++ b/src/main/java/dev/anderson/emprestimoapi/common/exceptions/ClientNotFoundException.java @@ -1,4 +1,4 @@ -package dev.anderson.emprestimoapi.exceptions; +package dev.anderson.emprestimoapi.common.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/src/main/java/dev/anderson/emprestimoapi/exceptions/LoanNotFoundException.java b/src/main/java/dev/anderson/emprestimoapi/common/exceptions/LoanNotFoundException.java similarity index 87% rename from src/main/java/dev/anderson/emprestimoapi/exceptions/LoanNotFoundException.java rename to src/main/java/dev/anderson/emprestimoapi/common/exceptions/LoanNotFoundException.java index 16a2b03..722e0f9 100644 --- a/src/main/java/dev/anderson/emprestimoapi/exceptions/LoanNotFoundException.java +++ b/src/main/java/dev/anderson/emprestimoapi/common/exceptions/LoanNotFoundException.java @@ -1,4 +1,4 @@ -package dev.anderson.emprestimoapi.exceptions; +package dev.anderson.emprestimoapi.common.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/src/main/java/dev/anderson/emprestimoapi/exceptions/MaxLoanException.java b/src/main/java/dev/anderson/emprestimoapi/common/exceptions/MaxLoanException.java similarity index 85% rename from src/main/java/dev/anderson/emprestimoapi/exceptions/MaxLoanException.java rename to src/main/java/dev/anderson/emprestimoapi/common/exceptions/MaxLoanException.java index bf1c62c..5e061c4 100644 --- a/src/main/java/dev/anderson/emprestimoapi/exceptions/MaxLoanException.java +++ b/src/main/java/dev/anderson/emprestimoapi/common/exceptions/MaxLoanException.java @@ -1,4 +1,4 @@ -package dev.anderson.emprestimoapi.exceptions; +package dev.anderson.emprestimoapi.common.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/src/main/java/dev/anderson/emprestimoapi/exceptions/handler/GlobalExceptionHandler.java b/src/main/java/dev/anderson/emprestimoapi/common/handler/GlobalExceptionHandler.java similarity index 88% rename from src/main/java/dev/anderson/emprestimoapi/exceptions/handler/GlobalExceptionHandler.java rename to src/main/java/dev/anderson/emprestimoapi/common/handler/GlobalExceptionHandler.java index c8e4b03..b4fb972 100644 --- a/src/main/java/dev/anderson/emprestimoapi/exceptions/handler/GlobalExceptionHandler.java +++ b/src/main/java/dev/anderson/emprestimoapi/common/handler/GlobalExceptionHandler.java @@ -1,9 +1,9 @@ -package dev.anderson.emprestimoapi.exceptions.handler; +package dev.anderson.emprestimoapi.common.handler; -import dev.anderson.emprestimoapi.exceptions.ClientDuplicatedException; -import dev.anderson.emprestimoapi.exceptions.ClientNotFoundException; -import dev.anderson.emprestimoapi.exceptions.LoanNotFoundException; -import dev.anderson.emprestimoapi.exceptions.MaxLoanException; +import dev.anderson.emprestimoapi.common.exceptions.ClientDuplicatedException; +import dev.anderson.emprestimoapi.common.exceptions.ClientNotFoundException; +import dev.anderson.emprestimoapi.common.exceptions.LoanNotFoundException; +import dev.anderson.emprestimoapi.common.exceptions.MaxLoanException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.validation.FieldError; diff --git a/src/main/java/dev/anderson/emprestimoapi/types/Membership.java b/src/main/java/dev/anderson/emprestimoapi/common/types/Membership.java similarity index 97% rename from src/main/java/dev/anderson/emprestimoapi/types/Membership.java rename to src/main/java/dev/anderson/emprestimoapi/common/types/Membership.java index f8d8e1d..174829b 100644 --- a/src/main/java/dev/anderson/emprestimoapi/types/Membership.java +++ b/src/main/java/dev/anderson/emprestimoapi/common/types/Membership.java @@ -1,4 +1,4 @@ -package dev.anderson.emprestimoapi.types; +package dev.anderson.emprestimoapi.common.types; import com.fasterxml.jackson.annotation.JsonCreator; diff --git a/src/main/java/dev/anderson/emprestimoapi/controller/LoanController.java b/src/main/java/dev/anderson/emprestimoapi/loan/LoanController.java similarity index 73% rename from src/main/java/dev/anderson/emprestimoapi/controller/LoanController.java rename to src/main/java/dev/anderson/emprestimoapi/loan/LoanController.java index d5af544..942e4ba 100644 --- a/src/main/java/dev/anderson/emprestimoapi/controller/LoanController.java +++ b/src/main/java/dev/anderson/emprestimoapi/loan/LoanController.java @@ -1,10 +1,9 @@ -package dev.anderson.emprestimoapi.controller; +package dev.anderson.emprestimoapi.loan; -import dev.anderson.emprestimoapi.dto.LoanDto; -import dev.anderson.emprestimoapi.exceptions.ClientNotFoundException; -import dev.anderson.emprestimoapi.exceptions.LoanNotFoundException; -import dev.anderson.emprestimoapi.exceptions.MaxLoanException; -import dev.anderson.emprestimoapi.service.LoanService; +import dev.anderson.emprestimoapi.common.exceptions.ClientNotFoundException; +import dev.anderson.emprestimoapi.common.exceptions.LoanNotFoundException; +import dev.anderson.emprestimoapi.common.exceptions.MaxLoanException; +import dev.anderson.emprestimoapi.common.handler.GlobalExceptionHandler; import lombok.AllArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; @@ -14,9 +13,9 @@ @RestController @CrossOrigin(origins = "*") -@RequestMapping("/api/v1/clientes/{cpf}/emprestimos") +@RequestMapping("/clientes/{cpf}/emprestimos") @AllArgsConstructor -public class LoanController { +public class LoanController extends GlobalExceptionHandler { private LoanService loanService; diff --git a/src/main/java/dev/anderson/emprestimoapi/dto/LoanDto.java b/src/main/java/dev/anderson/emprestimoapi/loan/LoanDto.java similarity index 92% rename from src/main/java/dev/anderson/emprestimoapi/dto/LoanDto.java rename to src/main/java/dev/anderson/emprestimoapi/loan/LoanDto.java index 76ba474..c873720 100644 --- a/src/main/java/dev/anderson/emprestimoapi/dto/LoanDto.java +++ b/src/main/java/dev/anderson/emprestimoapi/loan/LoanDto.java @@ -1,7 +1,7 @@ -package dev.anderson.emprestimoapi.dto; +package dev.anderson.emprestimoapi.loan; import com.fasterxml.jackson.annotation.JsonProperty; -import dev.anderson.emprestimoapi.types.Membership; +import dev.anderson.emprestimoapi.common.types.Membership; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; diff --git a/src/main/java/dev/anderson/emprestimoapi/entities/LoanEntity.java b/src/main/java/dev/anderson/emprestimoapi/loan/LoanEntity.java similarity index 84% rename from src/main/java/dev/anderson/emprestimoapi/entities/LoanEntity.java rename to src/main/java/dev/anderson/emprestimoapi/loan/LoanEntity.java index d63b1c7..267630b 100644 --- a/src/main/java/dev/anderson/emprestimoapi/entities/LoanEntity.java +++ b/src/main/java/dev/anderson/emprestimoapi/loan/LoanEntity.java @@ -1,6 +1,7 @@ -package dev.anderson.emprestimoapi.entities; +package dev.anderson.emprestimoapi.loan; -import dev.anderson.emprestimoapi.types.Membership; +import dev.anderson.emprestimoapi.client.ClientEntity; +import dev.anderson.emprestimoapi.common.types.Membership; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/dev/anderson/emprestimoapi/mapper/LoanMapper.java b/src/main/java/dev/anderson/emprestimoapi/loan/LoanMapper.java similarity index 81% rename from src/main/java/dev/anderson/emprestimoapi/mapper/LoanMapper.java rename to src/main/java/dev/anderson/emprestimoapi/loan/LoanMapper.java index bfc019e..63585ba 100644 --- a/src/main/java/dev/anderson/emprestimoapi/mapper/LoanMapper.java +++ b/src/main/java/dev/anderson/emprestimoapi/loan/LoanMapper.java @@ -1,7 +1,5 @@ -package dev.anderson.emprestimoapi.mapper; +package dev.anderson.emprestimoapi.loan; -import dev.anderson.emprestimoapi.dto.LoanDto; -import dev.anderson.emprestimoapi.entities.LoanEntity; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; diff --git a/src/main/java/dev/anderson/emprestimoapi/repositories/LoanRepository.java b/src/main/java/dev/anderson/emprestimoapi/loan/LoanRepository.java similarity index 66% rename from src/main/java/dev/anderson/emprestimoapi/repositories/LoanRepository.java rename to src/main/java/dev/anderson/emprestimoapi/loan/LoanRepository.java index 167c632..41446f1 100644 --- a/src/main/java/dev/anderson/emprestimoapi/repositories/LoanRepository.java +++ b/src/main/java/dev/anderson/emprestimoapi/loan/LoanRepository.java @@ -1,6 +1,5 @@ -package dev.anderson.emprestimoapi.repositories; +package dev.anderson.emprestimoapi.loan; -import dev.anderson.emprestimoapi.entities.LoanEntity; import org.springframework.data.jpa.repository.JpaRepository; public interface LoanRepository extends JpaRepository { diff --git a/src/main/java/dev/anderson/emprestimoapi/service/LoanService.java b/src/main/java/dev/anderson/emprestimoapi/loan/LoanService.java similarity index 83% rename from src/main/java/dev/anderson/emprestimoapi/service/LoanService.java rename to src/main/java/dev/anderson/emprestimoapi/loan/LoanService.java index 45d37a9..4ee6edc 100644 --- a/src/main/java/dev/anderson/emprestimoapi/service/LoanService.java +++ b/src/main/java/dev/anderson/emprestimoapi/loan/LoanService.java @@ -1,14 +1,10 @@ -package dev.anderson.emprestimoapi.service; - -import dev.anderson.emprestimoapi.dto.LoanDto; -import dev.anderson.emprestimoapi.entities.ClientEntity; -import dev.anderson.emprestimoapi.entities.LoanEntity; -import dev.anderson.emprestimoapi.exceptions.ClientNotFoundException; -import dev.anderson.emprestimoapi.exceptions.LoanNotFoundException; -import dev.anderson.emprestimoapi.exceptions.MaxLoanException; -import dev.anderson.emprestimoapi.mapper.LoanMapper; -import dev.anderson.emprestimoapi.repositories.ClientRepository; -import dev.anderson.emprestimoapi.repositories.LoanRepository; +package dev.anderson.emprestimoapi.loan; + +import dev.anderson.emprestimoapi.client.ClientEntity; +import dev.anderson.emprestimoapi.common.exceptions.ClientNotFoundException; +import dev.anderson.emprestimoapi.common.exceptions.LoanNotFoundException; +import dev.anderson.emprestimoapi.common.exceptions.MaxLoanException; +import dev.anderson.emprestimoapi.client.ClientRepository; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8e109ab..3f3c19f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -10,3 +10,4 @@ spring.jpa.hibernate.ddl-auto=update spring.h2.console.enabled=true spring.h2.console.path=/h2-console +server.servlet.context-path: /api/v1 diff --git a/src/test/java/dev/anderson/emprestimoapi/EmprestimoApiApplicationTests.java b/src/test/java/dev/anderson/emprestimoapi/EmprestimoApiApplicationTests.java index 7e949da..0865b5b 100644 --- a/src/test/java/dev/anderson/emprestimoapi/EmprestimoApiApplicationTests.java +++ b/src/test/java/dev/anderson/emprestimoapi/EmprestimoApiApplicationTests.java @@ -1,7 +1,7 @@ package dev.anderson.emprestimoapi; -import dev.anderson.emprestimoapi.controller.ClientController; -import dev.anderson.emprestimoapi.controller.LoanController; +import dev.anderson.emprestimoapi.client.ClientController; +import dev.anderson.emprestimoapi.loan.LoanController; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/test/java/dev/anderson/emprestimoapi/service/ClientServiceTest.java b/src/test/java/dev/anderson/emprestimoapi/service/ClientServiceTest.java index 8841a24..8dadd69 100644 --- a/src/test/java/dev/anderson/emprestimoapi/service/ClientServiceTest.java +++ b/src/test/java/dev/anderson/emprestimoapi/service/ClientServiceTest.java @@ -1,11 +1,12 @@ package dev.anderson.emprestimoapi.service; -import dev.anderson.emprestimoapi.dto.ClientDto; -import dev.anderson.emprestimoapi.entities.ClientEntity; -import dev.anderson.emprestimoapi.exceptions.ClientDuplicatedException; -import dev.anderson.emprestimoapi.exceptions.ClientNotFoundException; -import dev.anderson.emprestimoapi.mapper.ClientMapper; -import dev.anderson.emprestimoapi.repositories.ClientRepository; +import dev.anderson.emprestimoapi.client.ClientService; +import dev.anderson.emprestimoapi.client.ClientDto; +import dev.anderson.emprestimoapi.client.ClientEntity; +import dev.anderson.emprestimoapi.common.exceptions.ClientDuplicatedException; +import dev.anderson.emprestimoapi.common.exceptions.ClientNotFoundException; +import dev.anderson.emprestimoapi.client.ClientMapper; +import dev.anderson.emprestimoapi.client.ClientRepository; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/test/java/dev/anderson/emprestimoapi/service/LoanServiceTest.java b/src/test/java/dev/anderson/emprestimoapi/service/LoanServiceTest.java index ce6e084..d13a109 100644 --- a/src/test/java/dev/anderson/emprestimoapi/service/LoanServiceTest.java +++ b/src/test/java/dev/anderson/emprestimoapi/service/LoanServiceTest.java @@ -1,17 +1,14 @@ package dev.anderson.emprestimoapi.service; -import dev.anderson.emprestimoapi.dto.ClientDto; -import dev.anderson.emprestimoapi.dto.LoanDto; -import dev.anderson.emprestimoapi.entities.ClientEntity; -import dev.anderson.emprestimoapi.entities.LoanEntity; -import dev.anderson.emprestimoapi.exceptions.ClientNotFoundException; -import dev.anderson.emprestimoapi.exceptions.LoanNotFoundException; -import dev.anderson.emprestimoapi.exceptions.MaxLoanException; -import dev.anderson.emprestimoapi.mapper.ClientMapper; -import dev.anderson.emprestimoapi.mapper.LoanMapper; -import dev.anderson.emprestimoapi.repositories.ClientRepository; -import dev.anderson.emprestimoapi.repositories.LoanRepository; -import dev.anderson.emprestimoapi.types.Membership; +import dev.anderson.emprestimoapi.client.ClientDto; +import dev.anderson.emprestimoapi.loan.*; +import dev.anderson.emprestimoapi.client.ClientEntity; +import dev.anderson.emprestimoapi.common.exceptions.ClientNotFoundException; +import dev.anderson.emprestimoapi.common.exceptions.LoanNotFoundException; +import dev.anderson.emprestimoapi.common.exceptions.MaxLoanException; +import dev.anderson.emprestimoapi.client.ClientMapper; +import dev.anderson.emprestimoapi.client.ClientRepository; +import dev.anderson.emprestimoapi.common.types.Membership; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -104,7 +101,7 @@ void makeLoanOfClientThatDoesExist() throws Exception { @Test @DisplayName("Create a loan of a client that does exist but is not eligible for loan") - void makeLoanOfClientNotEligibleForLoan() throws Exception { + void makeLoanOfClientNotEligibleForLoan() { ClientDto clientDto = new ClientDto(); clientDto.setCpf("12345678901"); clientDto.setName("Bilbo Baggins"); diff --git a/src/test/java/dev/anderson/emprestimoapi/types/MembershipTest.java b/src/test/java/dev/anderson/emprestimoapi/types/MembershipTest.java index 2674596..3b82050 100644 --- a/src/test/java/dev/anderson/emprestimoapi/types/MembershipTest.java +++ b/src/test/java/dev/anderson/emprestimoapi/types/MembershipTest.java @@ -1,5 +1,6 @@ package dev.anderson.emprestimoapi.types; +import dev.anderson.emprestimoapi.common.types.Membership; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest;