/** * Test method for {@link * net.sf.jabref.export.layout.format.AuthorFirstAbbrLastOxfordCommas#format(java.lang.String)}. */ public void testFormat() { LayoutFormatter a = new AuthorFirstAbbrLastOxfordCommas(); // Empty case assertEquals("", a.format("")); // Single Names assertEquals("V. S. Someone", a.format("Someone, Van Something")); // Two names assertEquals( "J. von Neumann and P. Black Brown", a.format("John von Neumann and Black Brown, Peter")); // Three names assertEquals( "J. von Neumann, J. Smith, and P. Black Brown", a.format("von Neumann, John and Smith, John and Black Brown, Peter")); assertEquals( "J. von Neumann, J. Smith, and P. Black Brown", a.format("John von Neumann and John Smith and Black Brown, Peter")); }
public void testComposite() { { LayoutFormatter f = new CompositeFormat(); assertEquals("No Change", f.format("No Change")); } { LayoutFormatter f = new CompositeFormat( new LayoutFormatter[] { new LayoutFormatter() { public String format(String fieldText) { return fieldText + fieldText; } }, new LayoutFormatter() { public String format(String fieldText) { return "A" + fieldText; } }, new LayoutFormatter() { public String format(String fieldText) { return "B" + fieldText; } } }); assertEquals("BAff", f.format("f")); } { LayoutFormatter f = new CompositeFormat(new AuthorOrgSci(), new NoSpaceBetweenAbbreviations()); LayoutFormatter first = new AuthorOrgSci(); LayoutFormatter second = new NoSpaceBetweenAbbreviations(); assertEquals( second.format(first.format("John Flynn and Sabine Gartska")), f.format("John Flynn and Sabine Gartska")); assertEquals( second.format(first.format("Sa Makridakis and Sa Ca Wheelwright and Va Ea McGee")), f.format("Sa Makridakis and Sa Ca Wheelwright and Va Ea McGee")); } }