Examples of MaskTree


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

    expectException("foo:(bar))");
  }

  private void checkProjection(String input, String expected) throws Exception
  {
    MaskTree mask = ArgumentUtils.parseProjectionParameter(input);
    assertEquals(mask.getDataMap().toString(), expected);
  }
View Full Code Here

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

  private void expectException(String input)
  {
    try
    {
      MaskTree mask = ArgumentUtils.parseProjectionParameter(input);
      Assert.fail("Expected exception");
    }
    catch (Exception e)
    {
View Full Code Here

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

   */
  @Test
  public void testProcessProjections()
  {
    //Construct a MaskTree from a series of PathSpecs. Extract the subsequent Datamap representation.
    final MaskTree rootObjectsMask = MaskCreator
        .createPositiveMask(new PathSpec("foo", PathSpec.WILDCARD, "bar"));

    final MaskTree metadataMask = MaskCreator
        .createPositiveMask(new PathSpec("foo", "bar"), new PathSpec("bar", "baz"), new PathSpec("qux"));

    final MaskTree pagingMask = MaskCreator
        .createPositiveMask(new PathSpec("total"), new PathSpec("count"), new PathSpec("links", PathSpec.WILDCARD, "rel"));

    final DataMap resultMap = new DataMap(4); //For each type of projection, plus one query string parameter
    resultMap.put(RestConstants.FIELDS_PARAM, rootObjectsMask.getDataMap());
    resultMap.put(RestConstants.METADATA_FIELDS_PARAM, metadataMask.getDataMap());
    resultMap.put(RestConstants.PAGING_FIELDS_PARAM, pagingMask.getDataMap());
    resultMap.put("someQueryString", "someValue");

    final Map<String, List<String>> processedProjections = new LinkedHashMap<String, List<String>>();
    final DataMap processedDataMap = QueryParamsDataMap.processProjections(resultMap, processedProjections);
    Assert.assertTrue(processedDataMap.size() == 1, "Processed datamap should only have one item left!");
View Full Code Here

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

  }

  private void testDeodingFromURI(String jsonMask, String uriMask, String description) throws IllegalMaskException,
      IOException
  {
    MaskTree decoded = URIMaskUtil.decodeMaskUriFormat(new StringBuilder(uriMask));
    DataMap expectedMask = dataMapFromString(jsonMask.replace('\'', '"'));
    assertEquals(decoded.getDataMap().toString(),
                 expectedMask.toString(),
                 "Decoding test case failed: \n" + description + "\nmask in URI: "
                     + uriMask + "\nexcpected: " + expectedMask.toString() + "\nactual: "
                     + decoded.toString());
  }
View Full Code Here

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

    }
  }

  private void testEncodingToURI(String jsonMask, String uriMask, String description) throws IOException
  {
    String encoded = URIMaskUtil.encodeMaskForURI(new MaskTree(dataMapFromString(jsonMask.replace('\'', '"'))));

    //to check if two masks are equivalent they are first transformed into their sorted representation
    assertEquals(inSortedOrder(encoded),
                 inSortedOrder(uriMask),
                 "Encoding test case failed: \n" + description + "\nmask in JSON: "
View Full Code Here

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

    if (stack.size() != 1)
    {
      throw new IllegalMaskException("Malformed mask syntax: unmatched nesting");
    }
    result = stack.removeLast();
    return new MaskTree(result);
  }
View Full Code Here

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

  public void testProjectionOnPatch(String[] patchAndProjection, String expectedResult) throws IOException
  {
    DataMap patch = dataMapFromString(patchAndProjection[0].replace('\'', '"'));
    DataMap projection = dataMapFromString(patchAndProjection[1].replace('\'', '"'));
    DataMap expected = dataMapFromString(expectedResult.replace('\'', '"'));
    assertEquals(PatchHelper.applyProjection(PatchRequest.<RecordTemplate>createFromPatchDocument(patch), new MaskTree(projection)).getPatchDocument(), expected);
  }
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.