Search in sources :

Example 56 with PathSpec

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");
}
Also used : MaskTree(com.linkedin.data.transform.filter.request.MaskTree) PathSpec(com.linkedin.data.schema.PathSpec) DataMap(com.linkedin.data.DataMap) Test(org.testng.annotations.Test)

Example 57 with PathSpec

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");
}
Also used : MaskTree(com.linkedin.data.transform.filter.request.MaskTree) PathSpec(com.linkedin.data.schema.PathSpec) DataMap(com.linkedin.data.DataMap) Test(org.testng.annotations.Test)

Example 58 with PathSpec

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);
}
Also used : MaskTree(com.linkedin.data.transform.filter.request.MaskTree) PathSpec(com.linkedin.data.schema.PathSpec) Test(org.testng.annotations.Test)

Example 59 with PathSpec

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());
}
Also used : MaskTree(com.linkedin.data.transform.filter.request.MaskTree) PathSpec(com.linkedin.data.schema.PathSpec) Test(org.testng.annotations.Test)

Example 60 with PathSpec

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}");
}
Also used : MaskTree(com.linkedin.data.transform.filter.request.MaskTree) PathSpec(com.linkedin.data.schema.PathSpec) Test(org.testng.annotations.Test)

Aggregations

PathSpec (com.linkedin.data.schema.PathSpec)79 Test (org.testng.annotations.Test)63 MaskTree (com.linkedin.data.transform.filter.request.MaskTree)31 DataMap (com.linkedin.data.DataMap)21 HashSet (java.util.HashSet)11 PatchTree (com.linkedin.data.transform.patch.request.PatchTree)9 DataList (com.linkedin.data.DataList)8 RecordTemplate (com.linkedin.data.template.RecordTemplate)7 ResourceMethodDescriptor (com.linkedin.restli.internal.server.model.ResourceMethodDescriptor)7 ByteString (com.linkedin.data.ByteString)6 ArrayList (java.util.ArrayList)6 Foo (com.linkedin.pegasus.generator.examples.Foo)5 RoutingResult (com.linkedin.restli.internal.server.RoutingResult)5 ResourceModel (com.linkedin.restli.internal.server.model.ResourceModel)5 RestLiResponseData (com.linkedin.restli.server.RestLiResponseData)5 RestLiTestHelper.buildResourceModel (com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel)5 AfterTest (org.testng.annotations.AfterTest)5 BeforeTest (org.testng.annotations.BeforeTest)5 TestRecord (com.linkedin.restli.client.test.TestRecord)4 List (java.util.List)4