From 412136b8dbd85b768c19a2a5fdaf749c96474ecf Mon Sep 17 00:00:00 2001 From: Loredana Date: Sun, 11 Nov 2018 23:33:13 +0200 Subject: [PATCH] fix boot 2 upgrade, rename package --- .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 2 +- .../dao/GenericSpecificationsBuilder.java | 17 ++++++----- .../baeldung/persistence/dao/IUserDAO.java | 6 ++-- .../persistence/dao/MyUserPredicate.java | 7 ++--- .../dao/MyUserPredicatesBuilder.java | 5 ++-- .../persistence/dao/MyUserRepository.java | 4 +-- .../baeldung/persistence/dao/UserDAO.java | 7 +++-- .../persistence/dao/UserRepository.java | 5 ++-- .../dao/UserSearchQueryCriteriaConsumer.java | 4 +-- .../persistence/dao/UserSpecification.java | 7 +++-- .../dao/UserSpecificationsBuilder.java | 15 +++++----- .../dao/rsql/CustomRsqlVisitor.java | 2 +- .../dao/rsql/GenericRsqlSpecBuilder.java | 20 ++++++------- .../dao/rsql/GenericRsqlSpecification.java | 2 +- .../dao/rsql/RsqlSearchOperation.java | 2 +- .../baeldung/persistence/model/MyUser.java | 2 +- .../baeldung/persistence/model/User.java | 2 +- .../baeldung/persistence/model/User_.java | 2 +- .../baeldung/spring/Application.java | 2 +- .../baeldung/spring/PersistenceConfig.java | 2 +- .../baeldung/spring/WebConfig.java | 6 +--- .../web/controller/HomeController.java | 2 +- .../web/controller/UserController.java | 28 ++++++++--------- .../RestResponseEntityExceptionHandler.java | 5 ++-- .../MyResourceNotFoundException.java | 2 +- .../baeldung/web/util/CriteriaParser.java | 2 +- .../baeldung/web/util/SearchCriteria.java | 2 +- .../baeldung/web/util/SearchOperation.java | 2 +- .../baeldung/web/util/SpecSearchCriteria.java | 2 +- .../SpringContextIntegrationTest.java | 5 ++-- .../JPACriteriaQueryIntegrationTest.java | 11 +++---- .../query/JPAQuerydslIntegrationTest.java | 11 +++---- .../JPASpecificationIntegrationTest.java | 30 +++++++++---------- .../query/JPASpecificationLiveTest.java | 5 ++-- .../query/RsqlIntegrationTest.java | 11 +++---- .../baeldung/web/MyUserLiveTest.java | 5 ++-- 37 files changed, 125 insertions(+), 121 deletions(-) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/dao/GenericSpecificationsBuilder.java (86%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/dao/IUserDAO.java (52%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/dao/MyUserPredicate.java (92%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/dao/MyUserPredicatesBuilder.java (95%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/dao/MyUserRepository.java (91%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/dao/UserDAO.java (90%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/dao/UserRepository.java (74%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/dao/UserSearchQueryCriteriaConsumer.java (94%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/dao/UserSpecification.java (92%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/dao/UserSpecificationsBuilder.java (81%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/dao/rsql/CustomRsqlVisitor.java (95%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/dao/rsql/GenericRsqlSpecBuilder.java (59%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/dao/rsql/GenericRsqlSpecification.java (98%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/dao/rsql/RsqlSearchOperation.java (95%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/model/MyUser.java (98%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/model/User.java (97%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/persistence/model/User_.java (92%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/spring/Application.java (98%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/spring/PersistenceConfig.java (99%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/spring/WebConfig.java (93%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/web/controller/HomeController.java (87%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/web/controller/UserController.java (87%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/web/error/RestResponseEntityExceptionHandler.java (97%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/web/exception/MyResourceNotFoundException.java (92%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/web/util/CriteriaParser.java (98%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/web/util/SearchCriteria.java (96%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/web/util/SearchOperation.java (93%) rename spring-rest-query-language/src/main/java/{org => com}/baeldung/web/util/SpecSearchCriteria.java (95%) rename spring-rest-query-language/src/test/java/{org => com}/baeldung/SpringContextIntegrationTest.java (85%) rename spring-rest-query-language/src/test/java/{org => com}/baeldung/persistence/query/JPACriteriaQueryIntegrationTest.java (93%) rename spring-rest-query-language/src/test/java/{org => com}/baeldung/persistence/query/JPAQuerydslIntegrationTest.java (93%) rename spring-rest-query-language/src/test/java/{org => com}/baeldung/persistence/query/JPASpecificationIntegrationTest.java (89%) rename spring-rest-query-language/src/test/java/{org => com}/baeldung/persistence/query/JPASpecificationLiveTest.java (95%) rename spring-rest-query-language/src/test/java/{org => com}/baeldung/persistence/query/RsqlIntegrationTest.java (93%) rename spring-rest-query-language/src/test/java/{org => com}/baeldung/web/MyUserLiveTest.java (95%) diff --git a/spring-rest-angular/src/main/resources/application.properties b/spring-rest-angular/src/main/resources/application.properties index e24db89c8f..2571d286a3 100644 --- a/spring-rest-angular/src/main/resources/application.properties +++ b/spring-rest-angular/src/main/resources/application.properties @@ -1,4 +1,4 @@ -server.contextPath=/ +server.servlet.contextPath=/ spring.h2.console.enabled=true logging.level.org.hibernate.SQL=info spring.jpa.hibernate.ddl-auto=none \ No newline at end of file diff --git a/spring-rest-full/src/main/resources/application.properties b/spring-rest-full/src/main/resources/application.properties index 52d93b4cff..6c7461f12c 100644 --- a/spring-rest-full/src/main/resources/application.properties +++ b/spring-rest-full/src/main/resources/application.properties @@ -1,3 +1,3 @@ server.port=8082 -server.servlet.context-path=/spring-rest-full +server.context-path=/spring-rest-full endpoints.metrics.enabled=true \ No newline at end of file diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/GenericSpecificationsBuilder.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/GenericSpecificationsBuilder.java similarity index 86% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/GenericSpecificationsBuilder.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/GenericSpecificationsBuilder.java index 64bab9a435..75fb4456c4 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/GenericSpecificationsBuilder.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/GenericSpecificationsBuilder.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.dao; +package com.baeldung.persistence.dao; import java.util.ArrayList; import java.util.Collections; @@ -8,10 +8,10 @@ import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; -import org.baeldung.web.util.SearchOperation; -import org.baeldung.web.util.SpecSearchCriteria; import org.springframework.data.jpa.domain.Specification; -import org.springframework.data.jpa.domain.Specifications; + +import com.baeldung.web.util.SearchOperation; +import com.baeldung.web.util.SpecSearchCriteria; public class GenericSpecificationsBuilder { @@ -61,11 +61,12 @@ public class GenericSpecificationsBuilder { for (int idx = 1; idx < specs.size(); idx++) { result = params.get(idx) .isOrPredicate() - ? Specifications.where(result) + ? Specification.where(result) .or(specs.get(idx)) - : Specifications.where(result) + : Specification.where(result) .and(specs.get(idx)); } + return result; } @@ -84,10 +85,10 @@ public class GenericSpecificationsBuilder { Specification operand1 = specStack.pop(); Specification operand2 = specStack.pop(); if (mayBeOperand.equals(SearchOperation.AND_OPERATOR)) - specStack.push(Specifications.where(operand1) + specStack.push(Specification.where(operand1) .and(operand2)); else if (mayBeOperand.equals(SearchOperation.OR_OPERATOR)) - specStack.push(Specifications.where(operand1) + specStack.push(Specification.where(operand1) .or(operand2)); } diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/IUserDAO.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/IUserDAO.java similarity index 52% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/IUserDAO.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/IUserDAO.java index 4e74e94925..4837795792 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/IUserDAO.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/IUserDAO.java @@ -1,9 +1,9 @@ -package org.baeldung.persistence.dao; +package com.baeldung.persistence.dao; import java.util.List; -import org.baeldung.persistence.model.User; -import org.baeldung.web.util.SearchCriteria; +import com.baeldung.persistence.model.User; +import com.baeldung.web.util.SearchCriteria; public interface IUserDAO { List searchUser(List params); diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/MyUserPredicate.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserPredicate.java similarity index 92% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/MyUserPredicate.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserPredicate.java index 5dd4cdd17e..0c3a4a51f9 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/MyUserPredicate.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserPredicate.java @@ -1,8 +1,7 @@ -package org.baeldung.persistence.dao; - -import org.baeldung.persistence.model.MyUser; -import org.baeldung.web.util.SearchCriteria; +package com.baeldung.persistence.dao; +import com.baeldung.persistence.model.MyUser; +import com.baeldung.web.util.SearchCriteria; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.NumberPath; import com.querydsl.core.types.dsl.PathBuilder; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/MyUserPredicatesBuilder.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserPredicatesBuilder.java similarity index 95% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/MyUserPredicatesBuilder.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserPredicatesBuilder.java index 7be37c7155..6aad1a3bab 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/MyUserPredicatesBuilder.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserPredicatesBuilder.java @@ -1,12 +1,11 @@ -package org.baeldung.persistence.dao; +package com.baeldung.persistence.dao; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import org.baeldung.web.util.SearchCriteria; - +import com.baeldung.web.util.SearchCriteria; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.Expressions; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/MyUserRepository.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserRepository.java similarity index 91% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/MyUserRepository.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserRepository.java index 327d17e25a..0f04d084c3 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/MyUserRepository.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserRepository.java @@ -1,6 +1,5 @@ -package org.baeldung.persistence.dao; +package com.baeldung.persistence.dao; -import org.baeldung.persistence.model.MyUser; import org.baeldung.persistence.model.QMyUser; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.querydsl.QuerydslPredicateExecutor; @@ -8,6 +7,7 @@ import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; import org.springframework.data.querydsl.binding.QuerydslBindings; import org.springframework.data.querydsl.binding.SingleValueBinding; +import com.baeldung.persistence.model.MyUser; import com.querydsl.core.types.dsl.StringExpression; import com.querydsl.core.types.dsl.StringPath; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserDAO.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserDAO.java similarity index 90% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserDAO.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserDAO.java index 4f2f6003e4..6bc899176a 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserDAO.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserDAO.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.dao; +package com.baeldung.persistence.dao; import java.util.List; @@ -9,10 +9,11 @@ import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; -import org.baeldung.persistence.model.User; -import org.baeldung.web.util.SearchCriteria; import org.springframework.stereotype.Repository; +import com.baeldung.persistence.model.User; +import com.baeldung.web.util.SearchCriteria; + @Repository public class UserDAO implements IUserDAO { diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserRepository.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserRepository.java similarity index 74% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserRepository.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserRepository.java index de7acf60d5..1a7eda07ed 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserRepository.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserRepository.java @@ -1,9 +1,10 @@ -package org.baeldung.persistence.dao; +package com.baeldung.persistence.dao; -import org.baeldung.persistence.model.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import com.baeldung.persistence.model.User; + public interface UserRepository extends JpaRepository, JpaSpecificationExecutor { } diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserSearchQueryCriteriaConsumer.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSearchQueryCriteriaConsumer.java similarity index 94% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserSearchQueryCriteriaConsumer.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSearchQueryCriteriaConsumer.java index 8b15ef1605..a3e619ad21 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserSearchQueryCriteriaConsumer.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSearchQueryCriteriaConsumer.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.dao; +package com.baeldung.persistence.dao; import java.util.function.Consumer; @@ -6,7 +6,7 @@ import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; -import org.baeldung.web.util.SearchCriteria; +import com.baeldung.web.util.SearchCriteria; public class UserSearchQueryCriteriaConsumer implements Consumer{ diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserSpecification.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecification.java similarity index 92% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserSpecification.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecification.java index b2d9394500..928e75aea7 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserSpecification.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecification.java @@ -1,9 +1,10 @@ -package org.baeldung.persistence.dao; +package com.baeldung.persistence.dao; -import org.baeldung.persistence.model.User; -import org.baeldung.web.util.SpecSearchCriteria; import org.springframework.data.jpa.domain.Specification; +import com.baeldung.persistence.model.User; +import com.baeldung.web.util.SpecSearchCriteria; + import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Predicate; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserSpecificationsBuilder.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecificationsBuilder.java similarity index 81% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserSpecificationsBuilder.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecificationsBuilder.java index 28097d500a..72d7274226 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/UserSpecificationsBuilder.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecificationsBuilder.java @@ -1,14 +1,13 @@ -package org.baeldung.persistence.dao; +package com.baeldung.persistence.dao; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; -import org.baeldung.persistence.model.User; -import org.baeldung.web.util.SearchOperation; -import org.baeldung.web.util.SpecSearchCriteria; import org.springframework.data.jpa.domain.Specification; -import org.springframework.data.jpa.domain.Specifications; + +import com.baeldung.persistence.model.User; +import com.baeldung.web.util.SearchOperation; +import com.baeldung.web.util.SpecSearchCriteria; public final class UserSpecificationsBuilder { @@ -52,8 +51,8 @@ public final class UserSpecificationsBuilder { for (int i = 1; i < params.size(); i++) { result = params.get(i).isOrPredicate() - ? Specifications.where(result).or(new UserSpecification(params.get(i))) - : Specifications.where(result).and(new UserSpecification(params.get(i))); + ? Specification.where(result).or(new UserSpecification(params.get(i))) + : Specification.where(result).and(new UserSpecification(params.get(i))); } return result; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/rsql/CustomRsqlVisitor.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/CustomRsqlVisitor.java similarity index 95% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/rsql/CustomRsqlVisitor.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/CustomRsqlVisitor.java index 89cec89951..9c399e97ed 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/rsql/CustomRsqlVisitor.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/CustomRsqlVisitor.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.dao.rsql; +package com.baeldung.persistence.dao.rsql; import org.springframework.data.jpa.domain.Specification; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/rsql/GenericRsqlSpecBuilder.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecBuilder.java similarity index 59% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/rsql/GenericRsqlSpecBuilder.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecBuilder.java index ce5a4410b9..e81e9ab916 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/rsql/GenericRsqlSpecBuilder.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecBuilder.java @@ -1,10 +1,10 @@ -package org.baeldung.persistence.dao.rsql; +package com.baeldung.persistence.dao.rsql; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import org.springframework.data.jpa.domain.Specifications; +import org.springframework.data.jpa.domain.Specification; import cz.jirutka.rsql.parser.ast.ComparisonNode; import cz.jirutka.rsql.parser.ast.LogicalNode; @@ -13,7 +13,7 @@ import cz.jirutka.rsql.parser.ast.Node; public class GenericRsqlSpecBuilder { - public Specifications createSpecification(final Node node) { + public Specification createSpecification(final Node node) { if (node instanceof LogicalNode) { return createSpecification((LogicalNode) node); } @@ -23,31 +23,31 @@ public class GenericRsqlSpecBuilder { return null; } - public Specifications createSpecification(final LogicalNode logicalNode) { + public Specification createSpecification(final LogicalNode logicalNode) { - List> specs = logicalNode.getChildren() + List> specs = logicalNode.getChildren() .stream() .map(node -> createSpecification(node)) .filter(Objects::nonNull) .collect(Collectors.toList()); - Specifications result = specs.get(0); + Specification result = specs.get(0); if (logicalNode.getOperator() == LogicalOperator.AND) { for (int i = 1; i < specs.size(); i++) { - result = Specifications.where(result).and(specs.get(i)); + result = Specification.where(result).and(specs.get(i)); } } else if (logicalNode.getOperator() == LogicalOperator.OR) { for (int i = 1; i < specs.size(); i++) { - result = Specifications.where(result).or(specs.get(i)); + result = Specification.where(result).or(specs.get(i)); } } return result; } - public Specifications createSpecification(final ComparisonNode comparisonNode) { - return Specifications.where(new GenericRsqlSpecification(comparisonNode.getSelector(), comparisonNode.getOperator(), comparisonNode.getArguments())); + public Specification createSpecification(final ComparisonNode comparisonNode) { + return Specification.where(new GenericRsqlSpecification(comparisonNode.getSelector(), comparisonNode.getOperator(), comparisonNode.getArguments())); } } diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/rsql/GenericRsqlSpecification.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecification.java similarity index 98% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/rsql/GenericRsqlSpecification.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecification.java index 8055e959a6..87a46d4a85 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/rsql/GenericRsqlSpecification.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecification.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.dao.rsql; +package com.baeldung.persistence.dao.rsql; import java.util.List; import java.util.stream.Collectors; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/rsql/RsqlSearchOperation.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/RsqlSearchOperation.java similarity index 95% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/rsql/RsqlSearchOperation.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/RsqlSearchOperation.java index 673e78fbb4..81441fa609 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/rsql/RsqlSearchOperation.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/RsqlSearchOperation.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.dao.rsql; +package com.baeldung.persistence.dao.rsql; import cz.jirutka.rsql.parser.ast.ComparisonOperator; import cz.jirutka.rsql.parser.ast.RSQLOperators; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/model/MyUser.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/MyUser.java similarity index 98% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/model/MyUser.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/model/MyUser.java index 9a7bb4da3d..f3b9dc3810 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/model/MyUser.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/MyUser.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.model; +package com.baeldung.persistence.model; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/model/User.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/User.java similarity index 97% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/model/User.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/model/User.java index 670d4a2e74..dbc2b9360f 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/model/User.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/User.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.model; +package com.baeldung.persistence.model; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/model/User_.java b/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/User_.java similarity index 92% rename from spring-rest-query-language/src/main/java/org/baeldung/persistence/model/User_.java rename to spring-rest-query-language/src/main/java/com/baeldung/persistence/model/User_.java index b705c51ff8..c101b1d9b3 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/model/User_.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/User_.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.model; +package com.baeldung.persistence.model; import javax.persistence.metamodel.SingularAttribute; import javax.persistence.metamodel.StaticMetamodel; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/spring/Application.java b/spring-rest-query-language/src/main/java/com/baeldung/spring/Application.java similarity index 98% rename from spring-rest-query-language/src/main/java/org/baeldung/spring/Application.java rename to spring-rest-query-language/src/main/java/com/baeldung/spring/Application.java index 4a914d947e..83b3795084 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/spring/Application.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/spring/Application.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package com.baeldung.spring; import javax.servlet.ServletContext; import javax.servlet.ServletException; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-rest-query-language/src/main/java/com/baeldung/spring/PersistenceConfig.java similarity index 99% rename from spring-rest-query-language/src/main/java/org/baeldung/spring/PersistenceConfig.java rename to spring-rest-query-language/src/main/java/com/baeldung/spring/PersistenceConfig.java index f3a87b189e..ea64cfae50 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/spring/PersistenceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package com.baeldung.spring; import java.util.Properties; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/spring/WebConfig.java b/spring-rest-query-language/src/main/java/com/baeldung/spring/WebConfig.java similarity index 93% rename from spring-rest-query-language/src/main/java/org/baeldung/spring/WebConfig.java rename to spring-rest-query-language/src/main/java/com/baeldung/spring/WebConfig.java index 4139c69f95..2fac559ada 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/spring/WebConfig.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/spring/WebConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package com.baeldung.spring; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -14,10 +14,6 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver; @EnableWebMvc public class WebConfig implements WebMvcConfigurer { - public WebConfig() { - super(); - } - @Bean public ViewResolver viewResolver() { final InternalResourceViewResolver viewResolver = new InternalResourceViewResolver(); diff --git a/spring-rest-query-language/src/main/java/org/baeldung/web/controller/HomeController.java b/spring-rest-query-language/src/main/java/com/baeldung/web/controller/HomeController.java similarity index 87% rename from spring-rest-query-language/src/main/java/org/baeldung/web/controller/HomeController.java rename to spring-rest-query-language/src/main/java/com/baeldung/web/controller/HomeController.java index 9c4d14cae3..c82911211a 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/web/controller/HomeController.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/web/controller/HomeController.java @@ -1,4 +1,4 @@ -package org.baeldung.web.controller; +package com.baeldung.web.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/web/controller/UserController.java b/spring-rest-query-language/src/main/java/com/baeldung/web/controller/UserController.java similarity index 87% rename from spring-rest-query-language/src/main/java/org/baeldung/web/controller/UserController.java rename to spring-rest-query-language/src/main/java/com/baeldung/web/controller/UserController.java index 8953a52a1b..101231c7ab 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/web/controller/UserController.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/web/controller/UserController.java @@ -1,23 +1,10 @@ -package org.baeldung.web.controller; +package com.baeldung.web.controller; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.baeldung.persistence.dao.GenericSpecificationsBuilder; -import org.baeldung.persistence.dao.IUserDAO; -import org.baeldung.persistence.dao.MyUserPredicatesBuilder; -import org.baeldung.persistence.dao.MyUserRepository; -import org.baeldung.persistence.dao.UserRepository; -import org.baeldung.persistence.dao.UserSpecification; -import org.baeldung.persistence.dao.UserSpecificationsBuilder; -import org.baeldung.persistence.dao.rsql.CustomRsqlVisitor; -import org.baeldung.persistence.model.MyUser; -import org.baeldung.persistence.model.User; -import org.baeldung.web.util.CriteriaParser; -import org.baeldung.web.util.SearchCriteria; -import org.baeldung.web.util.SearchOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.querydsl.binding.QuerydslPredicate; @@ -31,6 +18,19 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; +import com.baeldung.persistence.dao.GenericSpecificationsBuilder; +import com.baeldung.persistence.dao.IUserDAO; +import com.baeldung.persistence.dao.MyUserPredicatesBuilder; +import com.baeldung.persistence.dao.MyUserRepository; +import com.baeldung.persistence.dao.UserRepository; +import com.baeldung.persistence.dao.UserSpecification; +import com.baeldung.persistence.dao.UserSpecificationsBuilder; +import com.baeldung.persistence.dao.rsql.CustomRsqlVisitor; +import com.baeldung.persistence.model.MyUser; +import com.baeldung.persistence.model.User; +import com.baeldung.web.util.CriteriaParser; +import com.baeldung.web.util.SearchCriteria; +import com.baeldung.web.util.SearchOperation; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.querydsl.core.types.Predicate; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java b/spring-rest-query-language/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java similarity index 97% rename from spring-rest-query-language/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java rename to spring-rest-query-language/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java index b593116c4a..b30f435ee4 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java @@ -1,8 +1,7 @@ -package org.baeldung.web.error; +package com.baeldung.web.error; import javax.persistence.EntityNotFoundException; -import org.baeldung.web.exception.MyResourceNotFoundException; import org.hibernate.exception.ConstraintViolationException; import org.springframework.dao.DataAccessException; import org.springframework.dao.DataIntegrityViolationException; @@ -17,6 +16,8 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; +import com.baeldung.web.exception.MyResourceNotFoundException; + @ControllerAdvice public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler { diff --git a/spring-rest-query-language/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java b/spring-rest-query-language/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java similarity index 92% rename from spring-rest-query-language/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java rename to spring-rest-query-language/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java index 14b61f9832..fd002efc28 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java @@ -1,4 +1,4 @@ -package org.baeldung.web.exception; +package com.baeldung.web.exception; public final class MyResourceNotFoundException extends RuntimeException { diff --git a/spring-rest-query-language/src/main/java/org/baeldung/web/util/CriteriaParser.java b/spring-rest-query-language/src/main/java/com/baeldung/web/util/CriteriaParser.java similarity index 98% rename from spring-rest-query-language/src/main/java/org/baeldung/web/util/CriteriaParser.java rename to spring-rest-query-language/src/main/java/com/baeldung/web/util/CriteriaParser.java index a72d07f440..26bfb7a78d 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/web/util/CriteriaParser.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/web/util/CriteriaParser.java @@ -1,4 +1,4 @@ -package org.baeldung.web.util; +package com.baeldung.web.util; import java.util.Arrays; import java.util.Collections; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/web/util/SearchCriteria.java b/spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchCriteria.java similarity index 96% rename from spring-rest-query-language/src/main/java/org/baeldung/web/util/SearchCriteria.java rename to spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchCriteria.java index cbe1fe539e..75ecefb653 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/web/util/SearchCriteria.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchCriteria.java @@ -1,4 +1,4 @@ -package org.baeldung.web.util; +package com.baeldung.web.util; public class SearchCriteria { diff --git a/spring-rest-query-language/src/main/java/org/baeldung/web/util/SearchOperation.java b/spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchOperation.java similarity index 93% rename from spring-rest-query-language/src/main/java/org/baeldung/web/util/SearchOperation.java rename to spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchOperation.java index db2c0133cf..acc9e0c0a8 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/web/util/SearchOperation.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchOperation.java @@ -1,4 +1,4 @@ -package org.baeldung.web.util; +package com.baeldung.web.util; public enum SearchOperation { EQUALITY, NEGATION, GREATER_THAN, LESS_THAN, LIKE, STARTS_WITH, ENDS_WITH, CONTAINS; diff --git a/spring-rest-query-language/src/main/java/org/baeldung/web/util/SpecSearchCriteria.java b/spring-rest-query-language/src/main/java/com/baeldung/web/util/SpecSearchCriteria.java similarity index 95% rename from spring-rest-query-language/src/main/java/org/baeldung/web/util/SpecSearchCriteria.java rename to spring-rest-query-language/src/main/java/com/baeldung/web/util/SpecSearchCriteria.java index 3435ff3342..73b690673b 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/web/util/SpecSearchCriteria.java +++ b/spring-rest-query-language/src/main/java/com/baeldung/web/util/SpecSearchCriteria.java @@ -1,4 +1,4 @@ -package org.baeldung.web.util; +package com.baeldung.web.util; public class SpecSearchCriteria { diff --git a/spring-rest-query-language/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-rest-query-language/src/test/java/com/baeldung/SpringContextIntegrationTest.java similarity index 85% rename from spring-rest-query-language/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-rest-query-language/src/test/java/com/baeldung/SpringContextIntegrationTest.java index 35939c992f..18fabce5ca 100644 --- a/spring-rest-query-language/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-rest-query-language/src/test/java/com/baeldung/SpringContextIntegrationTest.java @@ -1,11 +1,12 @@ -package org.baeldung; +package com.baeldung; -import org.baeldung.spring.Application; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; +import com.baeldung.spring.Application; + @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) public class SpringContextIntegrationTest { diff --git a/spring-rest-query-language/src/test/java/org/baeldung/persistence/query/JPACriteriaQueryIntegrationTest.java b/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPACriteriaQueryIntegrationTest.java similarity index 93% rename from spring-rest-query-language/src/test/java/org/baeldung/persistence/query/JPACriteriaQueryIntegrationTest.java rename to spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPACriteriaQueryIntegrationTest.java index e8e98074c6..6caabef628 100644 --- a/spring-rest-query-language/src/test/java/org/baeldung/persistence/query/JPACriteriaQueryIntegrationTest.java +++ b/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPACriteriaQueryIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.query; +package com.baeldung.persistence.query; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.collection.IsIn.isIn; @@ -7,10 +7,6 @@ import static org.hamcrest.core.IsNot.not; import java.util.ArrayList; import java.util.List; -import org.baeldung.persistence.dao.IUserDAO; -import org.baeldung.persistence.model.User; -import org.baeldung.spring.PersistenceConfig; -import org.baeldung.web.util.SearchCriteria; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -20,6 +16,11 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; +import com.baeldung.persistence.dao.IUserDAO; +import com.baeldung.persistence.model.User; +import com.baeldung.spring.PersistenceConfig; +import com.baeldung.web.util.SearchCriteria; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }) @Transactional diff --git a/spring-rest-query-language/src/test/java/org/baeldung/persistence/query/JPAQuerydslIntegrationTest.java b/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPAQuerydslIntegrationTest.java similarity index 93% rename from spring-rest-query-language/src/test/java/org/baeldung/persistence/query/JPAQuerydslIntegrationTest.java rename to spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPAQuerydslIntegrationTest.java index d397c3aac4..c4c5d23ab5 100644 --- a/spring-rest-query-language/src/test/java/org/baeldung/persistence/query/JPAQuerydslIntegrationTest.java +++ b/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPAQuerydslIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.query; +package com.baeldung.persistence.query; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.collection.IsEmptyIterable.emptyIterable; @@ -6,10 +6,6 @@ import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInA import static org.hamcrest.collection.IsIterableContainingInOrder.contains; import static org.hamcrest.core.IsNot.not; -import org.baeldung.persistence.dao.MyUserPredicatesBuilder; -import org.baeldung.persistence.dao.MyUserRepository; -import org.baeldung.persistence.model.MyUser; -import org.baeldung.spring.PersistenceConfig; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -19,6 +15,11 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; +import com.baeldung.persistence.dao.MyUserPredicatesBuilder; +import com.baeldung.persistence.dao.MyUserRepository; +import com.baeldung.persistence.model.MyUser; +import com.baeldung.spring.PersistenceConfig; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }) @Transactional diff --git a/spring-rest-query-language/src/test/java/org/baeldung/persistence/query/JPASpecificationIntegrationTest.java b/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationIntegrationTest.java similarity index 89% rename from spring-rest-query-language/src/test/java/org/baeldung/persistence/query/JPASpecificationIntegrationTest.java rename to spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationIntegrationTest.java index d9ae95c876..707426769e 100644 --- a/spring-rest-query-language/src/test/java/org/baeldung/persistence/query/JPASpecificationIntegrationTest.java +++ b/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationIntegrationTest.java @@ -1,25 +1,25 @@ -package org.baeldung.persistence.query; +package com.baeldung.persistence.query; -import org.baeldung.persistence.dao.GenericSpecificationsBuilder; -import org.baeldung.persistence.dao.UserRepository; -import org.baeldung.persistence.dao.UserSpecification; -import org.baeldung.persistence.dao.UserSpecificationsBuilder; -import org.baeldung.persistence.model.User; -import org.baeldung.spring.PersistenceConfig; -import org.baeldung.web.util.CriteriaParser; -import org.baeldung.web.util.SearchOperation; -import org.baeldung.web.util.SpecSearchCriteria; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.jpa.domain.Specification; -import org.springframework.data.jpa.domain.Specifications; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; +import com.baeldung.persistence.dao.GenericSpecificationsBuilder; +import com.baeldung.persistence.dao.UserRepository; +import com.baeldung.persistence.dao.UserSpecification; +import com.baeldung.persistence.dao.UserSpecificationsBuilder; +import com.baeldung.persistence.model.User; +import com.baeldung.spring.PersistenceConfig; +import com.baeldung.web.util.CriteriaParser; +import com.baeldung.web.util.SearchOperation; +import com.baeldung.web.util.SpecSearchCriteria; + import java.util.List; import java.util.function.Function; @@ -71,7 +71,7 @@ public class JPASpecificationIntegrationTest { public void givenFirstAndLastName_whenGettingListOfUsers_thenCorrect() { final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("firstName", SearchOperation.EQUALITY, "john")); final UserSpecification spec1 = new UserSpecification(new SpecSearchCriteria("lastName", SearchOperation.EQUALITY, "doe")); - final List results = repository.findAll(Specifications + final List results = repository.findAll(Specification .where(spec) .and(spec1)); @@ -127,7 +127,7 @@ public class JPASpecificationIntegrationTest { @Test public void givenFirstNameInverse_whenGettingListOfUsers_thenCorrect() { final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("firstName", SearchOperation.NEGATION, "john")); - final List results = repository.findAll(Specifications.where(spec)); + final List results = repository.findAll(Specification.where(spec)); assertThat(userTom, isIn(results)); assertThat(userJohn, not(isIn(results))); @@ -136,7 +136,7 @@ public class JPASpecificationIntegrationTest { @Test public void givenMinAge_whenGettingListOfUsers_thenCorrect() { final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("age", SearchOperation.GREATER_THAN, "25")); - final List results = repository.findAll(Specifications.where(spec)); + final List results = repository.findAll(Specification.where(spec)); assertThat(userTom, isIn(results)); assertThat(userJohn, not(isIn(results))); } @@ -170,7 +170,7 @@ public class JPASpecificationIntegrationTest { public void givenAgeRange_whenGettingListOfUsers_thenCorrect() { final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("age", SearchOperation.GREATER_THAN, "20")); final UserSpecification spec1 = new UserSpecification(new SpecSearchCriteria("age", SearchOperation.LESS_THAN, "25")); - final List results = repository.findAll(Specifications + final List results = repository.findAll(Specification .where(spec) .and(spec1)); diff --git a/spring-rest-query-language/src/test/java/org/baeldung/persistence/query/JPASpecificationLiveTest.java b/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationLiveTest.java similarity index 95% rename from spring-rest-query-language/src/test/java/org/baeldung/persistence/query/JPASpecificationLiveTest.java rename to spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationLiveTest.java index 044029c679..ad6a4259e7 100644 --- a/spring-rest-query-language/src/test/java/org/baeldung/persistence/query/JPASpecificationLiveTest.java +++ b/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationLiveTest.java @@ -1,15 +1,16 @@ -package org.baeldung.persistence.query; +package com.baeldung.persistence.query; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import io.restassured.RestAssured; import io.restassured.response.Response; -import org.baeldung.persistence.model.User; import org.junit.Before; import org.junit.Test; import org.springframework.test.context.ActiveProfiles; +import com.baeldung.persistence.model.User; + //@RunWith(SpringJUnit4ClassRunner.class) //@ContextConfiguration(classes = { ConfigTest.class, // PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) diff --git a/spring-rest-query-language/src/test/java/org/baeldung/persistence/query/RsqlIntegrationTest.java b/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/RsqlIntegrationTest.java similarity index 93% rename from spring-rest-query-language/src/test/java/org/baeldung/persistence/query/RsqlIntegrationTest.java rename to spring-rest-query-language/src/test/java/com/baeldung/persistence/query/RsqlIntegrationTest.java index 16dfa8a12f..b7b454892a 100644 --- a/spring-rest-query-language/src/test/java/org/baeldung/persistence/query/RsqlIntegrationTest.java +++ b/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/RsqlIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.query; +package com.baeldung.persistence.query; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.collection.IsIn.isIn; @@ -6,10 +6,6 @@ import static org.hamcrest.core.IsNot.not; import java.util.List; -import org.baeldung.persistence.dao.UserRepository; -import org.baeldung.persistence.dao.rsql.CustomRsqlVisitor; -import org.baeldung.persistence.model.User; -import org.baeldung.spring.PersistenceConfig; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -20,6 +16,11 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; +import com.baeldung.persistence.dao.UserRepository; +import com.baeldung.persistence.dao.rsql.CustomRsqlVisitor; +import com.baeldung.persistence.model.User; +import com.baeldung.spring.PersistenceConfig; + import cz.jirutka.rsql.parser.RSQLParser; import cz.jirutka.rsql.parser.ast.Node; diff --git a/spring-rest-query-language/src/test/java/org/baeldung/web/MyUserLiveTest.java b/spring-rest-query-language/src/test/java/com/baeldung/web/MyUserLiveTest.java similarity index 95% rename from spring-rest-query-language/src/test/java/org/baeldung/web/MyUserLiveTest.java rename to spring-rest-query-language/src/test/java/com/baeldung/web/MyUserLiveTest.java index a478016280..1d74ff1982 100644 --- a/spring-rest-query-language/src/test/java/org/baeldung/web/MyUserLiveTest.java +++ b/spring-rest-query-language/src/test/java/com/baeldung/web/MyUserLiveTest.java @@ -1,14 +1,15 @@ -package org.baeldung.web; +package com.baeldung.web; import static org.junit.Assert.assertEquals; import io.restassured.RestAssured; import io.restassured.response.Response; import io.restassured.specification.RequestSpecification; -import org.baeldung.persistence.model.MyUser; import org.junit.Test; import org.springframework.test.context.ActiveProfiles; +import com.baeldung.persistence.model.MyUser; + @ActiveProfiles("test") public class MyUserLiveTest {