DATAJPA-1451 - Make Assert messages consistent.
Assert for notEmpty rather than length > 0. Make the messages match the actual assertion. Original pull request: #303.
This commit is contained in:
committed by
Jens Schauder
parent
44b839ff88
commit
1d57a05f7f
@@ -34,6 +34,7 @@ import org.springframework.util.Assert;
|
||||
* @author Thomas Darimont
|
||||
* @author Oliver Gierke
|
||||
* @author Christoph Strobl
|
||||
* @author David Madden
|
||||
*/
|
||||
public class JpaSort extends Sort {
|
||||
|
||||
@@ -132,7 +133,7 @@ public class JpaSort extends Sort {
|
||||
*/
|
||||
public JpaSort andUnsafe(@Nullable Direction direction, String... properties) {
|
||||
|
||||
Assert.notEmpty(properties, "Properties must not be null!");
|
||||
Assert.notEmpty(properties, "Properties must not be empty!");
|
||||
|
||||
List<Order> orders = new ArrayList<Order>();
|
||||
|
||||
@@ -156,7 +157,7 @@ public class JpaSort extends Sort {
|
||||
private static Path<?, ?>[] paths(Attribute<?, ?>[] attributes) {
|
||||
|
||||
Assert.notNull(attributes, "Attributes must not be null!");
|
||||
Assert.isTrue(attributes.length > 0, "Attributes must not be empty");
|
||||
Assert.notEmpty(attributes, "Attributes must not be empty!");
|
||||
|
||||
Path<?, ?>[] paths = new Path[attributes.length];
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.util.Assert;
|
||||
* @author Oliver Gierke
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @author David Madden
|
||||
* @since 1.3
|
||||
*/
|
||||
public class JpaMetamodelMappingContext
|
||||
@@ -54,7 +55,7 @@ public class JpaMetamodelMappingContext
|
||||
public JpaMetamodelMappingContext(Set<Metamodel> models) {
|
||||
|
||||
Assert.notNull(models, "JPA metamodel must not be null!");
|
||||
Assert.notEmpty(models, "At least one JPA metamodel must be present!");
|
||||
Assert.notEmpty(models, "JPA metamodel must not be empty!");
|
||||
|
||||
this.models = new Metamodels(models);
|
||||
this.persistenceProvider = PersistenceProvider.fromMetamodel(models.iterator().next());
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.util.Assert;
|
||||
* @author Thomas Darimont
|
||||
* @author Jens Schauder
|
||||
* @author Tom Hombergs
|
||||
* @author David Madden
|
||||
*/
|
||||
abstract class AbstractStringBasedJpaQuery extends AbstractJpaQuery {
|
||||
|
||||
@@ -60,7 +61,7 @@ abstract class AbstractStringBasedJpaQuery extends AbstractJpaQuery {
|
||||
|
||||
Assert.hasText(queryString, "Query string must not be null or empty!");
|
||||
Assert.notNull(evaluationContextProvider, "ExpressionEvaluationContextProvider must not be null!");
|
||||
Assert.notNull(parser, "Parser must not be null or empty!");
|
||||
Assert.notNull(parser, "Parser must not be null!");
|
||||
|
||||
this.evaluationContextProvider = evaluationContextProvider;
|
||||
this.query = new ExpressionBasedStringQuery(queryString, method.getEntityInformation(), parser);
|
||||
|
||||
@@ -68,6 +68,7 @@ import org.springframework.util.Assert;
|
||||
* @author Christoph Strobl
|
||||
* @author Stefan Fussenegger
|
||||
* @author Jens Schauder
|
||||
* @author David Madden
|
||||
* @param <T> the type of the entity to handle
|
||||
* @param <ID> the type of the entity's identifier
|
||||
*/
|
||||
@@ -167,7 +168,7 @@ public class SimpleJpaRepository<T, ID> implements JpaRepositoryImplementation<T
|
||||
@Override
|
||||
public void delete(T entity) {
|
||||
|
||||
Assert.notNull(entity, "The entity must not be null!");
|
||||
Assert.notNull(entity, "Entity must not be null!");
|
||||
|
||||
if (entityInformation.isNew(entity)) {
|
||||
return;
|
||||
@@ -178,7 +179,6 @@ public class SimpleJpaRepository<T, ID> implements JpaRepositoryImplementation<T
|
||||
if (existing == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
em.remove(em.contains(entity) ? entity : em.merge(entity));
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ public class SimpleJpaRepository<T, ID> implements JpaRepositoryImplementation<T
|
||||
@Override
|
||||
public void deleteAll(Iterable<? extends T> entities) {
|
||||
|
||||
Assert.notNull(entities, "The given Iterable of entities not be null!");
|
||||
Assert.notNull(entities, "Entities must not be null!");
|
||||
|
||||
for (T entity : entities) {
|
||||
delete(entity);
|
||||
@@ -205,7 +205,7 @@ public class SimpleJpaRepository<T, ID> implements JpaRepositoryImplementation<T
|
||||
@Override
|
||||
public void deleteInBatch(Iterable<T> entities) {
|
||||
|
||||
Assert.notNull(entities, "The given Iterable of entities not be null!");
|
||||
Assert.notNull(entities, "Entities must not be null!");
|
||||
|
||||
if (!entities.iterator().hasNext()) {
|
||||
return;
|
||||
@@ -341,7 +341,7 @@ public class SimpleJpaRepository<T, ID> implements JpaRepositoryImplementation<T
|
||||
@Override
|
||||
public List<T> findAllById(Iterable<ID> ids) {
|
||||
|
||||
Assert.notNull(ids, "The given Iterable of Id's must not be null!");
|
||||
Assert.notNull(ids, "Ids must not be null!");
|
||||
|
||||
if (!ids.iterator().hasNext()) {
|
||||
return Collections.emptyList();
|
||||
@@ -553,7 +553,7 @@ public class SimpleJpaRepository<T, ID> implements JpaRepositoryImplementation<T
|
||||
@Override
|
||||
public <S extends T> List<S> saveAll(Iterable<S> entities) {
|
||||
|
||||
Assert.notNull(entities, "The given Iterable of entities not be null!");
|
||||
Assert.notNull(entities, "Entities must not be null!");
|
||||
|
||||
List<S> result = new ArrayList<S>();
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
* @author Mark Paluch
|
||||
* @author David Madden
|
||||
*/
|
||||
public class ClasspathScanningPersistenceUnitPostProcessor
|
||||
implements PersistenceUnitPostProcessor, ResourceLoaderAware, EnvironmentAware {
|
||||
@@ -73,7 +74,7 @@ public class ClasspathScanningPersistenceUnitPostProcessor
|
||||
*/
|
||||
public ClasspathScanningPersistenceUnitPostProcessor(String basePackage) {
|
||||
|
||||
Assert.hasText(basePackage, "Base package must not be null!");
|
||||
Assert.hasText(basePackage, "Base package must not be null or empty!");
|
||||
|
||||
this.basePackage = basePackage;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user