Skip to content

Commit

Permalink
Fix null return value in NamedEntity.toString
Browse files Browse the repository at this point in the history
  • Loading branch information
glts committed Apr 2, 2016
1 parent 33aaa27 commit c4068e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.springframework.samples.petclinic.model;

import java.util.Objects;

import javax.annotation.Nullable;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
Expand Down Expand Up @@ -44,7 +46,7 @@ public void setName(@Nullable String name) {

@Override
public String toString() {
return this.getName();
return Objects.toString(getName());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.springframework.samples.petclinic.model;

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

import org.junit.Test;

public class NamedEntityTests {
@Test
public void toStringReturnsNonNullString() {
assertThat(new Pet().toString()).isEqualTo("null");
}
}

0 comments on commit c4068e0

Please sign in to comment.