Search in sources :

Example 6 with CreateGreetingFluentClient

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());
}
Also used : CreateGreeting(com.linkedin.restli.examples.greetings.client.CreateGreeting) Greeting(com.linkedin.restli.examples.greetings.api.Greeting) PartialUpdateGreeting(com.linkedin.restli.examples.greetings.client.PartialUpdateGreeting) CreateGreetingFluentClient(com.linkedin.restli.examples.greetings.client.CreateGreetingFluentClient) CreateIdEntityStatus(com.linkedin.restli.common.CreateIdEntityStatus) CreateGreeting(com.linkedin.restli.examples.greetings.client.CreateGreeting) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Aggregations

CreateGreeting (com.linkedin.restli.examples.greetings.client.CreateGreeting)6 CreateGreetingFluentClient (com.linkedin.restli.examples.greetings.client.CreateGreetingFluentClient)6 Test (org.testng.annotations.Test)6 List (java.util.List)4 CreateIdEntityStatus (com.linkedin.restli.common.CreateIdEntityStatus)3 CreateIdStatus (com.linkedin.restli.common.CreateIdStatus)3 IdEntityResponse (com.linkedin.restli.common.IdEntityResponse)3 CustomLong (com.linkedin.restli.examples.custom.types.CustomLong)3 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)3 PartialUpdateGreeting (com.linkedin.restli.examples.greetings.client.PartialUpdateGreeting)3 ParSeqUnitTestHelper (com.linkedin.parseq.ParSeqUnitTestHelper)2 ParSeqRestliClient (com.linkedin.restli.client.ParSeqRestliClient)2 ParSeqRestliClientBuilder (com.linkedin.restli.client.ParSeqRestliClientBuilder)2 ParSeqRestliClientConfigBuilder (com.linkedin.restli.client.ParSeqRestliClientConfigBuilder)2 RestLiResponseException (com.linkedin.restli.client.RestLiResponseException)2 PatchGenerator (com.linkedin.restli.client.util.PatchGenerator)2 BatchCollectionResponse (com.linkedin.restli.common.BatchCollectionResponse)2 BatchFinderCriteriaResult (com.linkedin.restli.common.BatchFinderCriteriaResult)2 CollectionMetadata (com.linkedin.restli.common.CollectionMetadata)2 CollectionResponse (com.linkedin.restli.common.CollectionResponse)2