Package com.linkedin.data.schema

Examples of com.linkedin.data.schema.PathSpec


  }

  @Test
  public void testArrayWildcardPathSpec()
  {
    PathSpec p = ArrayTest.fields().recordInlineArray().items().f();
    Assert.assertEquals(p.toString(), "/recordInlineArray/*/f");
  }
View Full Code Here


  }

  @Test
  public void testMapWildcardPathSpec()
  {
    PathSpec p = MapTest.fields().recordInlineMap().values().f();
    Assert.assertEquals(p.toString(), "/recordInlineMap/*/f");
  }
View Full Code Here

  }

  @Test
  public void testUnionPathSpec()
  {
    PathSpec p = UnionTest.fields().unionWithInline().RecordInUnion().a();
    Assert.assertEquals(p.toString(), "/unionWithInline/com.linkedin.pegasus.generator.test.RecordInUnion/a");

    p = UnionTest.fields().unionWithoutNull().RecordBar().location();
    Assert.assertEquals(p.toString(), "/unionWithoutNull/com.linkedin.pegasus.generator.test.RecordBar/location");
  }
View Full Code Here

  }

  @Test
  public void testTyperefPathSpec()
  {
    PathSpec p = TyperefTest.fields().bar1().location();
    Assert.assertEquals(p.toString(), "/bar1/location");

    p = TyperefTest.fields().barRefMap().values().location();
    Assert.assertEquals(p.toString(), "/barRefMap/*/location");
  }
View Full Code Here

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

  @Test
  public void testProjectionFields()
  {
    final AbstractRequestBuilder<?, ?, ?> builder = new DummyAbstractRequestBuilder();

    builder.addFields(new PathSpec("firstField"), new PathSpec("secondField", PathSpec.WILDCARD, "thirdField"));
    Assert.assertTrue(builder._queryParams.get(RestConstants.FIELDS_PARAM) instanceof PathSpec[]);
    final PathSpec[] fieldsPathSpecs = (PathSpec[])builder._queryParams.get(RestConstants.FIELDS_PARAM);
    Assert.assertEquals(fieldsPathSpecs[0].toString(), "/firstField", "The path spec(s) should match!");
    Assert.assertEquals(fieldsPathSpecs[1].toString(), "/secondField/*/thirdField", "The path spec(s) should match!");

    builder.addMetadataFields(new PathSpec(PathSpec.WILDCARD, "fourthField"), new PathSpec("fifthField"));
    Assert.assertTrue(builder._queryParams.get(RestConstants.METADATA_FIELDS_PARAM) instanceof PathSpec[]);
    final PathSpec[] metadataFieldsPathSpecs = (PathSpec[])builder._queryParams.get(RestConstants.METADATA_FIELDS_PARAM);
    Assert.assertEquals(metadataFieldsPathSpecs[0].toString(), "/*/fourthField", "The path spec(s) should match!");
    Assert.assertEquals(metadataFieldsPathSpecs[1].toString(), "/fifthField", "The path spec(s) should match!");

    builder.addPagingFields(new PathSpec("sixthField", PathSpec.WILDCARD), new PathSpec("seventhField"),
        new PathSpec(PathSpec.WILDCARD));
    Assert.assertTrue(builder._queryParams.get(RestConstants.PAGING_FIELDS_PARAM) instanceof PathSpec[]);
    final PathSpec[] pagingFieldsPathSpecs = (PathSpec[])builder._queryParams.get(RestConstants.PAGING_FIELDS_PARAM);
    Assert.assertEquals(pagingFieldsPathSpecs[0].toString(), "/sixthField/*", "The path spec(s) should match!");
    Assert.assertEquals(pagingFieldsPathSpecs[1].toString(), "/seventhField", "The path spec(s) should match!");

View Full Code Here

  private void serializeTypeFields(DataMap data, PathSpec path) throws IOException
  {
    for (Map.Entry<String, Object> entry : data.entrySet())
    {
      PathSpec currentElement = new PathSpec(path.getPathComponents(), entry.getKey());
      if (isPegasusTypeField(currentElement) &&
              entry.getValue() instanceof DataMap)
      {
        String value = new String(_data_codec.mapToBytes((DataMap)entry.getValue()), RestConstants.DEFAULT_CHARSET);
        data.put(entry.getKey(), value);
View Full Code Here

public class TestPathSpec
{
  @Test
  public void testNestedFieldPathSpec()
  {
    PathSpec p = RecordTest.fields().recordField().location();
    Assert.assertEquals(p.toString(), "/recordField/location");
  }
View Full Code Here

TOP

Related Classes of com.linkedin.data.schema.PathSpec

Copyright © 2018 www.massapicom. 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.