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.
This commit is contained in:
Mark Paluch
2017-02-01 09:37:25 +01:00
parent a612f4a2ac
commit b06f8664f1
6 changed files with 22 additions and 16 deletions

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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);