use of com.linkedin.pegasus.generator.test.NestedArrayRefRecord in project rest.li by linkedin.
the class TestRestUtils method testNestedArrayRefRecord.
@Test
public void testNestedArrayRefRecord() throws CloneNotSupportedException {
TyperefTest test = new TyperefTest();
NestedArrayRefRecord nestedArrayRefRecord = new NestedArrayRefRecord();
RecordBarArray recordBarArray = new RecordBarArray();
RecordBar recordBar = new RecordBar();
recordBar.setLocation("mountain view");
recordBarArray.add(recordBar);
RecordBar recordBar2 = new RecordBar();
recordBar2.setLocation("palo alto");
recordBarArray.add(recordBar2);
RecordBarArrayArray recordBarArrayArray = new RecordBarArrayArray();
recordBarArrayArray.add(recordBarArray);
nestedArrayRefRecord.setNestedRecordRefArray(recordBarArrayArray);
test.setNestedArrayRefRecord(nestedArrayRefRecord);
// Generate expected copy.
TyperefTest expected = test.copy();
// Introduce bad elements.
test.getNestedArrayRefRecord().getNestedRecordRefArray().get(0).get(0).data().put("evil", "bar");
test.getNestedArrayRefRecord().getNestedRecordRefArray().get(0).get(0).data().put("evil2", "bar");
test.getNestedArrayRefRecord().getNestedRecordRefArray().get(0).get(1).data().put("evil", "foo");
test.getNestedArrayRefRecord().getNestedRecordRefArray().get(0).get(1).data().put("evil2", "foo");
Assert.assertEquals(test.getNestedArrayRefRecord().getNestedRecordRefArray().get(0).get(0).data().size(), 3);
Assert.assertEquals(test.getNestedArrayRefRecord().getNestedRecordRefArray().get(0).get(1).data().size(), 3);
RestUtils.trimRecordTemplate(test, false);
Assert.assertEquals(test, expected);
}
Aggregations