Search in sources :

Example 1 with NoToString

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()));
    }
}
Also used : NoToString(org.motechproject.mds.testutil.records.display.NoToString) UIRepresentationTestClass(org.motechproject.mds.testutil.records.display.UIRepresentationTestClass) ToStringTestClass(org.motechproject.mds.testutil.records.display.ToStringTestClass) UIRepresentationTestClass(org.motechproject.mds.testutil.records.display.UIRepresentationTestClass) ToStringTestClass(org.motechproject.mds.testutil.records.display.ToStringTestClass) FieldDto(org.motechproject.mds.dto.FieldDto) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 FieldDto (org.motechproject.mds.dto.FieldDto)1 NoToString (org.motechproject.mds.testutil.records.display.NoToString)1 ToStringTestClass (org.motechproject.mds.testutil.records.display.ToStringTestClass)1 UIRepresentationTestClass (org.motechproject.mds.testutil.records.display.UIRepresentationTestClass)1