From a79e249b61911dfa658c611cc89d6225be33530d Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Sun, 30 Jun 2019 16:27:50 -0500 Subject: [PATCH] BAEL-2985 fix Spring Boot apps in spring-data-rest (#7224) * BAEL-2246: add link back to article * BAEL-2174: rename core-java-net module to core-java-networking * BAEL-2174: add link back to article * BAEL-2363 BAEL-2337 BAEL-1996 BAEL-2277 add links back to articles * BAEL-2367: add link back to article * BAEL-2335: add link back to article * BAEL-2413: add link back to article * Update README.MD * BAEL-2577: add link back to article * BAEL-2490: add link back to article * BAEL-2471: add link back to article * BAEL-2583: add link back to article * BAEL-2738: add link back to article * BAEL-2711: Add spring-boot-angular module to root pom * BAEL-2544 BAEL-2711 BAEL-2575 BAEL-2657 Add links back to articles * BAEL-2736: Add link back to article * BAEL-2789: Add link back to article * BAEL-2489: add link back to article * BAEL-2840: add link back to article * BAEL-2655: add link back to article * BAEL-2884: add link back to article * BAEL-2985: Fix Spring Boot Apps in spring-data-rest module --- .../{ => books}/SpringDataRestApplication.java | 2 +- .../com/baeldung/{ => books}/config/DbConfig.java | 6 +++--- .../com/baeldung/{ => books}/config/MvcConfig.java | 7 ++++--- .../com/baeldung/{ => books}/config/RestConfig.java | 7 ++++--- .../{ => books}/config/ValidatorEventRegister.java | 2 +- .../baeldung/{ => books}/dialect/SQLiteDialect.java | 2 +- .../dialect/SQLiteIdentityColumnSupport.java | 2 +- .../{ => books}/events/AuthorEventHandler.java | 7 ++++--- .../{ => books}/events/BookEventHandler.java | 8 +++++--- .../handlers/RestResponseEntityExceptionHandler.java | 2 +- .../com/baeldung/{ => books}/models/Address.java | 2 +- .../java/com/baeldung/{ => books}/models/Author.java | 2 +- .../java/com/baeldung/{ => books}/models/Book.java | 2 +- .../com/baeldung/{ => books}/models/Library.java | 2 +- .../com/baeldung/{ => books}/models/Subject.java | 2 +- .../com/baeldung/{ => books}/models/WebsiteUser.java | 2 +- .../baeldung/{ => books}/projections/CustomBook.java | 6 +++--- .../{ => books}/repositories/AddressRepository.java | 4 ++-- .../{ => books}/repositories/AuthorRepository.java | 4 ++-- .../{ => books}/repositories/BookRepository.java | 6 +++--- .../{ => books}/repositories/LibraryRepository.java | 4 ++-- .../{ => books}/repositories/SubjectRepository.java | 5 +++-- .../{ => books}/repositories/UserRepository.java | 5 +++-- .../{ => books}/validators/WebsiteUserValidator.java | 4 ++-- .../events/AuthorEventHandlerUnitTest.java | 6 ++++-- .../{ => books}/events/BookEventHandlerUnitTest.java | 8 +++++--- .../projections}/SpringDataProjectionLiveTest.java | 12 ++++++------ .../SpringDataRestValidatorIntegrationTest.java | 6 +++--- .../test/UserControllerIntegrationTest.java | 2 +- .../org/baeldung/SpringContextIntegrationTest.java | 2 +- 30 files changed, 71 insertions(+), 60 deletions(-) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/SpringDataRestApplication.java (91%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/config/DbConfig.java (94%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/config/MvcConfig.java (85%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/config/RestConfig.java (86%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/config/ValidatorEventRegister.java (94%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/dialect/SQLiteDialect.java (98%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/dialect/SQLiteIdentityColumnSupport.java (94%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/events/AuthorEventHandler.java (89%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/events/BookEventHandler.java (86%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/exception/handlers/RestResponseEntityExceptionHandler.java (94%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/models/Address.java (96%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/models/Author.java (97%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/models/Book.java (97%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/models/Library.java (97%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/models/Subject.java (94%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/models/WebsiteUser.java (95%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/projections/CustomBook.java (77%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/repositories/AddressRepository.java (62%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/repositories/AuthorRepository.java (62%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/repositories/BookRepository.java (67%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/repositories/LibraryRepository.java (62%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/repositories/SubjectRepository.java (85%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/repositories/UserRepository.java (91%) rename spring-data-rest/src/main/java/com/baeldung/{ => books}/validators/WebsiteUserValidator.java (87%) rename spring-data-rest/src/test/java/com/baeldung/{ => books}/events/AuthorEventHandlerUnitTest.java (86%) rename spring-data-rest/src/test/java/com/baeldung/{ => books}/events/BookEventHandlerUnitTest.java (81%) rename spring-data-rest/src/test/java/com/baeldung/{projection => books/projections}/SpringDataProjectionLiveTest.java (91%) rename spring-data-rest/src/test/java/com/baeldung/{ => books}/validator/SpringDataRestValidatorIntegrationTest.java (97%) diff --git a/spring-data-rest/src/main/java/com/baeldung/SpringDataRestApplication.java b/spring-data-rest/src/main/java/com/baeldung/books/SpringDataRestApplication.java similarity index 91% rename from spring-data-rest/src/main/java/com/baeldung/SpringDataRestApplication.java rename to spring-data-rest/src/main/java/com/baeldung/books/SpringDataRestApplication.java index 702acb5b65..097a6aabd7 100644 --- a/spring-data-rest/src/main/java/com/baeldung/SpringDataRestApplication.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/SpringDataRestApplication.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.books; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java b/spring-data-rest/src/main/java/com/baeldung/books/config/DbConfig.java similarity index 94% rename from spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java rename to spring-data-rest/src/main/java/com/baeldung/books/config/DbConfig.java index 3ca728ec94..20008eb583 100644 --- a/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/config/DbConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.config; +package com.baeldung.books.config; import java.util.Properties; @@ -16,7 +16,7 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; @Configuration -@EnableJpaRepositories(basePackages = "com.baeldung.repositories") +@EnableJpaRepositories(basePackages = "com.baeldung.books.repositories") // @PropertySource("persistence-h2.properties") // @PropertySource("persistence-hsqldb.properties") // @PropertySource("persistence-derby.properties") @@ -40,7 +40,7 @@ public class DbConfig { public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); - em.setPackagesToScan(new String[] { "com.baeldung.models" }); + em.setPackagesToScan(new String[] { "com.baeldung.books.models" }); em.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); em.setJpaProperties(additionalProperties()); return em; diff --git a/spring-data-rest/src/main/java/com/baeldung/config/MvcConfig.java b/spring-data-rest/src/main/java/com/baeldung/books/config/MvcConfig.java similarity index 85% rename from spring-data-rest/src/main/java/com/baeldung/config/MvcConfig.java rename to spring-data-rest/src/main/java/com/baeldung/books/config/MvcConfig.java index 9d0d3a6687..69e984ad06 100644 --- a/spring-data-rest/src/main/java/com/baeldung/config/MvcConfig.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/config/MvcConfig.java @@ -1,13 +1,14 @@ -package com.baeldung.config; +package com.baeldung.books.config; -import com.baeldung.events.AuthorEventHandler; -import com.baeldung.events.BookEventHandler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import com.baeldung.books.events.AuthorEventHandler; +import com.baeldung.books.events.BookEventHandler; + @Configuration @EnableWebMvc public class MvcConfig implements WebMvcConfigurer { diff --git a/spring-data-rest/src/main/java/com/baeldung/config/RestConfig.java b/spring-data-rest/src/main/java/com/baeldung/books/config/RestConfig.java similarity index 86% rename from spring-data-rest/src/main/java/com/baeldung/config/RestConfig.java rename to spring-data-rest/src/main/java/com/baeldung/books/config/RestConfig.java index 47cb95693b..1c6f04331e 100644 --- a/spring-data-rest/src/main/java/com/baeldung/config/RestConfig.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/config/RestConfig.java @@ -1,7 +1,8 @@ -package com.baeldung.config; +package com.baeldung.books.config; + +import com.baeldung.books.models.WebsiteUser; +import com.baeldung.books.projections.CustomBook; -import com.baeldung.models.WebsiteUser; -import com.baeldung.projections.CustomBook; import org.springframework.context.annotation.Configuration; import org.springframework.data.rest.core.config.RepositoryRestConfiguration; import org.springframework.data.rest.core.mapping.ExposureConfiguration; diff --git a/spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java b/spring-data-rest/src/main/java/com/baeldung/books/config/ValidatorEventRegister.java similarity index 94% rename from spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java rename to spring-data-rest/src/main/java/com/baeldung/books/config/ValidatorEventRegister.java index 632ad9183a..bbaf9a2771 100644 --- a/spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/config/ValidatorEventRegister.java @@ -1,4 +1,4 @@ -package com.baeldung.config; +package com.baeldung.books.config; import java.util.Arrays; import java.util.List; diff --git a/spring-data-rest/src/main/java/com/baeldung/dialect/SQLiteDialect.java b/spring-data-rest/src/main/java/com/baeldung/books/dialect/SQLiteDialect.java similarity index 98% rename from spring-data-rest/src/main/java/com/baeldung/dialect/SQLiteDialect.java rename to spring-data-rest/src/main/java/com/baeldung/books/dialect/SQLiteDialect.java index 4512f7d34d..6e840eec43 100644 --- a/spring-data-rest/src/main/java/com/baeldung/dialect/SQLiteDialect.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/dialect/SQLiteDialect.java @@ -1,4 +1,4 @@ -package com.baeldung.dialect; +package com.baeldung.books.dialect; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.identity.IdentityColumnSupport; diff --git a/spring-data-rest/src/main/java/com/baeldung/dialect/SQLiteIdentityColumnSupport.java b/spring-data-rest/src/main/java/com/baeldung/books/dialect/SQLiteIdentityColumnSupport.java similarity index 94% rename from spring-data-rest/src/main/java/com/baeldung/dialect/SQLiteIdentityColumnSupport.java rename to spring-data-rest/src/main/java/com/baeldung/books/dialect/SQLiteIdentityColumnSupport.java index cf6e3a9a97..682d82c6f1 100644 --- a/spring-data-rest/src/main/java/com/baeldung/dialect/SQLiteIdentityColumnSupport.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/dialect/SQLiteIdentityColumnSupport.java @@ -1,4 +1,4 @@ -package com.baeldung.dialect; +package com.baeldung.books.dialect; import org.hibernate.MappingException; import org.hibernate.dialect.identity.IdentityColumnSupportImpl; diff --git a/spring-data-rest/src/main/java/com/baeldung/events/AuthorEventHandler.java b/spring-data-rest/src/main/java/com/baeldung/books/events/AuthorEventHandler.java similarity index 89% rename from spring-data-rest/src/main/java/com/baeldung/events/AuthorEventHandler.java rename to spring-data-rest/src/main/java/com/baeldung/books/events/AuthorEventHandler.java index 485dc8e221..b390a529ba 100644 --- a/spring-data-rest/src/main/java/com/baeldung/events/AuthorEventHandler.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/events/AuthorEventHandler.java @@ -1,9 +1,10 @@ -package com.baeldung.events; +package com.baeldung.books.events; -import com.baeldung.models.Author; -import com.baeldung.models.Book; import org.springframework.data.rest.core.annotation.*; +import com.baeldung.books.models.Author; +import com.baeldung.books.models.Book; + import java.util.logging.Logger; @RepositoryEventHandler diff --git a/spring-data-rest/src/main/java/com/baeldung/events/BookEventHandler.java b/spring-data-rest/src/main/java/com/baeldung/books/events/BookEventHandler.java similarity index 86% rename from spring-data-rest/src/main/java/com/baeldung/events/BookEventHandler.java rename to spring-data-rest/src/main/java/com/baeldung/books/events/BookEventHandler.java index 36ae62b926..0afb3a6279 100644 --- a/spring-data-rest/src/main/java/com/baeldung/events/BookEventHandler.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/events/BookEventHandler.java @@ -1,13 +1,15 @@ -package com.baeldung.events; +package com.baeldung.books.events; import java.util.logging.Logger; -import com.baeldung.models.Author; -import com.baeldung.models.Book; + import org.apache.commons.logging.Log; import org.springframework.data.rest.core.annotation.HandleAfterDelete; import org.springframework.data.rest.core.annotation.HandleBeforeCreate; import org.springframework.data.rest.core.annotation.RepositoryEventHandler; +import com.baeldung.books.models.Author; +import com.baeldung.books.models.Book; + @RepositoryEventHandler public class BookEventHandler { Logger logger = Logger.getLogger("Class BookEventHandler"); diff --git a/spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java b/spring-data-rest/src/main/java/com/baeldung/books/exception/handlers/RestResponseEntityExceptionHandler.java similarity index 94% rename from spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java rename to spring-data-rest/src/main/java/com/baeldung/books/exception/handlers/RestResponseEntityExceptionHandler.java index a3ef91f6d6..4a961e5250 100644 --- a/spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/exception/handlers/RestResponseEntityExceptionHandler.java @@ -1,4 +1,4 @@ -package com.baeldung.exception.handlers; +package com.baeldung.books.exception.handlers; import org.springframework.data.rest.core.RepositoryConstraintViolationException; import org.springframework.http.HttpHeaders; diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Address.java b/spring-data-rest/src/main/java/com/baeldung/books/models/Address.java similarity index 96% rename from spring-data-rest/src/main/java/com/baeldung/models/Address.java rename to spring-data-rest/src/main/java/com/baeldung/books/models/Address.java index 713af58ae6..3c36db0f3c 100644 --- a/spring-data-rest/src/main/java/com/baeldung/models/Address.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/models/Address.java @@ -1,4 +1,4 @@ -package com.baeldung.models; +package com.baeldung.books.models; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Author.java b/spring-data-rest/src/main/java/com/baeldung/books/models/Author.java similarity index 97% rename from spring-data-rest/src/main/java/com/baeldung/models/Author.java rename to spring-data-rest/src/main/java/com/baeldung/books/models/Author.java index 3f43af9c47..aec2e62ebf 100644 --- a/spring-data-rest/src/main/java/com/baeldung/models/Author.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/models/Author.java @@ -1,4 +1,4 @@ -package com.baeldung.models; +package com.baeldung.books.models; import java.util.List; diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Book.java b/spring-data-rest/src/main/java/com/baeldung/books/models/Book.java similarity index 97% rename from spring-data-rest/src/main/java/com/baeldung/models/Book.java rename to spring-data-rest/src/main/java/com/baeldung/books/models/Book.java index 07b0d08b84..7451b04b3b 100644 --- a/spring-data-rest/src/main/java/com/baeldung/models/Book.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/models/Book.java @@ -1,4 +1,4 @@ -package com.baeldung.models; +package com.baeldung.books.models; import java.util.List; diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Library.java b/spring-data-rest/src/main/java/com/baeldung/books/models/Library.java similarity index 97% rename from spring-data-rest/src/main/java/com/baeldung/models/Library.java rename to spring-data-rest/src/main/java/com/baeldung/books/models/Library.java index 091975f5d0..5f95169a9b 100644 --- a/spring-data-rest/src/main/java/com/baeldung/models/Library.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/models/Library.java @@ -1,4 +1,4 @@ -package com.baeldung.models; +package com.baeldung.books.models; import java.util.List; diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Subject.java b/spring-data-rest/src/main/java/com/baeldung/books/models/Subject.java similarity index 94% rename from spring-data-rest/src/main/java/com/baeldung/models/Subject.java rename to spring-data-rest/src/main/java/com/baeldung/books/models/Subject.java index 4e5fa82148..11a4425fdd 100644 --- a/spring-data-rest/src/main/java/com/baeldung/models/Subject.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/models/Subject.java @@ -1,4 +1,4 @@ -package com.baeldung.models; +package com.baeldung.books.models; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/spring-data-rest/src/main/java/com/baeldung/models/WebsiteUser.java b/spring-data-rest/src/main/java/com/baeldung/books/models/WebsiteUser.java similarity index 95% rename from spring-data-rest/src/main/java/com/baeldung/models/WebsiteUser.java rename to spring-data-rest/src/main/java/com/baeldung/books/models/WebsiteUser.java index 4eb9773e36..e632623019 100644 --- a/spring-data-rest/src/main/java/com/baeldung/models/WebsiteUser.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/models/WebsiteUser.java @@ -1,4 +1,4 @@ -package com.baeldung.models; +package com.baeldung.books.models; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/spring-data-rest/src/main/java/com/baeldung/projections/CustomBook.java b/spring-data-rest/src/main/java/com/baeldung/books/projections/CustomBook.java similarity index 77% rename from spring-data-rest/src/main/java/com/baeldung/projections/CustomBook.java rename to spring-data-rest/src/main/java/com/baeldung/books/projections/CustomBook.java index 3dc6938f5c..5fe78c869d 100644 --- a/spring-data-rest/src/main/java/com/baeldung/projections/CustomBook.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/projections/CustomBook.java @@ -1,12 +1,12 @@ -package com.baeldung.projections; +package com.baeldung.books.projections; import java.util.List; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.rest.core.config.Projection; -import com.baeldung.models.Author; -import com.baeldung.models.Book; +import com.baeldung.books.models.Author; +import com.baeldung.books.models.Book; @Projection(name = "customBook", types = { Book.class }) public interface CustomBook { diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/AddressRepository.java b/spring-data-rest/src/main/java/com/baeldung/books/repositories/AddressRepository.java similarity index 62% rename from spring-data-rest/src/main/java/com/baeldung/repositories/AddressRepository.java rename to spring-data-rest/src/main/java/com/baeldung/books/repositories/AddressRepository.java index 1cc7527e80..5e3900f439 100644 --- a/spring-data-rest/src/main/java/com/baeldung/repositories/AddressRepository.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/repositories/AddressRepository.java @@ -1,8 +1,8 @@ -package com.baeldung.repositories; +package com.baeldung.books.repositories; import org.springframework.data.repository.CrudRepository; -import com.baeldung.models.Address; +import com.baeldung.books.models.Address; public interface AddressRepository extends CrudRepository { diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/AuthorRepository.java b/spring-data-rest/src/main/java/com/baeldung/books/repositories/AuthorRepository.java similarity index 62% rename from spring-data-rest/src/main/java/com/baeldung/repositories/AuthorRepository.java rename to spring-data-rest/src/main/java/com/baeldung/books/repositories/AuthorRepository.java index 2d470367ef..837e13b1d2 100644 --- a/spring-data-rest/src/main/java/com/baeldung/repositories/AuthorRepository.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/repositories/AuthorRepository.java @@ -1,8 +1,8 @@ -package com.baeldung.repositories; +package com.baeldung.books.repositories; import org.springframework.data.repository.CrudRepository; -import com.baeldung.models.Author; +import com.baeldung.books.models.Author; public interface AuthorRepository extends CrudRepository { diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/BookRepository.java b/spring-data-rest/src/main/java/com/baeldung/books/repositories/BookRepository.java similarity index 67% rename from spring-data-rest/src/main/java/com/baeldung/repositories/BookRepository.java rename to spring-data-rest/src/main/java/com/baeldung/books/repositories/BookRepository.java index eee44f35d4..5d7e277526 100644 --- a/spring-data-rest/src/main/java/com/baeldung/repositories/BookRepository.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/repositories/BookRepository.java @@ -1,10 +1,10 @@ -package com.baeldung.repositories; +package com.baeldung.books.repositories; import org.springframework.data.repository.CrudRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; -import com.baeldung.models.Book; -import com.baeldung.projections.CustomBook; +import com.baeldung.books.models.Book; +import com.baeldung.books.projections.CustomBook; @RepositoryRestResource(excerptProjection = CustomBook.class) public interface BookRepository extends CrudRepository { diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/LibraryRepository.java b/spring-data-rest/src/main/java/com/baeldung/books/repositories/LibraryRepository.java similarity index 62% rename from spring-data-rest/src/main/java/com/baeldung/repositories/LibraryRepository.java rename to spring-data-rest/src/main/java/com/baeldung/books/repositories/LibraryRepository.java index c00787f03c..92518339a0 100644 --- a/spring-data-rest/src/main/java/com/baeldung/repositories/LibraryRepository.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/repositories/LibraryRepository.java @@ -1,8 +1,8 @@ -package com.baeldung.repositories; +package com.baeldung.books.repositories; import org.springframework.data.repository.CrudRepository; -import com.baeldung.models.Library; +import com.baeldung.books.models.Library; public interface LibraryRepository extends CrudRepository { diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java b/spring-data-rest/src/main/java/com/baeldung/books/repositories/SubjectRepository.java similarity index 85% rename from spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java rename to spring-data-rest/src/main/java/com/baeldung/books/repositories/SubjectRepository.java index 76e34b0799..187b01f222 100644 --- a/spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/repositories/SubjectRepository.java @@ -1,11 +1,12 @@ -package com.baeldung.repositories; +package com.baeldung.books.repositories; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RestResource; -import com.baeldung.models.Subject; + +import com.baeldung.books.models.Subject; public interface SubjectRepository extends PagingAndSortingRepository { diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/UserRepository.java b/spring-data-rest/src/main/java/com/baeldung/books/repositories/UserRepository.java similarity index 91% rename from spring-data-rest/src/main/java/com/baeldung/repositories/UserRepository.java rename to spring-data-rest/src/main/java/com/baeldung/books/repositories/UserRepository.java index a3fed1c318..f0823338bc 100644 --- a/spring-data-rest/src/main/java/com/baeldung/repositories/UserRepository.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/repositories/UserRepository.java @@ -1,11 +1,12 @@ -package com.baeldung.repositories; +package com.baeldung.books.repositories; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RestResource; import org.springframework.web.bind.annotation.CrossOrigin; -import com.baeldung.models.WebsiteUser; + +import com.baeldung.books.models.WebsiteUser; @CrossOrigin @RepositoryRestResource(collectionResourceRel = "users", path = "users") diff --git a/spring-data-rest/src/main/java/com/baeldung/validators/WebsiteUserValidator.java b/spring-data-rest/src/main/java/com/baeldung/books/validators/WebsiteUserValidator.java similarity index 87% rename from spring-data-rest/src/main/java/com/baeldung/validators/WebsiteUserValidator.java rename to spring-data-rest/src/main/java/com/baeldung/books/validators/WebsiteUserValidator.java index 0380332708..ad7511c2ba 100644 --- a/spring-data-rest/src/main/java/com/baeldung/validators/WebsiteUserValidator.java +++ b/spring-data-rest/src/main/java/com/baeldung/books/validators/WebsiteUserValidator.java @@ -1,10 +1,10 @@ -package com.baeldung.validators; +package com.baeldung.books.validators; import org.springframework.stereotype.Component; import org.springframework.validation.Errors; import org.springframework.validation.Validator; -import com.baeldung.models.WebsiteUser; +import com.baeldung.books.models.WebsiteUser; @Component("beforeCreateWebsiteUserValidator") public class WebsiteUserValidator implements Validator { diff --git a/spring-data-rest/src/test/java/com/baeldung/events/AuthorEventHandlerUnitTest.java b/spring-data-rest/src/test/java/com/baeldung/books/events/AuthorEventHandlerUnitTest.java similarity index 86% rename from spring-data-rest/src/test/java/com/baeldung/events/AuthorEventHandlerUnitTest.java rename to spring-data-rest/src/test/java/com/baeldung/books/events/AuthorEventHandlerUnitTest.java index c01d5882a0..719c4d7c86 100644 --- a/spring-data-rest/src/test/java/com/baeldung/events/AuthorEventHandlerUnitTest.java +++ b/spring-data-rest/src/test/java/com/baeldung/books/events/AuthorEventHandlerUnitTest.java @@ -1,6 +1,8 @@ -package com.baeldung.events; +package com.baeldung.books.events; + +import com.baeldung.books.events.AuthorEventHandler; +import com.baeldung.books.models.Author; -import com.baeldung.models.Author; import org.junit.Test; import org.mockito.Mockito; import org.springframework.data.rest.core.annotation.RepositoryEventHandler; diff --git a/spring-data-rest/src/test/java/com/baeldung/events/BookEventHandlerUnitTest.java b/spring-data-rest/src/test/java/com/baeldung/books/events/BookEventHandlerUnitTest.java similarity index 81% rename from spring-data-rest/src/test/java/com/baeldung/events/BookEventHandlerUnitTest.java rename to spring-data-rest/src/test/java/com/baeldung/books/events/BookEventHandlerUnitTest.java index d6b8b3b25e..4b9d77afa2 100644 --- a/spring-data-rest/src/test/java/com/baeldung/events/BookEventHandlerUnitTest.java +++ b/spring-data-rest/src/test/java/com/baeldung/books/events/BookEventHandlerUnitTest.java @@ -1,7 +1,9 @@ -package com.baeldung.events; +package com.baeldung.books.events; + +import com.baeldung.books.events.BookEventHandler; +import com.baeldung.books.models.Author; +import com.baeldung.books.models.Book; -import com.baeldung.models.Author; -import com.baeldung.models.Book; import org.junit.Test; import org.mockito.Mockito; diff --git a/spring-data-rest/src/test/java/com/baeldung/projection/SpringDataProjectionLiveTest.java b/spring-data-rest/src/test/java/com/baeldung/books/projections/SpringDataProjectionLiveTest.java similarity index 91% rename from spring-data-rest/src/test/java/com/baeldung/projection/SpringDataProjectionLiveTest.java rename to spring-data-rest/src/test/java/com/baeldung/books/projections/SpringDataProjectionLiveTest.java index 274ae3bc1d..98b5831b96 100644 --- a/spring-data-rest/src/test/java/com/baeldung/projection/SpringDataProjectionLiveTest.java +++ b/spring-data-rest/src/test/java/com/baeldung/books/projections/SpringDataProjectionLiveTest.java @@ -1,4 +1,4 @@ -package com.baeldung.projection; +package com.baeldung.books.projections; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -16,11 +16,11 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.SpringDataRestApplication; -import com.baeldung.models.Author; -import com.baeldung.models.Book; -import com.baeldung.repositories.AuthorRepository; -import com.baeldung.repositories.BookRepository; +import com.baeldung.books.SpringDataRestApplication; +import com.baeldung.books.models.Author; +import com.baeldung.books.models.Book; +import com.baeldung.books.repositories.AuthorRepository; +import com.baeldung.books.repositories.BookRepository; @RunWith(SpringRunner.class) @SpringBootTest(classes = SpringDataRestApplication.class, webEnvironment = WebEnvironment.DEFINED_PORT) diff --git a/spring-data-rest/src/test/java/com/baeldung/validator/SpringDataRestValidatorIntegrationTest.java b/spring-data-rest/src/test/java/com/baeldung/books/validator/SpringDataRestValidatorIntegrationTest.java similarity index 97% rename from spring-data-rest/src/test/java/com/baeldung/validator/SpringDataRestValidatorIntegrationTest.java rename to spring-data-rest/src/test/java/com/baeldung/books/validator/SpringDataRestValidatorIntegrationTest.java index 6da76d6a33..75733475e7 100644 --- a/spring-data-rest/src/test/java/com/baeldung/validator/SpringDataRestValidatorIntegrationTest.java +++ b/spring-data-rest/src/test/java/com/baeldung/books/validator/SpringDataRestValidatorIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.validator; +package com.baeldung.books.validator; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; @@ -19,8 +19,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.web.context.WebApplicationContext; -import com.baeldung.SpringDataRestApplication; -import com.baeldung.models.WebsiteUser; +import com.baeldung.books.SpringDataRestApplication; +import com.baeldung.books.models.WebsiteUser; import com.fasterxml.jackson.databind.ObjectMapper; @RunWith(SpringJUnit4ClassRunner.class) diff --git a/spring-data-rest/src/test/java/com/baeldung/springdatawebsupport/application/test/UserControllerIntegrationTest.java b/spring-data-rest/src/test/java/com/baeldung/springdatawebsupport/application/test/UserControllerIntegrationTest.java index e1aff7e09d..d7ef361783 100644 --- a/spring-data-rest/src/test/java/com/baeldung/springdatawebsupport/application/test/UserControllerIntegrationTest.java +++ b/spring-data-rest/src/test/java/com/baeldung/springdatawebsupport/application/test/UserControllerIntegrationTest.java @@ -42,7 +42,7 @@ public class UserControllerIntegrationTest { @Test public void whenGetRequestToUserEndPointWithNameRequestParameter_thenCorrectResponse() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.get("/user").param("name", "John").contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(MockMvcResultMatchers.status().isOk()) + mockMvc.perform(MockMvcRequestBuilders.get("/users").param("name", "John").contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.jsonPath("$['content'][0].['name']").value("John")); } diff --git a/spring-data-rest/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-data-rest/src/test/java/org/baeldung/SpringContextIntegrationTest.java index 0380e3dc2f..c2682855b8 100644 --- a/spring-data-rest/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-data-rest/src/test/java/org/baeldung/SpringContextIntegrationTest.java @@ -5,7 +5,7 @@ import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.SpringDataRestApplication; +import com.baeldung.books.SpringDataRestApplication; @RunWith(SpringRunner.class) @SpringBootTest(classes = SpringDataRestApplication.class)