Publication implements Comparator<Publication> { @Transient public String getShortAuthors() { if (authors != null && authors.length() > 0) { int pos = getNthOccurrence(authors, ',', 5); if (pos == -1) { return getAuthors(); } else { return getAuthors().substring(0, pos); } } return null; } protected  Publication();  Publication(String pubType, String isbn, String volume, Integer year, String pubTitle, String authors, String doi); long getPubId(); void setPubId(long pubId); Integer getPubMedId(); void setPubMedId(Integer pubMedId); String getPubAbstract(); void setPubAbstract(String pubAbstract); String getPubTitle(); void setPubTitle(String pubTitle); String getPubType(); void setPubType(String pubType); String getIsbn(); void setIsbn(String isbn); String getVolume(); void setVolume(String volume); String getIssue(); void setIssue(String issue); Integer getYear(); void setYear(Integer year); String getUrl(); void setUrl(String url); String getRawPages(); void setRawPages(String rawPages); String getMedlineJournal(); void setMedlineJournal(String medlineJournal); String getIsoJournal(); void setIsoJournal(String isoJournal); String getDoi(); void setDoi(String doi); String getAuthors(); @Transient String getShortAuthors(); void setAuthors(String authors); Integer getPubMedCentralId(); void setPubMedCentralId(Integer pubMedCentralId); @Override int hashCode(); @Override int compare(Publication o1, Publication o2); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testGetShortAuthors() { publication.setAuthors(authors); assertNotNull("Authors shouldn't be NULL!", publication.getAuthors()); assertEquals(authors, publication.getAuthors()); String expected = "Frias-Lopez J., Shi Y., Tyson GW., Coleman ML., Schuster SC."; assertEquals(expected, publication.getShortAuthors()); expected = "Frias-Lopez J., Shi Y., Tyson GW."; publication.setAuthors(expected); assertEquals(expected, publication.getAuthors()); assertEquals(expected, publication.getShortAuthors()); publication.setAuthors(null); assertNull(publication.getAuthors()); assertNull(publication.getShortAuthors()); }