From b06f8664f1551e8d2c3e2de9fc42f3bc6cf4425b Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 1 Feb 2017 09:37:25 +0100 Subject: [PATCH] DATAREST-992 - 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. --- .../mapping/PersistentEntitiesResourceMappings.java | 5 +++-- .../data/rest/tests/gemfire/Customer.java | 11 ++++++----- .../data/rest/tests/gemfire/Order.java | 7 ++++--- .../data/rest/tests/gemfire/Product.java | 5 +++-- .../data/rest/webmvc/ResourceProcessorInvoker.java | 5 +++-- .../ResourceProcessorInvokingHandlerAdapter.java | 5 +++-- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/PersistentEntitiesResourceMappings.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/PersistentEntitiesResourceMappings.java index 99673ba04..26809184c 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/PersistentEntitiesResourceMappings.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/PersistentEntitiesResourceMappings.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-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. @@ -32,6 +32,7 @@ import org.springframework.util.ClassUtils; * {@link ResourceMappings} for {@link PersistentEntities}. * * @author Oliver Gierke + * @author Mark Paluch */ public class PersistentEntitiesResourceMappings implements ResourceMappings { @@ -133,7 +134,7 @@ public class PersistentEntitiesResourceMappings implements ResourceMappings { @Override public boolean exportsTopLevelResourceFor(String path) { - Assert.hasText(path); + Assert.hasText(path, "Path must not be null or empty!"); for (ResourceMetadata metadata : this) { if (metadata.getPath().matches(path)) { diff --git a/spring-data-rest-tests/spring-data-rest-tests-gemfire/src/main/java/org/springframework/data/rest/tests/gemfire/Customer.java b/spring-data-rest-tests/spring-data-rest-tests-gemfire/src/main/java/org/springframework/data/rest/tests/gemfire/Customer.java index 8ba934261..71105e817 100644 --- a/spring-data-rest-tests/spring-data-rest-tests-gemfire/src/main/java/org/springframework/data/rest/tests/gemfire/Customer.java +++ b/spring-data-rest-tests/spring-data-rest-tests-gemfire/src/main/java/org/springframework/data/rest/tests/gemfire/Customer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-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. @@ -27,6 +27,7 @@ import org.springframework.util.Assert; * * @author Oliver Gierke * @author David Turanski + * @author Mark Paluch */ @Region public class Customer extends AbstractPersistentEntity { @@ -44,9 +45,9 @@ public class Customer extends AbstractPersistentEntity { */ public Customer(Long id, EmailAddress emailAddress, String firstname, String lastname) { super(id); - Assert.hasText(firstname); - Assert.hasText(lastname); - Assert.notNull(emailAddress); + Assert.hasText(firstname, "Firstname must not be null or empty!"); + Assert.hasText(lastname, "Lastname must not be null or empty!"); + Assert.notNull(emailAddress, "EmailAddress must not be null!"); this.firstname = firstname; this.lastname = lastname; @@ -62,7 +63,7 @@ public class Customer extends AbstractPersistentEntity { */ public void add(Address address) { - Assert.notNull(address); + Assert.notNull(address, "Address must not be null!"); this.addresses.add(address); } diff --git a/spring-data-rest-tests/spring-data-rest-tests-gemfire/src/main/java/org/springframework/data/rest/tests/gemfire/Order.java b/spring-data-rest-tests/spring-data-rest-tests-gemfire/src/main/java/org/springframework/data/rest/tests/gemfire/Order.java index 00bccda2f..92ffcf181 100644 --- a/spring-data-rest-tests/spring-data-rest-tests-gemfire/src/main/java/org/springframework/data/rest/tests/gemfire/Order.java +++ b/spring-data-rest-tests/spring-data-rest-tests-gemfire/src/main/java/org/springframework/data/rest/tests/gemfire/Order.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-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. @@ -26,6 +26,7 @@ import org.springframework.util.Assert; /** * @author Oliver Gierke * @author David Turanski + * @author Mark Paluch */ @Region public class Order extends AbstractPersistentEntity { @@ -44,8 +45,8 @@ public class Order extends AbstractPersistentEntity { */ public Order(Long id, Long customerId, Address shippingAddress) { super(id); - Assert.notNull(customerId); - Assert.notNull(shippingAddress); + Assert.notNull(customerId, "CustomerId must not be null!"); + Assert.notNull(shippingAddress, "ShippingAddress must not be null!"); this.customerId = customerId; this.shippingAddress = shippingAddress; diff --git a/spring-data-rest-tests/spring-data-rest-tests-gemfire/src/main/java/org/springframework/data/rest/tests/gemfire/Product.java b/spring-data-rest-tests/spring-data-rest-tests-gemfire/src/main/java/org/springframework/data/rest/tests/gemfire/Product.java index 3b187493e..0835a464e 100644 --- a/spring-data-rest-tests/spring-data-rest-tests-gemfire/src/main/java/org/springframework/data/rest/tests/gemfire/Product.java +++ b/spring-data-rest-tests/spring-data-rest-tests-gemfire/src/main/java/org/springframework/data/rest/tests/gemfire/Product.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-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 Oliver Gierke * @author David Turanski + * @author Mark Paluch */ @Region public class Product extends AbstractPersistentEntity { @@ -77,7 +78,7 @@ public class Product extends AbstractPersistentEntity { */ public void setAttribute(String name, String value) { - Assert.hasText(name); + Assert.hasText(name, "Name must not be null or empty!"); if (value == null) { this.attributes.remove(value); diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorInvoker.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorInvoker.java index a15041144..74103311a 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorInvoker.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorInvoker.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -37,6 +37,7 @@ import org.springframework.util.ReflectionUtils; * {@link ResourceSupport}. * * @author Oliver Gierke + * @author Mark Paluch * @since 2.5 * @deprecated use the same type from Spring HATEOAS, will be removed in 2.7. */ @@ -200,7 +201,7 @@ public class ResourceProcessorInvoker { */ public DefaultProcessorWrapper(ResourceProcessor processor) { - Assert.notNull(processor); + Assert.notNull(processor, "ResourceProcessor must not be null!"); this.processor = processor; this.targetType = ResolvableType.forClass(ResourceProcessor.class, processor.getClass()).getGeneric(0); diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorInvokingHandlerAdapter.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorInvokingHandlerAdapter.java index aa053e801..313f3af59 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorInvokingHandlerAdapter.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorInvokingHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-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. @@ -38,6 +38,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl * * @author Oliver Gierke * @author Phil Webb + * @author Mark Paluch * @deprecated use the same type from Spring HATEOAS, will be removed in 2.7. */ @Deprecated @@ -56,7 +57,7 @@ public class ResourceProcessorInvokingHandlerAdapter extends RequestMappingHandl @Autowired(required = false) public ResourceProcessorInvokingHandlerAdapter(ResourceProcessorInvoker invoker) { - Assert.notNull(invoker); + Assert.notNull(invoker, "ResourceProcessorInvoker must not be null!"); this.invoker = invoker; }