From 59aa636c6670f2346726d7d465a83501d8360fb8 Mon Sep 17 00:00:00 2001 From: Hazar Gul Nazari Date: Fri, 10 May 2024 00:46:24 +0200 Subject: [PATCH 1/2] Update README.md --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index 5dcd182..8c22456 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,6 @@ Explain https://medium.com/swlh/clean-architecture-java-spring-fea51e26e00 -My other artichels - -Recillence in Java Aplication -https://medium.com/swlh/future-proofing-your-java-applications-understanding-the-power-of-resilience-patterns-with-cfbafdcfdc86 - -Concurrency Java Application with examples -https://medium.com/swlh/conquering-concurrency-in-spring-boot-strategies-and-solutions-152f41dd9005 - *Compile*
mvn clean install From 0ad951d1910160d20f9616bbda415490b6133951 Mon Sep 17 00:00:00 2001 From: "hazar.nazari" Date: Sat, 11 May 2024 17:30:01 +0200 Subject: [PATCH 2/2] upgrade to spring boot 3.x --- core/pom.xml | 32 ++--- .../d4i/sample/movie/category/Category.java | 7 +- .../CategoryAlreadyExistException.java | 5 - .../ports/CategoryRepositoryService.java | 6 +- .../usecase/CreateCategoryUseCase.java | 2 +- .../usecase/GetAllCategoriesUseCase.java | 2 +- .../sample/movie/shared/SelfValidating.java | 13 +- infraestructure/pom.xml | 128 ----------------- .../movie/configuration/SwaggerConfig.java | 33 ----- .../movie/delivery/rest/CategoryRest.java | 23 --- infrastructure/pom.xml | 75 ++++++++++ .../com/d4i/sample/movie/Application.java | 0 .../configuration/CategoryConfiguration.java | 0 .../movie/delivery/CategoryController.java | 0 .../converters/CategoryRestConverter.java | 2 +- .../delivery/impl/CategoryControllerImpl.java | 131 +++++++++--------- .../delivery/responses/NetflixResponse.java | 0 .../movie/delivery/rest/CategoryRest.java | 9 ++ .../CategoryRepositoryConverter.java | 0 .../persistence/entities/CategoryEntity.java | 16 +-- .../persistence/impl/CategoryServiceImpl.java | 70 +++++----- .../repositories/CategoryRepository.java | 8 +- .../movie/shared/RepositoryConverter.java | 0 .../sample/movie/shared/RestConverter.java | 0 .../shared/constants/CommonConstants.java | 0 .../shared/constants/ExceptionConstants.java | 0 .../movie/shared/constants/RestConstants.java | 0 .../exceptions/BadRequestException.java | 3 +- .../shared/exceptions/NetflixException.java | 0 .../shared/exceptions/NotFoundException.java | 0 .../src/main/resource/application.properties | 0 pom.xml | 19 ++- 32 files changed, 227 insertions(+), 357 deletions(-) delete mode 100644 infraestructure/pom.xml delete mode 100644 infraestructure/src/main/java/com/d4i/sample/movie/configuration/SwaggerConfig.java delete mode 100644 infraestructure/src/main/java/com/d4i/sample/movie/delivery/rest/CategoryRest.java create mode 100644 infrastructure/pom.xml rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/Application.java (100%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/configuration/CategoryConfiguration.java (100%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/delivery/CategoryController.java (100%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/delivery/converters/CategoryRestConverter.java (88%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/delivery/impl/CategoryControllerImpl.java (82%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/delivery/responses/NetflixResponse.java (100%) create mode 100644 infrastructure/src/main/java/com/d4i/sample/movie/delivery/rest/CategoryRest.java rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/persistence/converters/CategoryRepositoryConverter.java (100%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/persistence/entities/CategoryEntity.java (72%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/persistence/impl/CategoryServiceImpl.java (85%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/persistence/repositories/CategoryRepository.java (86%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/shared/RepositoryConverter.java (100%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/shared/RestConverter.java (100%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/shared/constants/CommonConstants.java (100%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/shared/constants/ExceptionConstants.java (100%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/shared/constants/RestConstants.java (100%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/shared/exceptions/BadRequestException.java (99%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/shared/exceptions/NetflixException.java (100%) rename {infraestructure => infrastructure}/src/main/java/com/d4i/sample/movie/shared/exceptions/NotFoundException.java (100%) rename {infraestructure => infrastructure}/src/main/resource/application.properties (100%) diff --git a/core/pom.xml b/core/pom.xml index 53a216b..8854681 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,46 +4,34 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + com.d4i.sample + clean-arch + 1.0 + + com.d4i.sample.movie - clean-arch-core + core 0.0.1 core jar domain project - 1.8 - 1.18.8 - 2.8.0 + 22 - - com.d4i.sample - clean-arch - 1.0 - - org.projectlombok lombok true - ${lombok.version} - - - - javax.validation - validation-api - 2.0.1.Final - - javax.inject - javax.inject - 1 + org.springframework.boot + spring-boot-starter-validation - diff --git a/core/src/main/java/com/d4i/sample/movie/category/Category.java b/core/src/main/java/com/d4i/sample/movie/category/Category.java index 446f35b..715b6df 100644 --- a/core/src/main/java/com/d4i/sample/movie/category/Category.java +++ b/core/src/main/java/com/d4i/sample/movie/category/Category.java @@ -1,12 +1,9 @@ package com.d4i.sample.movie.category; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotEmpty; import java.io.Serializable; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; - - - import com.d4i.sample.movie.shared.SelfValidating; import lombok.AllArgsConstructor; diff --git a/core/src/main/java/com/d4i/sample/movie/category/exception/CategoryAlreadyExistException.java b/core/src/main/java/com/d4i/sample/movie/category/exception/CategoryAlreadyExistException.java index a949cf4..9a2abbb 100644 --- a/core/src/main/java/com/d4i/sample/movie/category/exception/CategoryAlreadyExistException.java +++ b/core/src/main/java/com/d4i/sample/movie/category/exception/CategoryAlreadyExistException.java @@ -1,11 +1,6 @@ package com.d4i.sample.movie.category.exception; - - - public class CategoryAlreadyExistException extends Exception { - - private static final long serialVersionUID = -5330068136795055851L; diff --git a/core/src/main/java/com/d4i/sample/movie/category/ports/CategoryRepositoryService.java b/core/src/main/java/com/d4i/sample/movie/category/ports/CategoryRepositoryService.java index c7f1923..1e2459d 100644 --- a/core/src/main/java/com/d4i/sample/movie/category/ports/CategoryRepositoryService.java +++ b/core/src/main/java/com/d4i/sample/movie/category/ports/CategoryRepositoryService.java @@ -6,9 +6,9 @@ public interface CategoryRepositoryService { - public Collection getAllCategories(); + Collection getAllCategories(); - public void saveCategory(Category category) ; + void saveCategory(Category category) ; - public Boolean doesCategoryNameExists(String name); + Boolean doesCategoryNameExists(String name); } diff --git a/core/src/main/java/com/d4i/sample/movie/category/usecase/CreateCategoryUseCase.java b/core/src/main/java/com/d4i/sample/movie/category/usecase/CreateCategoryUseCase.java index 0ca7692..f0fb46d 100644 --- a/core/src/main/java/com/d4i/sample/movie/category/usecase/CreateCategoryUseCase.java +++ b/core/src/main/java/com/d4i/sample/movie/category/usecase/CreateCategoryUseCase.java @@ -5,6 +5,6 @@ public interface CreateCategoryUseCase { - public void execute(Category category) throws CategoryAlreadyExistException ; + void execute(Category category) throws CategoryAlreadyExistException ; } diff --git a/core/src/main/java/com/d4i/sample/movie/category/usecase/GetAllCategoriesUseCase.java b/core/src/main/java/com/d4i/sample/movie/category/usecase/GetAllCategoriesUseCase.java index 61e10e6..f03a872 100644 --- a/core/src/main/java/com/d4i/sample/movie/category/usecase/GetAllCategoriesUseCase.java +++ b/core/src/main/java/com/d4i/sample/movie/category/usecase/GetAllCategoriesUseCase.java @@ -6,6 +6,6 @@ public interface GetAllCategoriesUseCase { - public Collection execute(); + Collection execute(); } diff --git a/core/src/main/java/com/d4i/sample/movie/shared/SelfValidating.java b/core/src/main/java/com/d4i/sample/movie/shared/SelfValidating.java index d919a08..fb20270 100644 --- a/core/src/main/java/com/d4i/sample/movie/shared/SelfValidating.java +++ b/core/src/main/java/com/d4i/sample/movie/shared/SelfValidating.java @@ -1,16 +1,15 @@ package com.d4i.sample.movie.shared; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.ConstraintViolationException; +import jakarta.validation.Validation; +import jakarta.validation.Validator; +import jakarta.validation.ValidatorFactory; import java.util.Set; -import javax.validation.ConstraintViolation; -import javax.validation.ConstraintViolationException; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; - public abstract class SelfValidating { - private Validator validator; + private final Validator validator; protected SelfValidating() { ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); diff --git a/infraestructure/pom.xml b/infraestructure/pom.xml deleted file mode 100644 index 353154a..0000000 --- a/infraestructure/pom.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.2.4.RELEASE - - - - com.d4i.sample.infrastructure - clean-arch-infrastructure - 0.0.1-SNAPSHOT - infrastructure - Clean Arch Sample - - - 1.8 - 1.18.8 - 2.8.0 - - - - - - com.d4i.sample.movie - clean-arch-core - 0.0.1 - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-web - - - mysql - mysql-connector-java - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - - - - - - org.postgresql - postgresql - 42.4.3 - - - - com.h2database - h2 - runtime - 2.2.220 - - - - io.springfox - springfox-swagger2 - ${swagger2.version} - - - io.springfox - springfox-swagger-ui - ${swagger2.version} - - - - org.projectlombok - lombok - ${lombok.version} - - - - com.fasterxml.jackson.core - jackson-core - 2.10.0 - - - com.fasterxml.jackson.core - jackson-databind - 2.12.7.1 - - - com.fasterxml.jackson.core - jackson-annotations - 2.10.0 - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - 1.8 - 1.8 - - - org.projectlombok - lombok - ${lombok.version} - - - - - - - - diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/configuration/SwaggerConfig.java b/infraestructure/src/main/java/com/d4i/sample/movie/configuration/SwaggerConfig.java deleted file mode 100644 index 9bc34c4..0000000 --- a/infraestructure/src/main/java/com/d4i/sample/movie/configuration/SwaggerConfig.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.d4i.sample.movie.configuration; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Configuration -@EnableSwagger2 -public class SwaggerConfig { - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("com.d4i.sample.movie")) - .paths(PathSelectors.any()) - .build(); - } - - private ApiInfo apiInfo() { - return new ApiInfoBuilder().title("Soy Juanmalopez").description("Apis realizadas con clean arquitecture") - .termsOfServiceUrl("https://www.everis.com").license("everis").licenseUrl("https://www.everis.com") - .version("1.0").build(); - } - -} diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/delivery/rest/CategoryRest.java b/infraestructure/src/main/java/com/d4i/sample/movie/delivery/rest/CategoryRest.java deleted file mode 100644 index d101e3d..0000000 --- a/infraestructure/src/main/java/com/d4i/sample/movie/delivery/rest/CategoryRest.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.d4i.sample.movie.delivery.rest; - -import java.io.Serializable; - -import javax.validation.constraints.NotNull; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class CategoryRest implements Serializable { - - private static final long serialVersionUID = 7809559376441998463L; - - @NotNull - private String name; - - @NotNull - private Boolean available; -} diff --git a/infrastructure/pom.xml b/infrastructure/pom.xml new file mode 100644 index 0000000..8b490fd --- /dev/null +++ b/infrastructure/pom.xml @@ -0,0 +1,75 @@ + + + 4.0.0 + + com.d4i.sample + clean-arch + 1.0 + + + com.d4i.sample.infrastructure + infrastructure + 0.0.1-SNAPSHOT + infrastructure + Clean Arch Sample + + + 22 + + + + + + com.d4i.sample.movie + core + 0.0.1 + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + com.mysql + mysql-connector-j + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.postgresql + postgresql + + + + com.h2database + h2 + runtime + + + + org.projectlombok + lombok + 1.18.32 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/Application.java b/infrastructure/src/main/java/com/d4i/sample/movie/Application.java similarity index 100% rename from infraestructure/src/main/java/com/d4i/sample/movie/Application.java rename to infrastructure/src/main/java/com/d4i/sample/movie/Application.java diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/configuration/CategoryConfiguration.java b/infrastructure/src/main/java/com/d4i/sample/movie/configuration/CategoryConfiguration.java similarity index 100% rename from infraestructure/src/main/java/com/d4i/sample/movie/configuration/CategoryConfiguration.java rename to infrastructure/src/main/java/com/d4i/sample/movie/configuration/CategoryConfiguration.java diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/delivery/CategoryController.java b/infrastructure/src/main/java/com/d4i/sample/movie/delivery/CategoryController.java similarity index 100% rename from infraestructure/src/main/java/com/d4i/sample/movie/delivery/CategoryController.java rename to infrastructure/src/main/java/com/d4i/sample/movie/delivery/CategoryController.java diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/delivery/converters/CategoryRestConverter.java b/infrastructure/src/main/java/com/d4i/sample/movie/delivery/converters/CategoryRestConverter.java similarity index 88% rename from infraestructure/src/main/java/com/d4i/sample/movie/delivery/converters/CategoryRestConverter.java rename to infrastructure/src/main/java/com/d4i/sample/movie/delivery/converters/CategoryRestConverter.java index f00c41d..0701285 100644 --- a/infraestructure/src/main/java/com/d4i/sample/movie/delivery/converters/CategoryRestConverter.java +++ b/infrastructure/src/main/java/com/d4i/sample/movie/delivery/converters/CategoryRestConverter.java @@ -9,7 +9,7 @@ public class CategoryRestConverter implements RestConverter> getCategories() throws NetflixException { - return new NetflixResponse<>(CommonConstants.SUCCESS, String.valueOf(HttpStatus.OK), CommonConstants.OK, - getAllCategoriesUseCase.execute().stream().map(category -> categoryRestConverter.mapToRest(category)) - .collect(Collectors.toList())); - } - - @Override - @ResponseStatus(HttpStatus.OK) - @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) - public NetflixResponse createCategory(@Valid @RequestBody final CategoryRest category) throws NetflixException { - - try { - createCategoryUseCase.execute(categoryRestConverter.mapToEntity(category)); - } catch (CategoryAlreadyExistException e) { - e.printStackTrace(); - - } - - return new NetflixResponse<>(CommonConstants.SUCCESS, String.valueOf(HttpStatus.OK), CommonConstants.OK); - } - -} +package com.d4i.sample.movie.delivery.impl; + +import com.d4i.sample.movie.category.exception.CategoryAlreadyExistException; +import com.d4i.sample.movie.category.usecase.CreateCategoryUseCase; +import com.d4i.sample.movie.category.usecase.GetAllCategoriesUseCase; +import com.d4i.sample.movie.delivery.CategoryController; +import com.d4i.sample.movie.delivery.converters.CategoryRestConverter; +import com.d4i.sample.movie.delivery.responses.NetflixResponse; +import com.d4i.sample.movie.delivery.rest.CategoryRest; +import com.d4i.sample.movie.shared.constants.CommonConstants; +import com.d4i.sample.movie.shared.constants.RestConstants; +import com.d4i.sample.movie.shared.exceptions.NetflixException; +import jakarta.validation.Valid; +import java.util.Collection; +import java.util.stream.Collectors; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping(RestConstants.APPLICATION_NAME + RestConstants.API_VERSION_1 + RestConstants.RESOURCE_CATEGORY) +public class CategoryControllerImpl implements CategoryController { + + private final GetAllCategoriesUseCase getAllCategoriesUseCase; + + private final CreateCategoryUseCase createCategoryUseCase; + + private final CategoryRestConverter categoryRestConverter; + + public CategoryControllerImpl(GetAllCategoriesUseCase getAllCategoriesUseCase, CreateCategoryUseCase createCategoryUseCase, + CategoryRestConverter categoryRestConverter) { + this.getAllCategoriesUseCase = getAllCategoriesUseCase; + this.createCategoryUseCase = createCategoryUseCase; + this.categoryRestConverter = categoryRestConverter; + } + + @Override + @ResponseStatus(HttpStatus.OK) + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public NetflixResponse> getCategories() throws NetflixException { + return new NetflixResponse<>(CommonConstants.SUCCESS, String.valueOf(HttpStatus.OK), CommonConstants.OK, + getAllCategoriesUseCase.execute().stream().map(categoryRestConverter::mapToRest) + .collect(Collectors.toList())); + } + + @Override + @ResponseStatus(HttpStatus.OK) + @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public NetflixResponse createCategory(@Valid @RequestBody final CategoryRest category) throws NetflixException { + + try { + createCategoryUseCase.execute(categoryRestConverter.mapToEntity(category)); + } catch (CategoryAlreadyExistException e) { + e.printStackTrace(); + + } + + return new NetflixResponse<>(CommonConstants.SUCCESS, String.valueOf(HttpStatus.OK), CommonConstants.OK); + } + +} diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/delivery/responses/NetflixResponse.java b/infrastructure/src/main/java/com/d4i/sample/movie/delivery/responses/NetflixResponse.java similarity index 100% rename from infraestructure/src/main/java/com/d4i/sample/movie/delivery/responses/NetflixResponse.java rename to infrastructure/src/main/java/com/d4i/sample/movie/delivery/responses/NetflixResponse.java diff --git a/infrastructure/src/main/java/com/d4i/sample/movie/delivery/rest/CategoryRest.java b/infrastructure/src/main/java/com/d4i/sample/movie/delivery/rest/CategoryRest.java new file mode 100644 index 0000000..e083f7c --- /dev/null +++ b/infrastructure/src/main/java/com/d4i/sample/movie/delivery/rest/CategoryRest.java @@ -0,0 +1,9 @@ +package com.d4i.sample.movie.delivery.rest; + + +import jakarta.validation.constraints.NotNull; +import java.io.Serializable; + +public record CategoryRest( + @NotNull String name, + @NotNull Boolean available) implements Serializable {} diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/persistence/converters/CategoryRepositoryConverter.java b/infrastructure/src/main/java/com/d4i/sample/movie/persistence/converters/CategoryRepositoryConverter.java similarity index 100% rename from infraestructure/src/main/java/com/d4i/sample/movie/persistence/converters/CategoryRepositoryConverter.java rename to infrastructure/src/main/java/com/d4i/sample/movie/persistence/converters/CategoryRepositoryConverter.java diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/persistence/entities/CategoryEntity.java b/infrastructure/src/main/java/com/d4i/sample/movie/persistence/entities/CategoryEntity.java similarity index 72% rename from infraestructure/src/main/java/com/d4i/sample/movie/persistence/entities/CategoryEntity.java rename to infrastructure/src/main/java/com/d4i/sample/movie/persistence/entities/CategoryEntity.java index 6359900..ec4e17c 100644 --- a/infraestructure/src/main/java/com/d4i/sample/movie/persistence/entities/CategoryEntity.java +++ b/infrastructure/src/main/java/com/d4i/sample/movie/persistence/entities/CategoryEntity.java @@ -1,15 +1,13 @@ package com.d4i.sample.movie.persistence.entities; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.SequenceGenerator; +import jakarta.persistence.Table; import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.SequenceGenerator; -import javax.persistence.Table; - import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/persistence/impl/CategoryServiceImpl.java b/infrastructure/src/main/java/com/d4i/sample/movie/persistence/impl/CategoryServiceImpl.java similarity index 85% rename from infraestructure/src/main/java/com/d4i/sample/movie/persistence/impl/CategoryServiceImpl.java rename to infrastructure/src/main/java/com/d4i/sample/movie/persistence/impl/CategoryServiceImpl.java index 7249daf..8022aca 100644 --- a/infraestructure/src/main/java/com/d4i/sample/movie/persistence/impl/CategoryServiceImpl.java +++ b/infrastructure/src/main/java/com/d4i/sample/movie/persistence/impl/CategoryServiceImpl.java @@ -1,36 +1,34 @@ -package com.d4i.sample.movie.persistence.impl; - -import java.util.Collection; -import java.util.stream.Collectors; - -import com.d4i.sample.movie.category.Category; -import com.d4i.sample.movie.category.ports.CategoryRepositoryService; -import com.d4i.sample.movie.persistence.converters.CategoryRepositoryConverter; -import com.d4i.sample.movie.persistence.repositories.CategoryRepository; - -import lombok.AllArgsConstructor; - -@AllArgsConstructor -public class CategoryServiceImpl implements CategoryRepositoryService { - - private final CategoryRepository categoryRepository; - - private final CategoryRepositoryConverter categoryRepositoryConverter; - - @Override - public Collection getAllCategories() { - return categoryRepository.findAll().stream().map(category -> categoryRepositoryConverter.mapToEntity(category)) - .collect(Collectors.toList()); - - } - - @Override - public void saveCategory(final Category category) { - categoryRepository.save(categoryRepositoryConverter.mapToTable(category)); - } - - public Boolean doesCategoryNameExists(final String name) { - return !categoryRepository.findByName(name).isEmpty(); - } - -} +package com.d4i.sample.movie.persistence.impl; + +import java.util.Collection; +import java.util.stream.Collectors; + +import com.d4i.sample.movie.category.Category; +import com.d4i.sample.movie.category.ports.CategoryRepositoryService; +import com.d4i.sample.movie.persistence.converters.CategoryRepositoryConverter; +import com.d4i.sample.movie.persistence.repositories.CategoryRepository; +import lombok.AllArgsConstructor; + +@AllArgsConstructor +public class CategoryServiceImpl implements CategoryRepositoryService { + + private final CategoryRepository categoryRepository; + private final CategoryRepositoryConverter categoryRepositoryConverter; + + @Override + public Collection getAllCategories() { + return categoryRepository.findAll().stream().map(categoryRepositoryConverter::mapToEntity) + .collect(Collectors.toList()); + + } + + @Override + public void saveCategory(final Category category) { + categoryRepository.save(categoryRepositoryConverter.mapToTable(category)); + } + + public Boolean doesCategoryNameExists(final String name) { + return !categoryRepository.findByName(name).isEmpty(); + } + +} diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/persistence/repositories/CategoryRepository.java b/infrastructure/src/main/java/com/d4i/sample/movie/persistence/repositories/CategoryRepository.java similarity index 86% rename from infraestructure/src/main/java/com/d4i/sample/movie/persistence/repositories/CategoryRepository.java rename to infrastructure/src/main/java/com/d4i/sample/movie/persistence/repositories/CategoryRepository.java index 283ab1e..96d3275 100644 --- a/infraestructure/src/main/java/com/d4i/sample/movie/persistence/repositories/CategoryRepository.java +++ b/infrastructure/src/main/java/com/d4i/sample/movie/persistence/repositories/CategoryRepository.java @@ -1,13 +1,11 @@ package com.d4i.sample.movie.persistence.repositories; -import java.util.Collection; - -import org.springframework.data.jpa.repository.JpaRepository; - import com.d4i.sample.movie.category.Category; import com.d4i.sample.movie.persistence.entities.CategoryEntity; +import java.util.Collection; +import org.springframework.data.jpa.repository.JpaRepository; public interface CategoryRepository extends JpaRepository { - public Collection findByName(String name); + Collection findByName(String name); } diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/shared/RepositoryConverter.java b/infrastructure/src/main/java/com/d4i/sample/movie/shared/RepositoryConverter.java similarity index 100% rename from infraestructure/src/main/java/com/d4i/sample/movie/shared/RepositoryConverter.java rename to infrastructure/src/main/java/com/d4i/sample/movie/shared/RepositoryConverter.java diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/shared/RestConverter.java b/infrastructure/src/main/java/com/d4i/sample/movie/shared/RestConverter.java similarity index 100% rename from infraestructure/src/main/java/com/d4i/sample/movie/shared/RestConverter.java rename to infrastructure/src/main/java/com/d4i/sample/movie/shared/RestConverter.java diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/shared/constants/CommonConstants.java b/infrastructure/src/main/java/com/d4i/sample/movie/shared/constants/CommonConstants.java similarity index 100% rename from infraestructure/src/main/java/com/d4i/sample/movie/shared/constants/CommonConstants.java rename to infrastructure/src/main/java/com/d4i/sample/movie/shared/constants/CommonConstants.java diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/shared/constants/ExceptionConstants.java b/infrastructure/src/main/java/com/d4i/sample/movie/shared/constants/ExceptionConstants.java similarity index 100% rename from infraestructure/src/main/java/com/d4i/sample/movie/shared/constants/ExceptionConstants.java rename to infrastructure/src/main/java/com/d4i/sample/movie/shared/constants/ExceptionConstants.java diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/shared/constants/RestConstants.java b/infrastructure/src/main/java/com/d4i/sample/movie/shared/constants/RestConstants.java similarity index 100% rename from infraestructure/src/main/java/com/d4i/sample/movie/shared/constants/RestConstants.java rename to infrastructure/src/main/java/com/d4i/sample/movie/shared/constants/RestConstants.java diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/shared/exceptions/BadRequestException.java b/infrastructure/src/main/java/com/d4i/sample/movie/shared/exceptions/BadRequestException.java similarity index 99% rename from infraestructure/src/main/java/com/d4i/sample/movie/shared/exceptions/BadRequestException.java rename to infrastructure/src/main/java/com/d4i/sample/movie/shared/exceptions/BadRequestException.java index 8681c5e..0e8267f 100644 --- a/infraestructure/src/main/java/com/d4i/sample/movie/shared/exceptions/BadRequestException.java +++ b/infrastructure/src/main/java/com/d4i/sample/movie/shared/exceptions/BadRequestException.java @@ -1,8 +1,7 @@ package com.d4i.sample.movie.shared.exceptions; -import org.springframework.http.HttpStatus; - import lombok.Data; +import org.springframework.http.HttpStatus; @Data public class BadRequestException extends NetflixException{ diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/shared/exceptions/NetflixException.java b/infrastructure/src/main/java/com/d4i/sample/movie/shared/exceptions/NetflixException.java similarity index 100% rename from infraestructure/src/main/java/com/d4i/sample/movie/shared/exceptions/NetflixException.java rename to infrastructure/src/main/java/com/d4i/sample/movie/shared/exceptions/NetflixException.java diff --git a/infraestructure/src/main/java/com/d4i/sample/movie/shared/exceptions/NotFoundException.java b/infrastructure/src/main/java/com/d4i/sample/movie/shared/exceptions/NotFoundException.java similarity index 100% rename from infraestructure/src/main/java/com/d4i/sample/movie/shared/exceptions/NotFoundException.java rename to infrastructure/src/main/java/com/d4i/sample/movie/shared/exceptions/NotFoundException.java diff --git a/infraestructure/src/main/resource/application.properties b/infrastructure/src/main/resource/application.properties similarity index 100% rename from infraestructure/src/main/resource/application.properties rename to infrastructure/src/main/resource/application.properties diff --git a/pom.xml b/pom.xml index b90ba1a..fa9f8a8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,23 +4,20 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.2.5 + + + com.d4i.sample clean-arch pom 1.0 - - - UTF-8 - 1.8 - 1.8 - 1.18.6 - 2.1.7.RELEASE - - - - infraestructure + infrastructure core