use of com.linkedin.data.template.TestCustom.CustomPoint in project rest.li by linkedin.
the class TestCustomPoint method testCustomPointMap.
@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()) {
String j = e.getKey() + "_";
a3.put(j, e.getValue());
assertEquals(a3.get(j), e.getValue());
}
}
use of com.linkedin.data.template.TestCustom.CustomPoint in project rest.li by linkedin.
the class TestCustomPoint method testCustomPointUnionMember.
@Test
public void testCustomPointUnionMember() {
CustomPoint[] input = { new CustomPoint("1,1"), new CustomPoint("2,2"), new CustomPoint("3,3") };
CustomPointRecord.CustomPointUnion u = new CustomPointRecord.CustomPointUnion();
assertFalse(u.isCustomPoint());
assertNull(u.getCustomPoint());
Integer i = 66;
for (CustomPoint p : input) {
u.setCustomPoint(p);
assertTrue(u.isCustomPoint());
assertEquals(u.getCustomPoint(), p);
assertFalse(u.isInt());
assertNull(u.getInt());
u.setInt(i);
assertFalse(u.isCustomPoint());
assertNull(u.getCustomPoint());
assertTrue(u.isInt());
assertEquals(u.getInt(), i);
i += 11;
}
}
use of com.linkedin.data.template.TestCustom.CustomPoint in project rest.li by linkedin.
the class TestCustomPoint method testCustomPointRecordArray.
@Test
public void testCustomPointRecordArray() throws CloneNotSupportedException {
final List<String> input = new ArrayList<String>(Arrays.asList("1,1", "2,2", "3,3"));
final DataList inputDataList = new DataList(input);
CustomPointRecord record = new CustomPointRecord();
CustomPointArray a1 = new CustomPointArray(inputDataList);
record.setCustomPointArray(a1);
CustomPointRecord recordCopy = new CustomPointRecord(record.data().copy());
for (int i = 0; i < input.size(); i++) {
assertEquals(recordCopy.getCustomPointArray().get(i), new CustomPoint(input.get(i)));
}
}
use of com.linkedin.data.template.TestCustom.CustomPoint in project rest.li by linkedin.
the class TestCustomPoint method testCustomPointRecordUnion.
@Test
public void testCustomPointRecordUnion() throws CloneNotSupportedException {
CustomPoint point = new CustomPoint("1,1");
CustomPointRecord record = new CustomPointRecord();
CustomPointRecord.CustomPointUnion u = new CustomPointRecord.CustomPointUnion();
u.setCustomPoint(point);
record.setCustomPointUnion(u);
CustomPointRecord recordCopy = new CustomPointRecord(record.data().copy());
assertEquals(recordCopy, record);
assertTrue(recordCopy.getCustomPointUnion().isCustomPoint());
assertEquals(recordCopy.getCustomPointUnion().getCustomPoint(), point);
Integer i = 66;
record.getCustomPointUnion().setInt(i);
assertTrue(record.getCustomPointUnion().isInt());
assertEquals(record.getCustomPointUnion().getInt(), i);
// recordCopy has not changed
assertTrue(recordCopy.getCustomPointUnion().isCustomPoint());
assertEquals(recordCopy.getCustomPointUnion().getCustomPoint(), point);
}
use of com.linkedin.data.template.TestCustom.CustomPoint in project rest.li by linkedin.
the class TestCustomPoint method testCustomPointRecordMap.
@Test
public void testCustomPointRecordMap() throws CloneNotSupportedException {
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"));
CustomPointRecord record = new CustomPointRecord();
CustomPointMap a1 = new CustomPointMap(inputDataMap);
record.setCustomPointMap(a1);
CustomPointRecord recordCopy = new CustomPointRecord(record.data().copy());
for (Map.Entry<String, CustomPoint> e : input.entrySet()) {
assertEquals(recordCopy.getCustomPointMap().get(e.getKey()), e.getValue());
}
}
Aggregations