Search in sources :

Example 1 with NestedArrayRefRecord

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);
}
Also used : RecordBarArray(com.linkedin.pegasus.generator.test.RecordBarArray) NestedArrayRefRecord(com.linkedin.pegasus.generator.test.NestedArrayRefRecord) TyperefTest(com.linkedin.pegasus.generator.test.TyperefTest) RecordBar(com.linkedin.pegasus.generator.test.RecordBar) RecordBarArrayArray(com.linkedin.pegasus.generator.test.RecordBarArrayArray) UnionTest(com.linkedin.pegasus.generator.test.UnionTest) Test(org.testng.annotations.Test) TyperefTest(com.linkedin.pegasus.generator.test.TyperefTest)

Aggregations

NestedArrayRefRecord (com.linkedin.pegasus.generator.test.NestedArrayRefRecord)1 RecordBar (com.linkedin.pegasus.generator.test.RecordBar)1 RecordBarArray (com.linkedin.pegasus.generator.test.RecordBarArray)1 RecordBarArrayArray (com.linkedin.pegasus.generator.test.RecordBarArrayArray)1 TyperefTest (com.linkedin.pegasus.generator.test.TyperefTest)1 UnionTest (com.linkedin.pegasus.generator.test.UnionTest)1 Test (org.testng.annotations.Test)1