use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestPagingProjection method testMetadataAutomaticPagingAutomaticPartialNullIncorrectSingleMetaPagingTotal.
/**
* Calls the resource method metadataAutomaticPagingAutomaticPartialNullIncorrect with a single metadata field and a single paging
* field for 'total'.
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testMetadataAutomaticPagingAutomaticPartialNullIncorrectSingleMetaPagingTotal(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> request = builders.findBy("metadataAutomaticPagingAutomaticPartialNullIncorrect").metadataFields(Greeting.fields().message()).pagingFields(CollectionMetadata.fields().total()).build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(request).getResponse();
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
assertGreeting(metadataGreeting, false, /*hasTone*/
true, /*hasMessage*/
false);
Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
//Resource method on the server specified null so we shouldn't get anything back
assertPaging(response.getEntity().getPaging(), false, /*hasTotal*/
false, /*hasStart*/
false, /*hasCount*/
false);
CollectionMetadata paging = response.getEntity().getPaging();
final int pagingTotal = paging.getTotal();
Assert.assertEquals(pagingTotal, 0, "We should still get the default of 0");
}
use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestPagingProjection method testMetadataAutomaticPagingAutomaticPartialNullSingleMetaPagingTotal.
/**
* Calls the resource method metadataAutomaticPagingAutomaticPartialNull with a single metadata field and a single paging
* field for 'total'.
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testMetadataAutomaticPagingAutomaticPartialNullSingleMetaPagingTotal(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> request = builders.findBy("metadataAutomaticPagingAutomaticPartialNull").metadataFields(Greeting.fields().message()).pagingFields(CollectionMetadata.fields().total()).build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(request).getResponse();
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
assertGreeting(metadataGreeting, false, /*hasTone*/
true, /*hasMessage*/
false);
Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
assertPaging(response.getEntity().getPaging(), true, /*hasTotal*/
false, /*hasStart*/
false, /*hasCount*/
false);
final int totalCount = response.getEntity().getPaging().getTotal();
Assert.assertEquals(totalCount, 2, "We must have 2 in our count");
}
use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestPagingProjection method testGetAllMetadataManualPagingAutomaticPartialNull.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//The following are single tests against individual resource methods
/**
* Calls the resource method getAllMetadataManualPagingAutomaticPartialNull with a single metadata field and multiple
* paging fields. This is the only test for this method and used to make sure that the GET_ALL code path within restli
* for paging projection calculation also works as intended.
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testGetAllMetadataManualPagingAutomaticPartialNull(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> request = builders.getAll().metadataFields(Greeting.fields().message()).pagingFields(CollectionMetadata.fields().total(), CollectionMetadata.fields().count(), CollectionMetadata.fields().links()).build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(request).getResponse();
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
assertGreeting(metadataGreeting, false, /*hasTone*/
true, /*hasMessage*/
true);
Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
assertPaging(response.getEntity().getPaging(), true, /*hasTotal*/
false, /*hasStart*/
true, /*hasCount*/
true);
final int totalCount = response.getEntity().getPaging().getTotal();
Assert.assertEquals(totalCount, 2, "We must have 2 in our count");
}
use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestPagingProjection method testMetadataAutomaticPagingAutomaticPartialNullNoFields.
/**
* Calls the resource method metadataAutomaticPagingAutomaticPartialNull without any projection fields specified
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testMetadataAutomaticPagingAutomaticPartialNullNoFields(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> request = builders.findBy("metadataAutomaticPagingAutomaticPartialNull").metadataFields().pagingFields().build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(request).getResponse();
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
//nothing should be sent back for both below
assertGreeting(metadataGreeting, false, /*hasTone*/
false, /*hasMessage*/
false);
assertPaging(response.getEntity().getPaging(), false, /*hasTotal*/
false, /*hasStart*/
false, /*hasCount*/
false);
}
use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestGreetingsClient method testSearch.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testSearch(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
Request<CollectionResponse<Greeting>> findRequest = builders.findBy("Search").setQueryParam("tone", Tone.FRIENDLY).build();
List<Greeting> greetings = getClient().sendRequest(findRequest).getResponse().getEntity().getElements();
for (Greeting g : greetings) {
Assert.assertEquals(g.getTone(), Tone.FRIENDLY);
Assert.assertNotNull(g.getMessage());
}
}
Aggregations