Search in sources :

Example 6 with MaskMap

use of com.linkedin.data.schema.MaskMap in project rest.li by linkedin.

the class TestMaskMap method testNonAliasedUnionFieldNestedProjection.

@Test
public void testNonAliasedUnionFieldNestedProjection() {
    MaskMap mask = UnionTest.createMask().withUnionWithoutNull(unionMask -> unionMask.withArray().withBoolean().withRecordBar(recordMask -> recordMask.withLocation()).withString().withBytes());
    MaskTree tree = MaskCreator.createPositiveMask(PathSpecSet.of(UnionTest.fields().unionWithoutNull().Array(), UnionTest.fields().unionWithoutNull().Boolean(), UnionTest.fields().unionWithoutNull().RecordBar().location(), UnionTest.fields().unionWithoutNull().String(), UnionTest.fields().unionWithoutNull().Bytes()));
    Assert.assertEquals(mask.getDataMap(), tree.getDataMap());
}
Also used : MaskMap(com.linkedin.data.schema.MaskMap) MaskCreator(com.linkedin.data.transform.filter.request.MaskCreator) PathSpecSet(com.linkedin.data.schema.PathSpecSet) Assert(org.testng.Assert) CustomRecord(com.linkedin.pegasus.generator.test.pdl.fixtures.CustomRecord) MaskTree(com.linkedin.data.transform.filter.request.MaskTree) Test(org.testng.annotations.Test) WithCustomRecord(com.linkedin.pegasus.generator.test.idl.records.WithCustomRecord) MaskTree(com.linkedin.data.transform.filter.request.MaskTree) MaskMap(com.linkedin.data.schema.MaskMap) Test(org.testng.annotations.Test)

Example 7 with MaskMap

use of com.linkedin.data.schema.MaskMap in project rest.li by linkedin.

the class TestMaskMap method testMapFieldDefaultProjection.

@Test
public void testMapFieldDefaultProjection() {
    MaskMap mask = MapTest.createMask().withRecordInlineMap();
    MaskTree tree = MaskCreator.createPositiveMask(PathSpecSet.of(MapTest.fields().recordInlineMap()));
    Assert.assertEquals(mask.getDataMap(), tree.getDataMap());
}
Also used : MaskTree(com.linkedin.data.transform.filter.request.MaskTree) MaskMap(com.linkedin.data.schema.MaskMap) Test(org.testng.annotations.Test)

Example 8 with MaskMap

use of com.linkedin.data.schema.MaskMap in project rest.li by linkedin.

the class TestQueryParamsUtil method testMaskTreeProjectionParams.

@Test
public void testMaskTreeProjectionParams() {
    Map<String, Object> queryParams = new HashMap<>();
    MaskMap fieldsMask = TestRecord.createMask().withId().withMessage();
    queryParams.put(RestConstants.FIELDS_PARAM, fieldsMask.getDataMap());
    DataMap pagingMask = new DataMap();
    pagingMask.put("paging", MaskMap.POSITIVE_MASK);
    queryParams.put(RestConstants.PAGING_FIELDS_PARAM, pagingMask);
    DataMap metaDataMask = new DataMap();
    metaDataMask.put("metadata", MaskMap.POSITIVE_MASK);
    queryParams.put(RestConstants.METADATA_FIELDS_PARAM, metaDataMask);
    DataMap dataMap = QueryParamsUtil.convertToDataMap(queryParams, Collections.emptyMap(), AllProtocolVersions.LATEST_PROTOCOL_VERSION, (paramName, pathSpecs) -> null);
    Assert.assertSame(dataMap.get(RestConstants.FIELDS_PARAM), fieldsMask.getDataMap());
    Assert.assertSame(dataMap.get(RestConstants.PAGING_FIELDS_PARAM), pagingMask);
    Assert.assertSame(dataMap.get(RestConstants.METADATA_FIELDS_PARAM), metaDataMask);
    UriBuilder uriBuilder = new UriBuilder();
    URIParamUtils.addSortedParams(uriBuilder, dataMap);
    String uri = uriBuilder.build().getQuery();
    Assert.assertEquals(uri, "fields=message,id&metadataFields=metadata&pagingFields=paging");
}
Also used : HashMap(java.util.HashMap) MaskMap(com.linkedin.data.schema.MaskMap) UriBuilder(com.linkedin.jersey.api.uri.UriBuilder) DataMap(com.linkedin.data.DataMap) Test(org.testng.annotations.Test)

Example 9 with MaskMap

use of com.linkedin.data.schema.MaskMap in project rest.li by linkedin.

the class TestMaskMap method testUnionFieldNestedProjection.

@Test
public void testUnionFieldNestedProjection() {
    MaskMap mask = UnionTest.createMask().withUnionWithAliases(unionMask -> unionMask.withMemAnotherInt().withMemInt().withMemBoolean().withMemAnotherMap().withMemMap());
    MaskTree tree = MaskCreator.createPositiveMask(PathSpecSet.of(UnionTest.fields().unionWithAliases().MemAnotherInt(), UnionTest.fields().unionWithAliases().MemInt(), UnionTest.fields().unionWithAliases().MemBoolean(), UnionTest.fields().unionWithAliases().MemAnotherMap(), UnionTest.fields().unionWithAliases().MemMap()));
    Assert.assertEquals(mask.getDataMap(), tree.getDataMap());
}
Also used : MaskTree(com.linkedin.data.transform.filter.request.MaskTree) MaskMap(com.linkedin.data.schema.MaskMap) Test(org.testng.annotations.Test)

Example 10 with MaskMap

use of com.linkedin.data.schema.MaskMap in project rest.li by linkedin.

the class TestMaskMap method testMapFieldNestedProjection.

@Test
public void testMapFieldNestedProjection() {
    MaskMap mask = MapTest.createMask().withRecordInlineMap(mapMask -> mapMask.withValues(RecordInMap.ProjectionMask::withF));
    MaskTree tree = MaskCreator.createPositiveMask(PathSpecSet.of(MapTest.fields().recordInlineMap().values().f()));
    Assert.assertEquals(mask.getDataMap(), tree.getDataMap());
}
Also used : MaskTree(com.linkedin.data.transform.filter.request.MaskTree) MaskMap(com.linkedin.data.schema.MaskMap) Test(org.testng.annotations.Test)

Aggregations

MaskMap (com.linkedin.data.schema.MaskMap)14 Test (org.testng.annotations.Test)14 MaskTree (com.linkedin.data.transform.filter.request.MaskTree)13 DataMap (com.linkedin.data.DataMap)1 PathSpecSet (com.linkedin.data.schema.PathSpecSet)1 MaskCreator (com.linkedin.data.transform.filter.request.MaskCreator)1 UriBuilder (com.linkedin.jersey.api.uri.UriBuilder)1 WithCustomRecord (com.linkedin.pegasus.generator.test.idl.records.WithCustomRecord)1 CustomRecord (com.linkedin.pegasus.generator.test.pdl.fixtures.CustomRecord)1 HashMap (java.util.HashMap)1 Assert (org.testng.Assert)1