use of com.linkedin.data.transform.filter.request.MaskTree in project rest.li by linkedin.
the class TestMaskCreation method testComposingPositiveSubmasks.
/**
* When positive mask for a PathSpec is composed with another positive mask, which is sub-PathSpec, then
* the result is a positive mask with PathSpec only for the parent, because positive mask means
* "select field and all it's children".
*/
@Test
public void testComposingPositiveSubmasks() {
MaskTree mask = new MaskTree();
mask.addOperation(new PathSpec("a", "b", "c"), MaskOperation.POSITIVE_MASK_OP);
mask.addOperation(new PathSpec("a", "b"), MaskOperation.POSITIVE_MASK_OP);
mask.addOperation(new PathSpec("a"), MaskOperation.POSITIVE_MASK_OP);
Assert.assertEquals(mask.toString(), "{a=1}");
}
use of com.linkedin.data.transform.filter.request.MaskTree in project rest.li by linkedin.
the class TestMaskCreation method testNegativeMaskNestedFields.
@Test
public void testNegativeMaskNestedFields() {
MaskTree mask = MaskCreator.createNegativeMask(new PathSpec("foo", "bar"), new PathSpec("bar", "baz"), new PathSpec("qux"));
//"{foo={bar=0}, bar={baz=0}, qux=0}"
final DataMap fooBarQuxMap = new DataMap();
fooBarQuxMap.put("qux", MaskOperation.NEGATIVE_MASK_OP.getRepresentation());
final DataMap barMap = new DataMap();
barMap.put("baz", MaskOperation.NEGATIVE_MASK_OP.getRepresentation());
final DataMap fooMap = new DataMap();
fooMap.put("bar", MaskOperation.NEGATIVE_MASK_OP.getRepresentation());
fooBarQuxMap.put("foo", fooMap);
fooBarQuxMap.put("bar", barMap);
Assert.assertEquals(mask.getDataMap(), fooBarQuxMap, "The MaskTree DataMap should match");
}
use of com.linkedin.data.transform.filter.request.MaskTree in project rest.li by linkedin.
the class TestMaskCreation method testNegativeMaskSingleField.
@Test
public void testNegativeMaskSingleField() {
MaskTree mask = MaskCreator.createNegativeMask(new PathSpec("foo"));
Assert.assertEquals(mask.toString(), "{foo=0}");
}
use of com.linkedin.data.transform.filter.request.MaskTree in project rest.li by linkedin.
the class TestMaskCreation method testComposingNegativeMaskWithPositiveSubmasks.
/**
* When negative mask for a PathSpec is composed with positive mask, which is sub-PathSpec, then
* the result is a negative mask with PathSpec only for the parent, because negative mask has a
* higher priority then a positive mask.
* @throws IOException
*/
@Test
public void testComposingNegativeMaskWithPositiveSubmasks() throws IOException {
MaskTree mask = new MaskTree();
mask.addOperation(new PathSpec("a", "b", "c"), MaskOperation.POSITIVE_MASK_OP);
mask.addOperation(new PathSpec("a"), MaskOperation.NEGATIVE_MASK_OP);
Assert.assertEquals(mask.toString(), "{a=0}");
}
use of com.linkedin.data.transform.filter.request.MaskTree in project rest.li by linkedin.
the class TestMaskCreation method testPositiveMaskMultipleFields.
@Test
public void testPositiveMaskMultipleFields() {
MaskTree mask = MaskCreator.createPositiveMask(new PathSpec("foo"), new PathSpec("bar"));
//"{foo=1, bar=1}"
final DataMap fooBarMap = new DataMap();
fooBarMap.put("foo", MaskOperation.POSITIVE_MASK_OP.getRepresentation());
fooBarMap.put("bar", MaskOperation.POSITIVE_MASK_OP.getRepresentation());
Assert.assertEquals(mask.getDataMap(), fooBarMap, "The MaskTree DataMap should match");
}
Aggregations