use of com.linkedin.restli.examples.greetings.client.CreateGreetingFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testBatchCreateReturnEntity.
@Test
public void testBatchCreateReturnEntity() throws Exception {
CreateGreeting greetings = new CreateGreetingFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
String msg1 = Double.toString(Math.random());
String msg2 = Double.toString(Math.random());
CompletionStage<List<CreateIdEntityStatus<Long, Greeting>>> result = greetings.batchCreateAndGet(Arrays.asList(getGreeting(msg1), getGreeting(msg2)));
CompletableFuture<List<CreateIdEntityStatus<Long, Greeting>>> future = result.toCompletableFuture();
List<CreateIdEntityStatus<Long, Greeting>> entities = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertEquals(entities.size(), 2);
Assert.assertNotNull(entities.get(0).getEntity());
Assert.assertEquals(msg1, entities.get(0).getEntity().getMessage());
Assert.assertNotNull(entities.get(1).getEntity());
Assert.assertEquals(msg2, entities.get(1).getEntity().getMessage());
}
Aggregations