use of com.linkedin.restli.examples.defaults.api.FillInDefaultsRequestBuilders in project rest.li by linkedin.
the class TestFillInDefaultValue method testGet.
@Test(dataProvider = "testGetData")
public void testGet(Long id, HighLevelRecordWithDefault expectedRecord) throws RemoteInvocationException, IOException {
FillInDefaultsRequestBuilders requestBuilders = new FillInDefaultsRequestBuilders();
FillInDefaultsGetRequestBuilder getRequestBuilder = requestBuilders.get();
GetRequest<HighLevelRecordWithDefault> req = getRequestBuilder.id(id).setParam(RestConstants.FILL_IN_DEFAULTS_PARAM, true).build();
HighLevelRecordWithDefault actual = getClient().sendRequest(req).getResponse().getEntity();
Assert.assertEquals(actual, expectedRecord);
}
use of com.linkedin.restli.examples.defaults.api.FillInDefaultsRequestBuilders in project rest.li by linkedin.
the class TestFillInDefaultValue method testFillInDefaultBatchGet.
@Test(dataProvider = "testBatchGetData")
public void testFillInDefaultBatchGet(Long[] ids, HighLevelRecordWithDefault[] expected) throws RemoteInvocationException {
Map<Integer, HighLevelRecordWithDefault> idToRecord = new HashMap<>();
for (int i = 0; i < ids.length; i++) {
idToRecord.put(Math.toIntExact(ids[i]), expected[i]);
}
FillInDefaultsRequestBuilders builders = new FillInDefaultsRequestBuilders();
BatchGetEntityRequest<Long, HighLevelRecordWithDefault> request = builders.batchGet().setParam(RestConstants.FILL_IN_DEFAULTS_PARAM, true).ids(ids).build();
BatchKVResponse<Long, EntityResponse<HighLevelRecordWithDefault>> batchKVResponse = getClient().sendRequest(request).getResponse().getEntity();
for (Map.Entry<Long, EntityResponse<HighLevelRecordWithDefault>> entry : batchKVResponse.getResults().entrySet()) {
HighLevelRecordWithDefault actualEntity = entry.getValue().getEntity();
Assert.assertEquals(actualEntity, idToRecord.getOrDefault(actualEntity.getNoDefaultFieldA(), null));
}
}
use of com.linkedin.restli.examples.defaults.api.FillInDefaultsRequestBuilders in project rest.li by linkedin.
the class TestFillInDefaultValue method testGetWithFillInDefaults.
@Test(dataProvider = "testGetDataNoFillIn")
public void testGetWithFillInDefaults(Long id, HighLevelRecordWithDefault expectedRecord) throws RemoteInvocationException {
FillInDefaultsRequestBuilders requestBuilders = new FillInDefaultsRequestBuilders();
FillInDefaultsGetRequestBuilder getRequestBuilder = requestBuilders.get();
GetRequest<HighLevelRecordWithDefault> req = getRequestBuilder.id(id).build();
HighLevelRecordWithDefault actual = getClient().sendRequest(req).getResponse().getEntity();
Assert.assertEquals(actual, expectedRecord);
}
use of com.linkedin.restli.examples.defaults.api.FillInDefaultsRequestBuilders 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.FillInDefaultsRequestBuilders 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());
}
Aggregations