use of com.linkedin.restli.server.LinkedListNode in project rest.li by linkedin.
the class TestRestUtils method testRecursiveBasic.
@Test
public void testRecursiveBasic() throws CloneNotSupportedException {
LinkedListNode node1 = new LinkedListNode();
node1.setIntField(1);
LinkedListNode node2 = new LinkedListNode();
node2.setIntField(2);
node1.setNext(node2);
RecordTemplate expected = node1.copy();
// Introduce bad elements.
node1.data().put("foo", "bar");
node2.data().put("foo", "bar");
Assert.assertEquals(node1.getIntField().intValue(), 1);
Assert.assertEquals(node1.getNext(), node2);
Assert.assertEquals(node1.data().size(), 3);
Assert.assertEquals(node2.getIntField().intValue(), 2);
Assert.assertEquals(node2.getNext(), null);
Assert.assertEquals(node2.data().size(), 2);
RestUtils.trimRecordTemplate(node1, false);
Assert.assertEquals(node1, expected);
}
use of com.linkedin.restli.server.LinkedListNode in project rest.li by linkedin.
the class TestRestUtils method testOverrideMaskNestedRecord.
@Test
public void testOverrideMaskNestedRecord() throws CloneNotSupportedException {
LinkedListNode node1 = new LinkedListNode();
node1.setIntField(1);
LinkedListNode node2 = new LinkedListNode();
node2.setIntField(2);
node1.setNext(node2);
node2.data().put("keep me", "foo");
MaskTree maskTree = new MaskTree();
maskTree.addOperation(new PathSpec("next", "keep me"), MaskOperation.POSITIVE_MASK_OP);
maskTree.addOperation(new PathSpec("next", "intField"), MaskOperation.POSITIVE_MASK_OP);
LinkedListNode expected = node2.clone();
RestUtils.trimRecordTemplate(node1, maskTree, false);
Assert.assertEquals(node1.getNext(), expected);
}
Aggregations