use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestCustomMetadataProjection method testRootAutomaticMetadataManualSingleRootNonexistentMeta.
/**
* Calls the resource method rootAutomaticMetadataManual with a single root object entity field and a single
* custom metadata field which does not exist in Greeting. This is a negative test.
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testRootAutomaticMetadataManualSingleRootNonexistentMeta(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> request = builders.findBy("rootAutomaticMetadataManual").metadataFields(//Note the use of Group here instead of Greeting
Group.fields().description()).build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(request).getResponse();
assertEntityElements(response.getEntity().getElements(), true, /*hasTone*/
true, /*hasMessage*/
true);
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
//Note that we are performing a manual projection in the resource method, but not removing anything because
//there exists an invalid field in the metadata projection mask
assertCustomMetadata(metadataGreeting, true, /*hasTone*/
true, /*hasMessage*/
true);
Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
assertAllPagingFieldsExist(response.getEntity().getPaging());
}
use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestCustomMetadataProjection method testRootAutomaticMetadataAutomaticNoFields.
/**
* Calls the resource method rootAutomaticMetadataAutomatic with no fields specified in any projection
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testRootAutomaticMetadataAutomaticNoFields(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> findRequest = builders.findBy("rootAutomaticMetadataAutomatic").build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(findRequest).getResponse();
assertEntityElements(response.getEntity().getElements(), true, /*hasTone*/
true, /*hasMessage*/
true);
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
assertCustomMetadata(metadataGreeting, true, /*hasTone*/
true, /*hasMessage*/
true);
Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
assertAllPagingFieldsExist(response.getEntity().getPaging());
}
use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestCustomMetadataProjection method testRootAutomaticMetadataManualSingleRootSingleMeta.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//The following tests operate on the resource method rootAutomaticMetadataManual
/**
* Calls the resource method rootAutomaticMetadataManual with a single metadata field and a single root object
* entity field
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testRootAutomaticMetadataManualSingleRootSingleMeta(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> request = builders.findBy("rootAutomaticMetadataManual").fields(Greeting.fields().tone()).metadataFields(Greeting.fields().message()).build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(request).getResponse();
assertEntityElements(response.getEntity().getElements(), true, /*hasTone*/
false, /*hasMessage*/
false);
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
//Note that the server here will intentionally leave the tone in the greeting
assertCustomMetadata(metadataGreeting, true, /*hasTone*/
true, /*hasMessage*/
false);
Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
assertAllPagingFieldsExist(response.getEntity().getPaging());
}
use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestCustomMetadataProjection method testRootAutomaticMetadataManualNoFields.
/**
* Calls the resource method rootAutomaticMetadataManual with no fields specified in any projection
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testRootAutomaticMetadataManualNoFields(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> findRequest = builders.findBy("rootAutomaticMetadataManual").build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(findRequest).getResponse();
assertEntityElements(response.getEntity().getElements(), true, /*hasTone*/
true, /*hasMessage*/
true);
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
//Note here the resource method is doing manual projection, but not removing anything, so we should get all
//the fields back
assertCustomMetadata(metadataGreeting, true, /*hasTone*/
true, /*hasMessage*/
true);
Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
assertAllPagingFieldsExist(response.getEntity().getPaging());
}
use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestGreetingClientContentTypes method testFinder.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "clientDataDataProvider")
public void testFinder(RestClient restClient, RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
Request<CollectionResponse<Greeting>> request = builders.findBy("Search").setQueryParam("tone", Tone.SINCERE).paginate(1, 2).build();
Response<CollectionResponse<Greeting>> response = restClient.sendRequest(request).getResponse();
CollectionResponse<Greeting> collectionResponse = response.getEntity();
List<Greeting> greetings = collectionResponse.getElements();
for (Greeting g : greetings) {
Assert.assertEquals(g.getTone(), Tone.SINCERE);
}
collectionResponse.getPaging().getLinks();
}
Aggregations