use of com.linkedin.restli.common.LinkArray in project rest.li by linkedin.
the class TestCollectionResponseBuilder method dataProvider.
@DataProvider(name = "testData")
public Object[][] dataProvider() throws CloneNotSupportedException {
Foo metadata = new Foo().setStringField("metadata").setIntField(7);
Foo projectedMetadata = new Foo().setIntField(7);
final List<Foo> generatedList = generateTestList();
final List<Foo> testListWithProjection = generateTestListWithProjection();
CollectionResult<Foo, Foo> collectionResult = new CollectionResult<>(generatedList, generatedList.size(), metadata);
DataMap dataProjectionDataMap = new DataMap();
dataProjectionDataMap.put("stringField", MaskOperation.POSITIVE_MASK_OP.getRepresentation());
MaskTree dataMaskTree = new MaskTree(dataProjectionDataMap);
DataMap metadataProjectionDataMap = new DataMap();
metadataProjectionDataMap.put("intField", MaskOperation.POSITIVE_MASK_OP.getRepresentation());
MaskTree metadataMaskTree = new MaskTree(metadataProjectionDataMap);
DataMap pagingProjectDataMap = new DataMap();
pagingProjectDataMap.put("count", MaskOperation.POSITIVE_MASK_OP.getRepresentation());
MaskTree pagingMaskTree = new MaskTree(pagingProjectDataMap);
CollectionMetadata collectionMetadata1 = new CollectionMetadata().setCount(10).setStart(0).setLinks(new LinkArray());
CollectionMetadata collectionMetadata2 = collectionMetadata1.clone().setTotal(2);
CollectionMetadata collectionMetadataWithProjection = new CollectionMetadata().setCount(10);
ProjectionMode auto = ProjectionMode.AUTOMATIC;
ProjectionMode manual = ProjectionMode.MANUAL;
List<Object[]> data = new ArrayList<>();
for (ResourceMethod resourceMethod : BUILDERS.keySet()) {
// auto projection for data and metadata with null projection masks
data.add(new Object[] { generatedList, null, generatedList, collectionMetadata1, null, null, null, auto, auto, resourceMethod });
data.add(new Object[] { collectionResult, metadata.data(), collectionResult.getElements(), collectionMetadata2, null, null, null, auto, auto, resourceMethod });
// manual projection for data and metadata with null projection masks
data.add(new Object[] { generatedList, null, generatedList, collectionMetadata1, null, null, null, manual, manual, resourceMethod });
data.add(new Object[] { collectionResult, metadata.data(), collectionResult.getElements(), collectionMetadata2, null, null, null, manual, manual, resourceMethod });
// NOTE - we always apply projections to the CollectionMetaData if the paging MaskTree is non-null
// since ProjectionMode.AUTOMATIC is used.
// manual projection for data and metadata with non-null projection masks
data.add(new Object[] { generatedList, null, generatedList, collectionMetadataWithProjection, dataMaskTree, metadataMaskTree, pagingMaskTree, manual, manual, resourceMethod });
data.add(new Object[] { collectionResult, metadata.data(), collectionResult.getElements(), collectionMetadataWithProjection, dataMaskTree, metadataMaskTree, pagingMaskTree, manual, manual, resourceMethod });
// auto projection for data with non-null data and paging projection masks
data.add(new Object[] { generatedList, null, testListWithProjection, collectionMetadataWithProjection, dataMaskTree, null, pagingMaskTree, auto, auto, resourceMethod });
// auto projection for data and metadata with non-null projection masks
data.add(new Object[] { collectionResult, projectedMetadata.data(), testListWithProjection, collectionMetadataWithProjection, dataMaskTree, metadataMaskTree, pagingMaskTree, auto, auto, resourceMethod });
// auto data projection, manual metadata projection, and auto (default) paging projection
data.add(new Object[] { collectionResult, metadata.data(), testListWithProjection, collectionMetadataWithProjection, dataMaskTree, metadataMaskTree, pagingMaskTree, auto, manual, resourceMethod });
}
return data.toArray(new Object[data.size()][]);
}
Aggregations