}
@Test
public void testCustomPointMap() throws IOException
{
final Map<String, CustomPoint> input = asMap("1", new CustomPoint("1,1"), "2", new CustomPoint("2,2"), "3", new CustomPoint("3,3"));
final DataMap inputDataMap = new DataMap(asMap("1", "1,1", "2", "2,2", "3", "3,3"));
final String customPointMapSchemaText = "{\"type\":\"map\",\"values\":{\"type\":\"typeref\",\"name\":\"CustomPoint\",\"namespace\":\"com.linkedin.pegasus.generator.test\",\"ref\":\"string\",\"java\":{\"class\":\"com.linkedin.data.template.TestCustom.CustomPoint\"}}}";
CustomPointMap a1 = new CustomPointMap();
assertEquals(a1.schema(), TestUtil.dataSchemaFromString(customPointMapSchemaText));
for (Map.Entry<String, CustomPoint> e : input.entrySet())
{
a1.put(e.getKey(), e.getValue());
assertTrue(a1.containsKey(e.getKey()));
assertTrue(a1.containsValue(e.getValue()));
}
CustomPointMap a2 = new CustomPointMap(inputDataMap);
assertEquals(a1, a2);
assertEquals(a1.data(), a2.data());
for (Map.Entry<String, CustomPoint> e : input.entrySet())
{
assertTrue(a2.containsKey(e.getKey()));
assertTrue(a2.containsValue(e.getValue()));
}
for (Map.Entry<String, CustomPoint> e : input.entrySet())
{
CustomPoint p = a1.get(e.getKey());
assertEquals(p, e.getValue());
}
CustomPointMap a3 = new CustomPointMap(input.size());
for (Map.Entry<String, CustomPoint> e : input.entrySet())