ConstraintViolation { @Override public String toString() { if (prop != null) { return "ConstraintViolation{" + name + "." + prop + " " + message + '}'; } return "ConstraintViolation{" + name + " " + message + '}'; } ConstraintViolation(String message);  ConstraintViolation(); int getIndex(); void setIndex(int index); String getMessage(); void setMessage(String message); String getName(); void setName(String name); String getProp(); void setProp(String prop); @Override String toString();  }
@Test public void testToString() { System.out.println("toString"); instance.setName("arg"); instance.setProp(null); instance.setMessage("can't be null"); String expResult = "ConstraintViolation{arg can't be null}"; String result = instance.toString(); assertThat(result).isEqualTo(expResult); instance.setProp("name"); expResult = "ConstraintViolation{arg.name can't be null}"; result = instance.toString(); assertThat(result).isEqualTo(expResult); }