use of com.linkedin.data.transform.filter.request.MaskTree in project rest.li by linkedin.
the class TestRestUtils method testOverrideMask.
@Test
public void testOverrideMask() throws CloneNotSupportedException {
RecordBar bar = new RecordBar();
bar.setLocation("mountain view");
bar.data().put("SF", "CA");
RecordBar expected = bar.clone();
MaskTree maskTree = new MaskTree();
maskTree.addOperation(new PathSpec("SF"), MaskOperation.POSITIVE_MASK_OP);
RestUtils.trimRecordTemplate(bar, maskTree, false);
Assert.assertEquals(bar, expected);
}
use of com.linkedin.data.transform.filter.request.MaskTree in project rest.li by linkedin.
the class TestGetResponseBuilder method dataProvider.
@DataProvider(name = "testData")
public Object[][] dataProvider() {
DataMap projectionDataMap = new DataMap();
projectionDataMap.put("stringField", MaskOperation.POSITIVE_MASK_OP.getRepresentation());
MaskTree maskTree = new MaskTree(projectionDataMap);
ProjectionMode manual = ProjectionMode.MANUAL;
ProjectionMode auto = ProjectionMode.AUTOMATIC;
return new Object[][] { // no projections with null projection masks and auto projection mode
{ getRecord(), HttpStatus.S_200_OK, null, auto }, { new GetResult<Foo>(getRecord(), HttpStatus.S_207_MULTI_STATUS), HttpStatus.S_207_MULTI_STATUS, null, auto }, // no projections with null projection masks and manual projection mode
{ getRecord(), HttpStatus.S_200_OK, null, manual }, { new GetResult<Foo>(getRecord(), HttpStatus.S_207_MULTI_STATUS), HttpStatus.S_207_MULTI_STATUS, null, manual }, // no projections with non-null projection masks and manual projection mode
{ getRecord(), HttpStatus.S_200_OK, maskTree, manual }, { new GetResult<Foo>(getRecord(), HttpStatus.S_207_MULTI_STATUS), HttpStatus.S_207_MULTI_STATUS, maskTree, manual }, // projections with non-null projection masks and auto projection mode
{ getRecord(), HttpStatus.S_200_OK, maskTree, auto }, { new GetResult<Foo>(getRecord(), HttpStatus.S_207_MULTI_STATUS), HttpStatus.S_207_MULTI_STATUS, maskTree, auto } };
}
use of com.linkedin.data.transform.filter.request.MaskTree in project rest.li by linkedin.
the class TestRestUtils method testOverrideMaskNestedWithMap.
@Test
public void testOverrideMaskNestedWithMap() throws CloneNotSupportedException {
TyperefTest test = new TyperefTest();
RecordBar bar = new RecordBar();
bar.setLocation("foo");
bar.data().put("bar", "keep me");
RecordBar expected = bar.clone();
test.setBarRefMap(new RecordBarMap());
test.getBarRefMap().put("foo", bar);
MaskTree maskTree = new MaskTree();
maskTree.addOperation(new PathSpec("barRefMap", PathSpec.WILDCARD, "location"), MaskOperation.POSITIVE_MASK_OP);
maskTree.addOperation(new PathSpec("barRefMap", PathSpec.WILDCARD, "bar"), MaskOperation.POSITIVE_MASK_OP);
RestUtils.trimRecordTemplate(test, maskTree, false);
Assert.assertEquals(test.getBarRefMap().get("foo"), expected);
}
use of com.linkedin.data.transform.filter.request.MaskTree 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