use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestMaskCreation method testNegativeMaskMultipleFields.
@Test
public void testNegativeMaskMultipleFields() {
MaskTree mask = MaskCreator.createNegativeMask(new PathSpec("foo"), new PathSpec("bar"));
//"{foo=0, bar=0}"
final DataMap fooBarMap = new DataMap();
fooBarMap.put("foo", MaskOperation.NEGATIVE_MASK_OP.getRepresentation());
fooBarMap.put("bar", MaskOperation.NEGATIVE_MASK_OP.getRepresentation());
Assert.assertEquals(mask.getDataMap(), fooBarMap, "The MaskTree DataMap should match");
}
use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestMaskCreation method testPositiveMaskNestedFields.
@Test
public void testPositiveMaskNestedFields() {
MaskTree mask = MaskCreator.createPositiveMask(new PathSpec("foo", "bar"), new PathSpec("bar", "baz"), new PathSpec("qux"));
//"{foo={bar=1}, bar={baz=1}, qux=1}"
final DataMap fooBarQuxMap = new DataMap();
fooBarQuxMap.put("qux", MaskOperation.POSITIVE_MASK_OP.getRepresentation());
final DataMap barMap = new DataMap();
barMap.put("baz", MaskOperation.POSITIVE_MASK_OP.getRepresentation());
final DataMap fooMap = new DataMap();
fooMap.put("bar", MaskOperation.POSITIVE_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.schema.PathSpec in project rest.li by linkedin.
the class TestMaskCreation method testMaskWithDollarField.
@Test
public void testMaskWithDollarField() {
MaskTree mask = new MaskTree();
mask.addOperation(new PathSpec("$foo"), MaskOperation.POSITIVE_MASK_OP);
Assert.assertEquals(mask.toString(), "{$$foo=1}");
Assert.assertEquals(mask.getOperations().get(new PathSpec("$$foo")), null);
Assert.assertEquals(mask.getOperations().get(new PathSpec("$foo")), MaskOperation.POSITIVE_MASK_OP);
}
use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestMaskCreation method testComposingPositiveMaskWithNegativeSubmasks.
/**
* When positive mask for a PathSpec is composed with negative mask, which is sub-PathSpec, then
* the result is a mask, which selects all fields in PathSpec using wildcard with negative mask
* for sub-PathSpec. This is because negative mask has a higher priority then a positive mask.
* @throws IOException
*/
@Test
public void testComposingPositiveMaskWithNegativeSubmasks() throws IOException {
MaskTree mask = new MaskTree();
mask.addOperation(new PathSpec("a", "b", "c"), MaskOperation.NEGATIVE_MASK_OP);
mask.addOperation(new PathSpec("a"), MaskOperation.POSITIVE_MASK_OP);
Assert.assertEquals(mask.toString(), dataMapFromString("{'a': {'$*': 1, 'b': {'c': 0}}}".replace('\'', '"')).toString());
}
use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestMaskCreation method testPositiveMaskSingleField.
@Test
public void testPositiveMaskSingleField() {
MaskTree mask = MaskCreator.createPositiveMask(new PathSpec("foo"));
Assert.assertEquals(mask.toString(), "{foo=1}");
}
Aggregations