use of com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault in project rest.li by linkedin.
the class FieldFillInDefaultResources method getAllHighLevelRecordWithDefault.
@RestMethod.GetAll
public CollectionResult<HighLevelRecordWithDefault, LowLevelRecordWithDefault> getAllHighLevelRecordWithDefault(@PagingContextParam PagingContext pagingContext) {
final int total = 3;
List<HighLevelRecordWithDefault> elements = new LinkedList<>();
for (int i = 0; i < total; i++) {
elements.add(new HighLevelRecordWithDefault().setNoDefaultFieldA(i));
}
LowLevelRecordWithDefault metadata = new LowLevelRecordWithDefault();
return new CollectionResult<>(elements, total, metadata);
}
use of com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault in project rest.li by linkedin.
the class TestFillInDefaultValue method testGetAllData.
@DataProvider(name = "testGetAllData")
private Object[][] testGetAllData() throws CloneNotSupportedException {
final int count = 3;
List<HighLevelRecordWithDefault> elements = new ArrayList<>();
for (int i = 0; i < count; i++) {
elements.add(new HighLevelRecordWithDefault(expectedTestData.clone()).setNoDefaultFieldA(i));
}
CollectionMetadata collectionMetadata = new CollectionMetadata().setCount(10).setTotal(3).setStart(0).setLinks(new LinkArray());
LowLevelRecordWithDefault metadata = new LowLevelRecordWithDefault();
metadata.setNameWithDefault(metadata.getNameWithDefault());
return new Object[][] { { elements, collectionMetadata, metadata } };
}
use of com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault 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.HighLevelRecordWithDefault 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.HighLevelRecordWithDefault 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);
}
Aggregations