use of org.motechproject.mds.testutil.records.display.NoToString in project motech by motech.
the class DefaultCsvExportCustomizerTest method shouldFormatRelationships.
@Test
public void shouldFormatRelationships() {
// these two relationship types should be handled the same way
for (Class clazz : asList(OneToOneRelationship.class, ManyToOneRelationship.class)) {
FieldDto relField = FieldTestHelper.fieldDto("name", clazz);
assertEquals("something", exportCustomizer.formatField(relField, new UIRepresentationTestClass(1, "something")));
assertEquals("something", exportCustomizer.formatField(relField, new ToStringTestClass(1, "something")));
assertEquals("4", exportCustomizer.formatField(relField, new NoToString(4)));
assertEquals("", exportCustomizer.formatField(relField, null));
}
// these two as well
for (Class clazz : asList(OneToManyRelationship.class, ManyToManyRelationship.class)) {
FieldDto relField = FieldTestHelper.fieldDto("name", clazz);
assertEquals("first,second", exportCustomizer.formatField(relField, asList(new UIRepresentationTestClass(1, "first"), new UIRepresentationTestClass(2, "second"))));
assertEquals("first,second", exportCustomizer.formatField(relField, asList(new ToStringTestClass(1, "first"), new ToStringTestClass(2, "second"))));
assertEquals("7,8", exportCustomizer.formatField(relField, asList(new NoToString(7), new NoToString(8))));
assertEquals("", exportCustomizer.formatField(relField, null));
assertEquals("", exportCustomizer.formatField(relField, Collections.emptySet()));
}
}
Aggregations