Examples of MaskTree


Examples of com.linkedin.data.transform.filter.request.MaskTree

  @Test
  public void testSimplePositiveMask() throws Exception
  {
    List<PathSpec> fields = Arrays.asList(Group.fields().name(), Group.fields().description(), Group.fields().id());
    MaskTree mask = MaskCreator.createPositiveMask(fields);
    assertEquals(mask.toString(), "{id=1, description=1, name=1}");
    assertEquals(URIMaskUtil.encodeMaskForURI(mask), "id,description,name");
  }
View Full Code Here

Examples of com.linkedin.data.transform.filter.request.MaskTree

  @Test
  public void testNestedPositiveMask() throws Exception
  {
    List<PathSpec> fields = Arrays.asList(Group.fields().id(), Group.fields().location().latitude(), Group.fields().location().longitude(), Group.fields().name());
    MaskTree mask = MaskCreator.createPositiveMask(fields);
    assertEquals(mask.toString(), "{id=1, location={longitude=1, latitude=1}, name=1}");
    assertEquals(URIMaskUtil.encodeMaskForURI(mask), "id,location:(longitude,latitude),name");
  }
View Full Code Here

Examples of com.linkedin.data.transform.filter.request.MaskTree


  @Test
  public void testNegativeMask() throws Exception
  {
    MaskTree mask = MaskCreator.createNegativeMask(Group.fields().badge(), Group.fields().id(),
                                                   Group.fields().owner().id());
    assertEquals(mask.toString(),"{id=0, owner={id=0}, badge=0}");
    assertEquals(URIMaskUtil.encodeMaskForURI(mask), "-id,owner:(-id),-badge");
  }
View Full Code Here

Examples of com.linkedin.data.transform.filter.request.MaskTree

   * "remove field and all it's children".
   */
  @Test
  public void testComposingNegativeSubmasks()
  {
    MaskTree mask = new MaskTree();
    mask.addOperation(new PathSpec("a", "b", "c"), MaskOperation.NEGATIVE_MASK_OP);
    mask.addOperation(new PathSpec("a", "b"), MaskOperation.NEGATIVE_MASK_OP);
    mask.addOperation(new PathSpec("a"), MaskOperation.NEGATIVE_MASK_OP);
    Assert.assertEquals(mask.toString(), "{a=0}");
  }
View Full Code Here

Examples of com.linkedin.data.transform.filter.request.MaskTree

   * @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());
  }
View Full Code Here

Examples of com.linkedin.data.transform.filter.request.MaskTree

   * @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}");
  }
View Full Code Here

Examples of com.linkedin.data.transform.filter.request.MaskTree

    headers.put(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, version.toString());

    ResourceContext context = new ResourceContextImpl(new PathKeysImpl(),
                                                      new MockRequest(uri, headers),
                                                      new RequestContext());
    final MaskTree rootEntityMask = context.getProjectionMask();
    Assert.assertEquals(rootEntityMask.toString(), "{locale=1, state=1}");

    final MaskTree metadataMask = context.getMetadataProjectionMask();
    Assert.assertEquals(metadataMask.toString(), "{region=1, city=1}");

    final MaskTree pagingMask = context.getPagingProjectionMask();
    Assert.assertEquals(pagingMask.toString(), "{start=1, links=1}");
  }
View Full Code Here

Examples of com.linkedin.data.transform.filter.request.MaskTree

    headers.put(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, version.toString());

    ResourceContext context = new ResourceContextImpl(new PathKeysImpl(),
                                                      new MockRequest(uri, headers),
                                                      new RequestContext());
    final MaskTree rootEntityMask = context.getProjectionMask();
    Assert.assertEquals(rootEntityMask.toString(), "{location={longitude=1, latitude=1}, locale=1, state=1}");

    final MaskTree metadataMask = context.getMetadataProjectionMask();
    Assert.assertEquals(metadataMask.toString(), "{region=1, profile={weight=1, height=1}, city=1}");

    //Note the lack of a test with paging here. This is because paging (CollectionMetadata) has a LinkArray which
    //requires a wildcard path spec in the URI. That behavior is inconsistent with the other projections in this test,
    //therefore it will be included in the subsequent test.
  }
View Full Code Here

Examples of com.linkedin.data.transform.filter.request.MaskTree

    headers.put(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, version.toString());

    ResourceContext context = new ResourceContextImpl(new PathKeysImpl(),
                                                      new MockRequest(uri, headers),
                                                      new RequestContext());
    final MaskTree rootEntityMask = context.getProjectionMask();
    Assert.assertEquals(rootEntityMask.toString(), "{d={$*={f=1, e=1}}, b={$*={c=1}}, a={$*=1}}");

    final MaskTree metadataMask = context.getMetadataProjectionMask();
    Assert.assertEquals(metadataMask.toString(), "{baz={$*={a=1}}, foo={$*={b=1, c=1, a=1}}, bar={$*=1}}");

    final MaskTree pagingMask = context.getPagingProjectionMask();
    Assert.assertEquals(pagingMask.toString(), "{total=1, count=1, links={$*={rel=1}}}");
  }
View Full Code Here

Examples of com.linkedin.data.transform.filter.request.MaskTree

    ServerResourceContext context = new ResourceContextImpl(new PathKeysImpl(),
                                                            new MockRequest(uri, headers),
                                                            new RequestContext());

    final MaskTree rootEntityMask = context.getProjectionMask();
    Assert.assertEquals(rootEntityMask.toString(), "{baz=1, foo=1, bar=1}");

    final MaskTree metadataMask = context.getMetadataProjectionMask();
    Assert.assertEquals(metadataMask.toString(), "{region=1, city=1}");

    final MaskTree pagingMask = context.getPagingProjectionMask();
    Assert.assertEquals(pagingMask.toString(), "{start=1, links=1}");

    DataMap parameters = context.getParameters();
    DataMap expectedParameters = new DataMap();
    expectedParameters.put("fields", "foo,bar,baz");
    expectedParameters.put("metadataFields", "city,region");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.