TitleBuilder { public String toString() { return new StringBuilder() .append(parentString) .append(nameString) .append(referenceString.length() > 0 && nameString.length() > 0 ? SPACE : "") .append(!referenceString.toString().equals(nameString.toString()) ? delimited(referenceString) : "") .toString().trim(); } private  TitleBuilder(); static TitleBuilder start(); TitleBuilder withParent(final Object object); TitleBuilder withName(final String name); TitleBuilder withReference(final String reference); String toString(); TitleBuilder withName(final Object object); @Deprecated TitleBuilder withTupleElement(Object object); static final Class[] NO_PARAMETER_TYPES; static final Object[] NO_ARGUMENTS; }
@Test public void testToString() throws Exception { assertThat(TitleBuilder.start().withName("Name").withReference("REF").toString()) .isEqualTo("Name [REF]"); assertThat(TitleBuilder.start().withParent(new TestObject()).withName("Name").withReference("REF").toString()) .isEqualTo("Parent [PAR] > Name [REF]"); assertThat(TitleBuilder.start().withParent(new TestObject()).withName("REF").withReference("REF").toString()) .isEqualTo("Parent [PAR] > REF"); assertThat(TitleBuilder.start().withParent(new TestObject()).withName("Name1").withName("Name2").withReference("REF").toString()) .isEqualTo("Parent [PAR] > Name1 Name2 [REF]"); assertThat(TitleBuilder.start().withParent(new TestObject()).withName(LocalDateInterval.parseString("2014-01-01/2015-01-01")).toString()) .isEqualTo("Parent [PAR] > 2014-01-01/2015-01-01"); }