From 642eabeb9bfbf10ea00a4792a88aaa28a61f27c4 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Tue, 31 Jan 2017 15:21:33 +0100 Subject: [PATCH] DATAES-329 - Remove references to Assert single-arg methods. Replace references to Assert single-arg methods with references to methods accepting the test object and message. Related ticket: SPR-15196. --- .../core/convert/MappingElasticsearchConverter.java | 8 +++++--- .../data/elasticsearch/core/query/AbstractQuery.java | 7 +++++-- .../support/AbstractElasticsearchRepository.java | 11 ++++++++--- .../ElasticsearchEntityInformationCreatorImpl.java | 7 +++++-- .../support/ElasticsearchRepositoryFactory.java | 7 +++++-- .../support/ElasticsearchRepositoryFactoryBean.java | 7 +++++-- 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverter.java b/src/main/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverter.java index 60cdc9412..bb0b1e780 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverter.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,8 +31,8 @@ import org.springframework.util.Assert; * * @author Rizwan Idrees * @author Mohsin Husen + * @author Mark Paluch */ - public class MappingElasticsearchConverter implements ElasticsearchConverter, ApplicationContextAware { private final MappingContext, ElasticsearchPersistentProperty> mappingContext; @@ -43,7 +43,9 @@ public class MappingElasticsearchConverter implements ElasticsearchConverter, Ap public MappingElasticsearchConverter( MappingContext, ElasticsearchPersistentProperty> mappingContext) { - Assert.notNull(mappingContext); + + Assert.notNull(mappingContext, "MappingContext must not be null!"); + this.mappingContext = mappingContext; this.conversionService = new DefaultConversionService(); } diff --git a/src/main/java/org/springframework/data/elasticsearch/core/query/AbstractQuery.java b/src/main/java/org/springframework/data/elasticsearch/core/query/AbstractQuery.java index 2031902c7..030ce9b10 100755 --- a/src/main/java/org/springframework/data/elasticsearch/core/query/AbstractQuery.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/query/AbstractQuery.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2016 the original author or authors. + * Copyright 2013-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.util.Assert; * * @author Rizwan Idrees * @author Mohsin Husen + * @author Mark Paluch */ abstract class AbstractQuery implements Query { @@ -55,7 +56,9 @@ abstract class AbstractQuery implements Query { @Override public final T setPageable(Pageable pageable) { - Assert.notNull(pageable); + + Assert.notNull(pageable, "Pageable must not be null!"); + this.pageable = pageable; return (T) this.addSort(pageable.getSort()); } diff --git a/src/main/java/org/springframework/data/elasticsearch/repository/support/AbstractElasticsearchRepository.java b/src/main/java/org/springframework/data/elasticsearch/repository/support/AbstractElasticsearchRepository.java index c0ecda498..3cd3bc098 100644 --- a/src/main/java/org/springframework/data/elasticsearch/repository/support/AbstractElasticsearchRepository.java +++ b/src/main/java/org/springframework/data/elasticsearch/repository/support/AbstractElasticsearchRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2016 the original author or authors. + * Copyright 2013-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ import org.springframework.util.Assert; * @author Mohsin Husen * @author Ryan Henszey * @author Kevin Leturc + * @author Mark Paluch */ public abstract class AbstractElasticsearchRepository implements ElasticsearchRepository { @@ -56,14 +57,18 @@ public abstract class AbstractElasticsearchRepository metadata, ElasticsearchOperations elasticsearchOperations) { this(elasticsearchOperations); - Assert.notNull(metadata); + + Assert.notNull(metadata, "ElasticsearchEntityInformation must not be null!"); + this.entityInformation = metadata; setEntityClass(this.entityInformation.getJavaType()); try { diff --git a/src/main/java/org/springframework/data/elasticsearch/repository/support/ElasticsearchEntityInformationCreatorImpl.java b/src/main/java/org/springframework/data/elasticsearch/repository/support/ElasticsearchEntityInformationCreatorImpl.java index 8426b2f2f..6be8669ff 100644 --- a/src/main/java/org/springframework/data/elasticsearch/repository/support/ElasticsearchEntityInformationCreatorImpl.java +++ b/src/main/java/org/springframework/data/elasticsearch/repository/support/ElasticsearchEntityInformationCreatorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.util.Assert; * @author Rizwan Idrees * @author Mohsin Husen * @author Oliver Gierke + * @author Mark Paluch */ public class ElasticsearchEntityInformationCreatorImpl implements ElasticsearchEntityInformationCreator { @@ -35,7 +36,9 @@ public class ElasticsearchEntityInformationCreatorImpl implements ElasticsearchE public ElasticsearchEntityInformationCreatorImpl( MappingContext, ElasticsearchPersistentProperty> mappingContext) { - Assert.notNull(mappingContext); + + Assert.notNull(mappingContext, "MappingContext must not be null!"); + this.mappingContext = mappingContext; } diff --git a/src/main/java/org/springframework/data/elasticsearch/repository/support/ElasticsearchRepositoryFactory.java b/src/main/java/org/springframework/data/elasticsearch/repository/support/ElasticsearchRepositoryFactory.java index 8019dcf9b..3ee1ceef9 100644 --- a/src/main/java/org/springframework/data/elasticsearch/repository/support/ElasticsearchRepositoryFactory.java +++ b/src/main/java/org/springframework/data/elasticsearch/repository/support/ElasticsearchRepositoryFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ import org.springframework.util.Assert; * @author Mohsin Husen * @author Ryan Henszey * @author Gad Akuka + * @author Mark Paluch */ public class ElasticsearchRepositoryFactory extends RepositoryFactorySupport { @@ -50,7 +51,9 @@ public class ElasticsearchRepositoryFactory extends RepositoryFactorySupport { private final ElasticsearchEntityInformationCreator entityInformationCreator; public ElasticsearchRepositoryFactory(ElasticsearchOperations elasticsearchOperations) { - Assert.notNull(elasticsearchOperations); + + Assert.notNull(elasticsearchOperations, "ElasticsearchOperations must not be null!"); + this.elasticsearchOperations = elasticsearchOperations; this.entityInformationCreator = new ElasticsearchEntityInformationCreatorImpl(elasticsearchOperations .getElasticsearchConverter().getMappingContext()); diff --git a/src/main/java/org/springframework/data/elasticsearch/repository/support/ElasticsearchRepositoryFactoryBean.java b/src/main/java/org/springframework/data/elasticsearch/repository/support/ElasticsearchRepositoryFactoryBean.java index 7fcafb53f..991c263b6 100644 --- a/src/main/java/org/springframework/data/elasticsearch/repository/support/ElasticsearchRepositoryFactoryBean.java +++ b/src/main/java/org/springframework/data/elasticsearch/repository/support/ElasticsearchRepositoryFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.util.Assert; * * @author Rizwan Idrees * @author Mohsin Husen + * @author Mark Paluch */ public class ElasticsearchRepositoryFactoryBean, S, ID extends Serializable> extends RepositoryFactoryBeanSupport { @@ -50,7 +51,9 @@ public class ElasticsearchRepositoryFactoryBean, S, * @param operations the operations to set */ public void setElasticsearchOperations(ElasticsearchOperations operations) { - Assert.notNull(operations); + + Assert.notNull(operations, "ElasticsearchOperations must not be null!"); + setMappingContext(operations.getElasticsearchConverter().getMappingContext()); this.operations = operations; }