GuestModel { @Override public String toString() { return new ToStringBuilder(this) .append("publicId", publicId) .append("name", name) .toString(); } GuestModel();  GuestModel(String publicId, String lastName); String getPublicId(); void setPublicId(String publicId); String getName(); void setName(String name); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void marshal() { StringWriter w = new StringWriter(); GuestModel guest = new GuestModel("foo", "qux"); JAXB.marshal(guest, w); assertThat(w.toString()).startsWith("<?xml"); }