public String title() { final TitleBuffer buf = new TitleBuffer(); buf.append(name); return buf.toString(); }
public String title() { final TitleBuffer buf = new TitleBuffer(); buf.append(getName()); return buf.toString(); }
@Test public void testAppendNull() { t1.append(null); assertEquals(name, t1.toString()); }
@Test public void testAppendStringAddStringWithSpace() { t1.append("Smith"); assertEquals("Fred Smith", t1.toString()); }
@Test public void testAppendStringWithJoinerAddsStringWithJoinerAndSpace() { t1.append(",", "Smith"); assertEquals("Fred, Smith", t1.toString()); }
@Test public void testConstructorsWithObjectWhereDefaultIsNotNeeded() { t1 = new TitleBuffer(objectWithTitle, "test"); assertEquals("ABC Co.", t1.toString()); }
@Test public void testConstructorWithObjectWithNoTitle() { final TitleBuffer t = new TitleBuffer(objectWithEmptyTitle); assertEquals("", t.toString()); }
@Test public void testDefaultConstructor() { final TitleBuffer t = new TitleBuffer(); assertEquals("", t.toString()); }
@Test public void testTruncateLimitsTitleLength() { t3.truncate(3); assertEquals("This is a...", t3.toString()); }
@Test public void testAppendEmptyStringWithJoinerLeavesBufferUnchanged() { t1.append(",", ""); assertEquals(name, t1.toString()); }
@Test public void testAppendNullWithJoinerLeavesBufferUnchanged() { t1.append(",", (Object) null); assertEquals(name, t1.toString()); }
@Test public void testConcatEmptyStringLeavesBufferUnchanged() { t1.concat(""); assertEquals(name, t1.toString()); }
@Test public void testConstructorWithObject() { final TitleBuffer t = new TitleBuffer(objectWithTitle); assertEquals("ABC Co.", t.toString()); }
@Test public void testAppendObjectWithEmptyTitleLeavesBufferUnchanged() { t1.append(objectWithEmptyTitle); assertEquals(name, t1.toString()); }
@Test public void testAppendStringToEmptyBufferAddsStringWithoutSpace() { t2.append("Smith"); assertEquals("Smith", t2.toString()); }
@Test public void testConcatObjectWhereTitleIsAdded() { t1.concat(objectWithTitle); assertEquals("FredABC Co.", t1.toString()); }
@Test public void testConcatStringAddsString() { t1.concat("Smith"); assertEquals("FredSmith", t1.toString()); }
@Test public void testTruncateHasNoEffectUntilTitleLongEnough() { t3.truncate(5); assertEquals("This is a long title", t3.toString()); }
public String title() { final TitleBuffer buf = new TitleBuffer(); if (getParent() != null) { buf.append(getParent().getName()).append("-"); } buf.append(getName()); return buf.toString(); }
@Test public void testAppendInt() { final TitleBuffer t = new TitleBuffer(); t.append(123); assertEquals("123", t.toString()); }