### Question:
PubMedListFormat extends Format { @Override public Object parseObject(String source, ParsePosition pos) { pos.setIndex(source.length() + 1); PubMedIdList list = new PubMedIdList(); StringTokenizer tokenizer = new StringTokenizer(source, ","); while (tokenizer.hasMoreTokens()) { validatePubMedID(tokenizer.nextToken(), list); } return list; }  @Override StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos); @Override Object parseObject(String source, ParsePosition pos);  }### Answer:
@Test public void testParseEmptyString() throws ParseException { assertEquals(Collections.emptyList(), d_format.parseObject("")); }
@Test public void testParseSingleEntry() throws ParseException { String str1 = "12345"; assertEquals(Collections.singletonList(new PubMedId(str1)), d_format.parseObject(str1)); }
@Test public void testParseSingleEntryWithNonDigits() throws ParseException { assertEquals(Collections.singletonList(new PubMedId("12345")), d_format.parseObject("12345a")); assertEquals(Collections.singletonList(new PubMedId("12345")), d_format.parseObject("-1x23\n45a")); assertEquals(Collections.singletonList(new PubMedId("12345")), d_format.parseObject("0012345")); }
@Test public void testParseSingleInvalidEntry() throws ParseException { assertEquals(Collections.emptyList(), d_format.parseObject("notanid")); }
@Test public void testParseMultipleEntries() throws ParseException { String str1 = "123"; String str2 = "456"; List<PubMedId> lst = new ArrayList<PubMedId>(); lst.add(new PubMedId(str1)); lst.add(new PubMedId(str2)); assertEquals(lst, d_format.parseObject(str1 + ", " + str2)); assertEquals(lst, d_format.parseObject(str1 + "," + str2)); }
@Test public void testParseMultipleWithInvalidEntry() throws ParseException { assertEquals(Collections.singletonList(new PubMedId("12345")), d_format.parseObject("12345a, x")); assertEquals(Collections.emptyList(), d_format.parseObject("x, y")); }