use of org.motechproject.mds.testutil.records.display.ToStringTestClass 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()));
}
}
use of org.motechproject.mds.testutil.records.display.ToStringTestClass in project motech by motech.
the class DisplayHelperTest method testSingleObjectRelationshipDisplay.
private void testSingleObjectRelationshipDisplay(Class<? extends Relationship> relClass) {
FieldDto field = FieldTestHelper.fieldDto("relField", relClass);
assertEquals("Value", DisplayHelper.getDisplayValueForField(field, new ToStringTestClass(1, "Value")));
assertEquals("Value", DisplayHelper.getDisplayValueForField(field, new UIRepresentationTestClass(1, "Value")));
}
use of org.motechproject.mds.testutil.records.display.ToStringTestClass in project motech by motech.
the class DisplayHelperTest method testMultiObjectRelationshipDisplay.
private void testMultiObjectRelationshipDisplay(Class<? extends Relationship> relClass) {
FieldDto field = FieldTestHelper.fieldDto("relField", relClass);
Map<Long, String> displayMap = (Map<Long, String>) DisplayHelper.getDisplayValueForField(field, asList(new ToStringTestClass(1, "val1"), new ToStringTestClass(2, "val2"), new ToStringTestClass(3, "val3")));
assertDisplayMap(displayMap, "val1", "val2", "val3");
displayMap = (Map<Long, String>) DisplayHelper.getDisplayValueForField(field, asList(new UIRepresentationTestClass(1, "val1"), new UIRepresentationTestClass(2, "val2"), new UIRepresentationTestClass(3, "val3")));
assertDisplayMap(displayMap, "val1", "val2", "val3");
}
Aggregations