use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestPagingProjection method testMetadataManualPagingFullyAutomaticSingleMetaPagingCount.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//The following tests operate on the resource method metadataManualPagingFullyAutomatic
/**
* Calls the resource method metadataManualPagingFullyAutomatic with a single metadata field and a single paging
* field for 'count'.
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testMetadataManualPagingFullyAutomaticSingleMetaPagingCount(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> request = builders.findBy("metadataManualPagingFullyAutomatic").metadataFields(Greeting.fields().message()).pagingFields(CollectionMetadata.fields().count()).build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(request).getResponse();
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
//We should ideally only get back the message field in our metadata, but the resource method here intentionally
//sends back the message and the ID to verify that restli doesn't interfere with a manual metadata projection.
assertGreeting(metadataGreeting, false, /*hasTone*/
true, /*hasMessage*/
true);
Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
assertPaging(response.getEntity().getPaging(), false, /*hasTotal*/
false, /*hasStart*/
true, /*hasCount*/
false);
}
use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestPagingProjection method testMetadataAutomaticPagingFullyAutomaticSingleMetaMultiplePaging.
/**
* Calls the resource method metadataAutomaticPagingFullyAutomatic with a single metadata field and multiple paging
* fields using 'links' and 'total'.
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testMetadataAutomaticPagingFullyAutomaticSingleMetaMultiplePaging(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> request = builders.findBy("metadataAutomaticPagingFullyAutomatic").metadataFields(Greeting.fields().message()).pagingFields(CollectionMetadata.fields().total(), 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*/
false);
Assert.assertTrue(response.getEntity().hasPaging(), "We must have paging!");
assertPaging(response.getEntity().getPaging(), true, /*hasTotal*/
false, /*hasStart*/
false, /*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 testMetadataManualPagingFullyAutomaticNoFields.
/**
* Calls the resource method metadataManualPagingFullyAutomatic without any projection fields specified
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testMetadataManualPagingFullyAutomaticNoFields(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> request = builders.findBy("metadataManualPagingFullyAutomatic").metadataFields().pagingFields().build();
final Response<CollectionResponse<Greeting>> response = getClient().sendRequest(request).getResponse();
final Greeting metadataGreeting = new Greeting(response.getEntity().getMetadataRaw());
//This is manual on the server, so everything should be there
assertGreeting(metadataGreeting, true, /*hasTone*/
true, /*hasMessage*/
true);
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 TestPagingProjection method testMetadataAutomaticPagingFullyAutomaticSingleMetaPagingCount.
//The following tests operate on the resource method metadataAutomaticPagingFullyAutomatic
/**
* Calls the resource method metadataAutomaticPagingFullyAutomatic with a single metadata field and a single paging
* field for 'count'.
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testMetadataAutomaticPagingFullyAutomaticSingleMetaPagingCount(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> request = builders.findBy("metadataAutomaticPagingFullyAutomatic").metadataFields(Greeting.fields().message()).pagingFields(CollectionMetadata.fields().count()).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(), false, /*hasTotal*/
false, /*hasStart*/
true, /*hasCount*/
false);
}
use of com.linkedin.restli.common.CollectionResponse in project rest.li by linkedin.
the class TestPagingProjection method testMetadataAutomaticPagingAutomaticPartialNullIncorrectSingleMetaPagingCount.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//The following tests operate on the resource method metadataAutomaticPagingAutomaticPartialNullIncorrect
/**
* Calls the resource method metadataAutomaticPagingAutomaticPartialNullIncorrect with a single metadata field
* and a single paging field for 'count'.
*/
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testMetadataAutomaticPagingAutomaticPartialNullIncorrectSingleMetaPagingCount(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
final Request<CollectionResponse<Greeting>> request = builders.findBy("metadataAutomaticPagingAutomaticPartialNullIncorrect").metadataFields(Greeting.fields().message()).pagingFields(CollectionMetadata.fields().count()).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(), false, /*hasTotal*/
false, /*hasStart*/
true, /*hasCount*/
false);
}
Aggregations