Search in sources :

Example 26 with GreetingsFluentClient

use of com.linkedin.restli.examples.greetings.client.GreetingsFluentClient in project rest.li by linkedin.

the class TestParseqBasedFluentClientApi method testBatchUpdateWithErrors.

@Test
public void testBatchUpdateWithErrors() throws Exception {
    Greetings greetings = new GreetingsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
    final Map<Long, Greeting> inputs = new HashMap<>();
    inputs.put(-6L, getGreeting());
    CompletionStage<Long> createResult = greetings.create(getGreeting());
    CompletionStage<Map<Long, UpdateStatus>> result = createResult.thenCompose(id -> {
        inputs.put(id, getGreeting("Batch update test"));
        return greetings.batchUpdate(inputs);
    });
    CompletableFuture<Map<Long, UpdateStatus>> future = result.toCompletableFuture();
    Map<Long, UpdateStatus> ids = future.get(5000, TimeUnit.MILLISECONDS);
    Assert.assertEquals(ids.size(), 2);
    Assert.assertEquals(ids.get(createResult.toCompletableFuture().get()).getStatus().intValue(), 204);
    Assert.assertEquals(ids.get(-6L).getStatus().intValue(), 404);
}
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) UpdateStatus(com.linkedin.restli.common.UpdateStatus) HashMap(java.util.HashMap) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) Greetings(com.linkedin.restli.examples.greetings.client.Greetings) GreetingsFluentClient(com.linkedin.restli.examples.greetings.client.GreetingsFluentClient) Map(java.util.Map) HashMap(java.util.HashMap) StringMap(com.linkedin.data.template.StringMap) Test(org.testng.annotations.Test)

Aggregations

GreetingsFluentClient (com.linkedin.restli.examples.greetings.client.GreetingsFluentClient)26 Test (org.testng.annotations.Test)26 Greetings (com.linkedin.restli.examples.greetings.client.Greetings)25 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)16 CustomLong (com.linkedin.restli.examples.custom.types.CustomLong)15 CreateGreeting (com.linkedin.restli.examples.greetings.client.CreateGreeting)15 PartialUpdateGreeting (com.linkedin.restli.examples.greetings.client.PartialUpdateGreeting)15 HashMap (java.util.HashMap)12 Map (java.util.Map)12 List (java.util.List)11 RestLiResponseException (com.linkedin.restli.client.RestLiResponseException)10 ExecutionException (java.util.concurrent.ExecutionException)10 StringMap (com.linkedin.data.template.StringMap)9 CreateIdStatus (com.linkedin.restli.common.CreateIdStatus)9 ArrayList (java.util.ArrayList)9 BatchCollectionResponse (com.linkedin.restli.common.BatchCollectionResponse)8 CollectionResponse (com.linkedin.restli.common.CollectionResponse)8 EntityResponse (com.linkedin.restli.common.EntityResponse)8 IdEntityResponse (com.linkedin.restli.common.IdEntityResponse)8 UpdateStatus (com.linkedin.restli.common.UpdateStatus)7