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());
}
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());
}
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");
}
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());
}
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());
}
Aggregations