Search in sources :

Example 6 with FillInDefaultsRequestBuilders

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

Example 7 with FillInDefaultsRequestBuilders

use of com.linkedin.restli.examples.defaults.api.FillInDefaultsRequestBuilders 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);
}
Also used : BatchFinderCriteriaResult(com.linkedin.restli.common.BatchFinderCriteriaResult) RecordCriteria(com.linkedin.restli.examples.defaults.api.RecordCriteria) FillInDefaultsRequestBuilders(com.linkedin.restli.examples.defaults.api.FillInDefaultsRequestBuilders) HighLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 8 with FillInDefaultsRequestBuilders

use of com.linkedin.restli.examples.defaults.api.FillInDefaultsRequestBuilders in project rest.li by linkedin.

the class TestFillInDefaultValue method testFillInDefaultGetAllWithoutRequireDefault.

@Test(dataProvider = "testGetAllDataWithoutRequireDefault")
public void testFillInDefaultGetAllWithoutRequireDefault(List<HighLevelRecordWithDefault> expectedElements, CollectionMetadata expectedCollectionMetadata, LowLevelRecordWithDefault expectedMetadata) throws RemoteInvocationException {
    FillInDefaultsRequestBuilders builders = new FillInDefaultsRequestBuilders();
    GetAllRequest<HighLevelRecordWithDefault> request = builders.getAll().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