Summary implements Serializable { public static Summary copyValues(final Summary from, final Summary to) { Summary summary = null; if (null != from) { summary = new Summary(); if (to != null) { summary.setId(to.getId()); } summary.setVersion(from.getVersion()); summary.setTiny(from.getTiny()); summary.setLegend(from.getLegend()); summary.setMedium(from.getMedium()); summary.setDownload(from.getDownload()); summary.setMetadataDownload(from.getMetadataDownload()); Full toFull = new Full(); if (to != null && to.getFull() != null) { toFull = to.getFull(); } summary.setFull(Full.copyValues(from.getFull(), toFull)); summary.setKeywords(from.getKeywords()); } return summary; }  @Id @GeneratedValue(strategy = GenerationType.AUTO) int getId(); void setId(int id); @Column(name = "version", length = VERSION_MAX_LENGTH) String getVersion(); void setVersion(String version); @Embedded Tiny getTiny(); void setTiny(Tiny tiny); @Embedded Legend getLegend(); void setLegend(Legend legend); @Embedded Download getDownload(); void setDownload(Download download); @Column(name = "metadata_download_link") String getMetadataDownload(); void setMetadataDownload(String metadataDownload); @Embedded Medium getMedium(); void setMedium(Medium medium); @OneToOne(cascade = CascadeType.ALL) Full getFull(); void setFull(Full full); String getKeywords(); void setKeywords(String keywords); static Summary copyValues(final Summary from, final Summary to); static final int VERSION_MAX_LENGTH; }
@Test public void testCopyToWithNullFrom() { Summary from = null; Summary to = null; Summary actual = Summary.copyValues(from, to); assertNull(actual); }