Skip to content

Commit

Permalink
Tidy up compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyer committed Jan 11, 2018
1 parent 14ef611 commit cf35266
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.NotEmpty;

/**
* Simple JavaBean domain object representing an person.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotEmpty;

import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.beans.support.MutableSortDefinition;
import org.springframework.beans.support.PropertyComparator;
import org.springframework.core.style.ToStringCreator;
Expand Down Expand Up @@ -61,7 +61,6 @@ public class Owner extends Person {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
private Set<Pet> pets;


public String getAddress() {
return this.address;
}
Expand Down Expand Up @@ -99,7 +98,8 @@ protected void setPetsInternal(Set<Pet> pets) {

public List<Pet> getPets() {
List<Pet> sortedPets = new ArrayList<>(getPetsInternal());
PropertyComparator.sort(sortedPets, new MutableSortDefinition("name", true, true));
PropertyComparator.sort(sortedPets,
new MutableSortDefinition("name", true, true));
return Collections.unmodifiableList(sortedPets);
}

Expand Down Expand Up @@ -144,13 +144,9 @@ public Pet getPet(String name, boolean ignoreNew) {
public String toString() {
return new ToStringCreator(this)

.append("id", this.getId())
.append("new", this.isNew())
.append("lastName", this.getLastName())
.append("firstName", this.getFirstName())
.append("address", this.address)
.append("city", this.city)
.append("telephone", this.telephone)
.toString();
.append("id", this.getId()).append("new", this.isNew())
.append("lastName", this.getLastName())
.append("firstName", this.getFirstName()).append("address", this.address)
.append("city", this.city).append("telephone", this.telephone).toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
* Controller used to showcase what happens when an exception is thrown
Expand All @@ -32,8 +30,8 @@ class CrashController {

@GetMapping("/oups")
public String triggerException() {
throw new RuntimeException(
"Expected: controller used to showcase what " + "happens when an exception is thrown");
throw new RuntimeException("Expected: controller used to showcase what "
+ "happens when an exception is thrown");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotEmpty;

import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.samples.petclinic.model.BaseEntity;

Expand All @@ -46,44 +46,36 @@ public class Visit extends BaseEntity {
@Column(name = "description")
private String description;


@Column(name = "pet_id")
private Integer petId;


/**
* Creates a new instance of Visit for the current date
*/
public Visit() {
this.date = new Date();
}


public Date getDate() {
return this.date;
}


public void setDate(Date date) {
this.date = date;
}


public String getDescription() {
return this.description;
}


public void setDescription(String description) {
this.description = description;
}


public Integer getPetId() {
return this.petId;
}


public void setPetId(Integer petId) {
this.petId = petId;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package org.springframework.samples.petclinic.model;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.Locale;
import java.util.Set;

import javax.validation.ConstraintViolation;
import javax.validation.Validator;

import org.junit.Test;

import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;

import static org.assertj.core.api.Assertions.assertThat;

/**
* @author Michael Isvy
* Simple test to make sure that Bean Validation is working
* (useful when upgrading to a new version of Hibernate Validator/ Bean Validation)
* @author Michael Isvy Simple test to make sure that Bean Validation is working (useful
* when upgrading to a new version of Hibernate Validator/ Bean Validation)
*/
public class ValidatorTests {

Expand All @@ -34,12 +34,13 @@ public void shouldNotValidateWhenFirstNameEmpty() {
person.setLastName("smith");

Validator validator = createValidator();
Set<ConstraintViolation<Person>> constraintViolations = validator.validate(person);
Set<ConstraintViolation<Person>> constraintViolations = validator
.validate(person);

assertThat(constraintViolations.size()).isEqualTo(1);
ConstraintViolation<Person> violation = constraintViolations.iterator().next();
assertThat(violation.getPropertyPath().toString()).isEqualTo("firstName");
assertThat(violation.getMessage()).isEqualTo("may not be empty");
assertThat(violation.getMessage()).isEqualTo("must not be empty");
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.springframework.samples.petclinic.owner;

import static org.junit.Assert.assertEquals;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -13,10 +11,9 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.samples.petclinic.owner.PetRepository;
import org.springframework.samples.petclinic.owner.PetType;
import org.springframework.samples.petclinic.owner.PetTypeFormatter;
import org.mockito.junit.MockitoJUnitRunner;

import static org.junit.Assert.assertEquals;

/**
* Test class for {@link PetTypeFormatter}
Expand Down Expand Up @@ -64,12 +61,12 @@ public void shouldThrowParseException() throws ParseException {
*/
private List<PetType> makePetTypes() {
List<PetType> petTypes = new ArrayList<>();
petTypes.add(new PetType(){
petTypes.add(new PetType() {
{
setName("Dog");
}
});
petTypes.add(new PetType(){
petTypes.add(new PetType() {
{
setName("Bird");
}
Expand Down

0 comments on commit cf35266

Please sign in to comment.