use of com.linkedin.restli.examples.greetings.client.PagingMetadataProjectionsFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApiWithProjections method testFinderWithPagingProjection.
@Test
public void testFinderWithPagingProjection() throws Exception {
PagingMetadataProjections greetings = new PagingMetadataProjectionsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
CompletionStage<CollectionResponse<Greeting>> result = greetings.findByMetadataAutomaticPagingFullyAutomatic(params -> params.withPagingMask(pageMask -> pageMask.withTotal()));
CompletableFuture<CollectionResponse<Greeting>> future = result.toCompletableFuture();
CollectionResponse<Greeting> greetingResult = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertTrue(greetingResult.hasPaging());
Assert.assertFalse(greetingResult.getPaging().hasCount());
Assert.assertFalse(greetingResult.getPaging().hasStart());
Assert.assertFalse(greetingResult.getPaging().hasLinks());
Assert.assertTrue(greetingResult.getPaging().hasTotal());
Assert.assertTrue(greetingResult.getPaging().getTotal() > 0);
// Same request without projection.
result = greetings.findByMetadataAutomaticPagingFullyAutomatic();
future = result.toCompletableFuture();
greetingResult = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertTrue(greetingResult.hasPaging());
Assert.assertTrue(greetingResult.getPaging().hasCount());
Assert.assertTrue(greetingResult.getPaging().hasStart());
Assert.assertTrue(greetingResult.getPaging().hasLinks());
Assert.assertTrue(greetingResult.getPaging().hasTotal());
Assert.assertTrue(greetingResult.getPaging().getTotal() > 0);
}
use of com.linkedin.restli.examples.greetings.client.PagingMetadataProjectionsFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApiWithProjections method testGetAllWithMetadataProjection.
@Test
public void testGetAllWithMetadataProjection() throws Exception {
PagingMetadataProjections greetings = new PagingMetadataProjectionsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
CompletionStage<CollectionResponse<Greeting>> result = greetings.getAll(params -> params.withMetadataMask(metadataMask -> metadataMask.withMessage()));
CompletableFuture<CollectionResponse<Greeting>> future = result.toCompletableFuture();
CollectionResponse<Greeting> greetingResult = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertNotNull(greetingResult.getMetadataRaw());
Greeting metadata = new Greeting(greetingResult.getMetadataRaw());
Assert.assertTrue(metadata.hasMessage());
Assert.assertFalse(metadata.hasTone());
// Same request without projection.
result = greetings.findByMetadataAutomaticPagingFullyAutomatic();
future = result.toCompletableFuture();
greetingResult = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertNotNull(greetingResult.getMetadataRaw());
metadata = new Greeting(greetingResult.getMetadataRaw());
Assert.assertTrue(metadata.hasMessage());
Assert.assertTrue(metadata.hasTone());
}
use of com.linkedin.restli.examples.greetings.client.PagingMetadataProjectionsFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApiWithProjections method testGetAllWithPagingProjection.
@Test
public void testGetAllWithPagingProjection() throws Exception {
PagingMetadataProjections greetings = new PagingMetadataProjectionsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
CompletionStage<CollectionResponse<Greeting>> result = greetings.getAll(params -> params.withPagingMask(pageMask -> pageMask.withTotal().withStart()));
CompletableFuture<CollectionResponse<Greeting>> future = result.toCompletableFuture();
CollectionResponse<Greeting> greetingResult = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertTrue(greetingResult.hasPaging());
Assert.assertFalse(greetingResult.getPaging().hasCount());
Assert.assertTrue(greetingResult.getPaging().hasStart());
Assert.assertEquals((int) greetingResult.getPaging().getStart(), 0);
Assert.assertFalse(greetingResult.getPaging().hasLinks());
Assert.assertTrue(greetingResult.getPaging().getTotal() > 0);
// Same request without projection.
result = greetings.getAll();
future = result.toCompletableFuture();
greetingResult = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertTrue(greetingResult.hasPaging());
Assert.assertTrue(greetingResult.getPaging().hasCount());
Assert.assertTrue(greetingResult.getPaging().hasStart());
Assert.assertTrue(greetingResult.getPaging().hasLinks());
// The resource applies manual projection and returns total only when it is explicitly projected. So no total field here.
}
use of com.linkedin.restli.examples.greetings.client.PagingMetadataProjectionsFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApiWithProjections method testFinderWithMetadataProjection.
@Test
public void testFinderWithMetadataProjection() throws Exception {
PagingMetadataProjections greetings = new PagingMetadataProjectionsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
CompletionStage<CollectionResponse<Greeting>> result = greetings.findByMetadataAutomaticPagingFullyAutomatic(params -> params.withMetadataMask(metadataMask -> metadataMask.withId()));
CompletableFuture<CollectionResponse<Greeting>> future = result.toCompletableFuture();
CollectionResponse<Greeting> greetingResult = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertNotNull(greetingResult.getMetadataRaw());
Greeting metadata = new Greeting(greetingResult.getMetadataRaw());
Assert.assertFalse(metadata.hasMessage());
Assert.assertFalse(metadata.hasTone());
Assert.assertTrue(metadata.hasId());
// Same request without projection.
result = greetings.findByMetadataAutomaticPagingFullyAutomatic();
future = result.toCompletableFuture();
greetingResult = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertNotNull(greetingResult.getMetadataRaw());
metadata = new Greeting(greetingResult.getMetadataRaw());
Assert.assertTrue(metadata.hasMessage());
Assert.assertTrue(metadata.hasTone());
Assert.assertTrue(metadata.hasId());
}
Aggregations