Search in sources :

Example 1 with RecordBarArrayArray

use of com.linkedin.pegasus.generator.test.RecordBarArrayArray in project rest.li by linkedin.

the class TestRestUtils method testRecordRefArrayTrim.

@Test
public void testRecordRefArrayTrim() throws CloneNotSupportedException {
    TyperefTest test = new TyperefTest();
    RecordBarArrayArray recordBarArrayArray = new RecordBarArrayArray();
    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.add(recordBarArray);
    test.setRecordRefArray(recordBarArrayArray);
    // Generate expected copy.
    TyperefTest expected = test.copy();
    // Introduce bad elements.
    test.getRecordRefArray().get(0).get(0).data().put("evil", "bar");
    test.getRecordRefArray().get(0).get(0).data().put("evil2", "bar");
    test.getRecordRefArray().get(0).get(1).data().put("evil", "foo");
    test.getRecordRefArray().get(0).get(1).data().put("evil2", "foo");
    Assert.assertEquals(test.getRecordRefArray().get(0).get(0).data().size(), 3);
    Assert.assertEquals(test.getRecordRefArray().get(0).get(1).data().size(), 3);
    RestUtils.trimRecordTemplate(test, false);
    Assert.assertEquals(test, expected);
}
Also used : RecordBarArray(com.linkedin.pegasus.generator.test.RecordBarArray) 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)

Example 2 with RecordBarArrayArray

use of com.linkedin.pegasus.generator.test.RecordBarArrayArray 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

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