use of com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault in project rest.li by linkedin.
the class TestFillInDefaultValue method testFillInDefaultFinder.
@Test(dataProvider = "testFinderData")
public void testFillInDefaultFinder(Integer fieldA, List<HighLevelRecordWithDefault> expectedElements, CollectionMetadata expectedCollection, LowLevelRecordWithDefault expectedMetadata) throws RemoteInvocationException {
FillInDefaultsRequestBuilders builders = new FillInDefaultsRequestBuilders();
FindRequest<HighLevelRecordWithDefault> request = builders.findByFindRecords().setParam(RestConstants.FILL_IN_DEFAULTS_PARAM, true).setParam("noDefaultFieldA", fieldA).build();
CollectionResponse<HighLevelRecordWithDefault> actual = getClient().sendRequest(request).getResponse().getEntity();
Assert.assertEquals(actual.getElements(), expectedElements);
Assert.assertEquals(actual.getPaging(), expectedCollection);
Assert.assertEquals(actual.getMetadataRaw(), expectedMetadata.data());
}
use of com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault in project rest.li by linkedin.
the class TestFillInDefaultValue method testFinderData.
@DataProvider(name = "testFinderData")
private Object[][] testFinderData() throws CloneNotSupportedException {
final int total = 3;
List<HighLevelRecordWithDefault> elements = new ArrayList<>();
for (int i = 0; i < total; i++) {
elements.add(new HighLevelRecordWithDefault(expectedTestData.clone()).setNoDefaultFieldA(2));
}
CollectionMetadata collectionMetadata = new CollectionMetadata().setLinks(new LinkArray()).setCount(10).setTotal(3).setStart(0);
LowLevelRecordWithDefault metadata = new LowLevelRecordWithDefault();
metadata.setNameWithDefault(metadata.getNameWithDefault());
return new Object[][] { { 2, elements, collectionMetadata, metadata } };
}
use of com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault in project rest.li by linkedin.
the class TestFillInDefaultValue method testFillInDefaultGetAll.
@Test(dataProvider = "testGetAllData")
public void testFillInDefaultGetAll(List<HighLevelRecordWithDefault> expectedElements, CollectionMetadata expectedCollectionMetadata, LowLevelRecordWithDefault expectedMetadata) throws RemoteInvocationException {
FillInDefaultsRequestBuilders builders = new FillInDefaultsRequestBuilders();
GetAllRequest<HighLevelRecordWithDefault> request = builders.getAll().setParam(RestConstants.FILL_IN_DEFAULTS_PARAM, true).build();
CollectionResponse<HighLevelRecordWithDefault> actual = getClient().sendRequest(request).getResponse().getEntity();
Assert.assertEquals(actual.getElements(), expectedElements);
Assert.assertEquals(actual.getPaging(), expectedCollectionMetadata);
Assert.assertEquals(actual.getMetadataRaw(), expectedMetadata.data());
}
use of com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault in project rest.li by linkedin.
the class TestFillInDefaultValue method testFillInDefaultAction.
@Test(dataProvider = "testActionData")
public void testFillInDefaultAction(Long actionParam) throws RemoteInvocationException {
FillInDefaultsRequestBuilders builders = new FillInDefaultsRequestBuilders();
ActionRequest<HighLevelRecordWithDefault> request = builders.actionDefaultFillAction().actionParamParam(actionParam).setParam(RestConstants.FILL_IN_DEFAULTS_PARAM, true).build();
HighLevelRecordWithDefault actual = getClient().sendRequest(request).getResponse().getEntity();
HighLevelRecordWithDefault expect = new HighLevelRecordWithDefault(expectedTestData).setNoDefaultFieldA(Math.toIntExact(actionParam));
Assert.assertEquals(actual, expect);
}
use of com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault in project rest.li by linkedin.
the class TestFillInDefaultValue method testFillInDefaultBatchFinder.
@Test(dataProvider = "testBatchFinderData")
public void testFillInDefaultBatchFinder(Object[] criteria, HighLevelRecordWithDefault[] expected) throws RemoteInvocationException {
FillInDefaultsRequestBuilders builders = new FillInDefaultsRequestBuilders();
BatchFindRequest<HighLevelRecordWithDefault> request = builders.batchFindBySearchRecords().addCriteriaParam((RecordCriteria) criteria[0]).addCriteriaParam((RecordCriteria) criteria[1]).setParam(RestConstants.FILL_IN_DEFAULTS_PARAM, true).build();
List<BatchFinderCriteriaResult<HighLevelRecordWithDefault>> batchFinderCriteriaResults = getClient().sendRequest(request).getResponse().getEntity().getResults();
Set<HighLevelRecordWithDefault> actualActionResponse = new HashSet<>();
for (BatchFinderCriteriaResult<HighLevelRecordWithDefault> result : batchFinderCriteriaResults) {
actualActionResponse.addAll(result.getElements());
}
Set<HighLevelRecordWithDefault> expectedActionResponse = new HashSet<>(Arrays.asList(expected));
Assert.assertEquals(actualActionResponse, expectedActionResponse);
}
Aggregations