Search in sources :

Example 1 with FillInDefaultsRequestBuilders

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);
}
Also used : FillInDefaultsGetRequestBuilder(com.linkedin.restli.examples.defaults.api.FillInDefaultsGetRequestBuilder) FillInDefaultsRequestBuilders(com.linkedin.restli.examples.defaults.api.FillInDefaultsRequestBuilders) HighLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault) Test(org.testng.annotations.Test)

Example 2 with FillInDefaultsRequestBuilders

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));
    }
}
Also used : HashMap(java.util.HashMap) EntityResponse(com.linkedin.restli.common.EntityResponse) HashMap(java.util.HashMap) DataMap(com.linkedin.data.DataMap) Map(java.util.Map) HighLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault) FillInDefaultsRequestBuilders(com.linkedin.restli.examples.defaults.api.FillInDefaultsRequestBuilders) Test(org.testng.annotations.Test)

Example 3 with FillInDefaultsRequestBuilders

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);
}
Also used : FillInDefaultsGetRequestBuilder(com.linkedin.restli.examples.defaults.api.FillInDefaultsGetRequestBuilder) FillInDefaultsRequestBuilders(com.linkedin.restli.examples.defaults.api.FillInDefaultsRequestBuilders) HighLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault) Test(org.testng.annotations.Test)

Example 4 with FillInDefaultsRequestBuilders

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());
}
Also used : FillInDefaultsRequestBuilders(com.linkedin.restli.examples.defaults.api.FillInDefaultsRequestBuilders) HighLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault) Test(org.testng.annotations.Test)

Example 5 with FillInDefaultsRequestBuilders

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());
}
Also used : FillInDefaultsRequestBuilders(com.linkedin.restli.examples.defaults.api.FillInDefaultsRequestBuilders) HighLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault) Test(org.testng.annotations.Test)

Aggregations

FillInDefaultsRequestBuilders (com.linkedin.restli.examples.defaults.api.FillInDefaultsRequestBuilders)8 HighLevelRecordWithDefault (com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault)8 Test (org.testng.annotations.Test)8 FillInDefaultsGetRequestBuilder (com.linkedin.restli.examples.defaults.api.FillInDefaultsGetRequestBuilder)2 DataMap (com.linkedin.data.DataMap)1 BatchFinderCriteriaResult (com.linkedin.restli.common.BatchFinderCriteriaResult)1 EntityResponse (com.linkedin.restli.common.EntityResponse)1 RecordCriteria (com.linkedin.restli.examples.defaults.api.RecordCriteria)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1