Search in sources :

Example 6 with PartialUpdateGreetingFluentClient

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

the class TestParseqBasedFluentClientApi method testBatchPartialUpdateWithErrors.

@Test
public void testBatchPartialUpdateWithErrors() throws Exception {
    PartialUpdateGreeting greetings = new PartialUpdateGreetingFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
    Map<Long, PatchRequest<Greeting>> inputs = new HashMap<>();
    Greeting original = getGreeting();
    String message = "Edited message: fluent api test partialUpdateAndGet";
    Greeting update = getGreeting(message);
    inputs.put(21L, PatchGenerator.diff(original, update));
    inputs.put(-2L, PatchGenerator.diff(original, update));
    CompletionStage<Map<Long, UpdateStatus>> result = greetings.batchPartialUpdate(inputs);
    CompletableFuture<Map<Long, UpdateStatus>> future = result.toCompletableFuture();
    Assert.assertNotNull(future.get(5000, TimeUnit.MILLISECONDS));
    Assert.assertEquals(future.get().get(21L).getStatus().intValue(), 200);
    Assert.assertEquals(future.get().get(-2L).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) HashMap(java.util.HashMap) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) PartialUpdateGreetingFluentClient(com.linkedin.restli.examples.greetings.client.PartialUpdateGreetingFluentClient) PatchRequest(com.linkedin.restli.common.PatchRequest) Map(java.util.Map) HashMap(java.util.HashMap) StringMap(com.linkedin.data.template.StringMap) PartialUpdateGreeting(com.linkedin.restli.examples.greetings.client.PartialUpdateGreeting) Test(org.testng.annotations.Test)

Example 7 with PartialUpdateGreetingFluentClient

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

the class TestParseqBasedFluentClientApiWithProjections method testBatchPartialUpdateAndGetWithProjection.

@Test
public void testBatchPartialUpdateAndGetWithProjection() throws Exception {
    PartialUpdateGreeting greetings = new PartialUpdateGreetingFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
    Map<Long, PatchRequest<Greeting>> inputs = new HashMap<>();
    Greeting original = getGreeting();
    String message = "Edited message: fluent api test partialUpdateAndGet";
    Greeting update = getGreeting(message);
    inputs.put(21L, PatchGenerator.diff(original, update));
    inputs.put(22L, PatchGenerator.diff(original, update));
    CompletionStage<Map<Long, UpdateEntityStatus<Greeting>>> result = greetings.batchPartialUpdateAndGet(inputs, optionalParams -> optionalParams.withMask(mask -> mask.withId().withMessage().withTone()));
    CompletableFuture<Map<Long, UpdateEntityStatus<Greeting>>> future = result.toCompletableFuture();
    Assert.assertNotNull(future.get(5000, TimeUnit.MILLISECONDS));
    Assert.assertEquals(future.get().get(21L).getEntity().getId().longValue(), 21L);
    Assert.assertEquals(future.get().get(21L).getEntity().getMessage(), message);
    Assert.assertEquals(future.get().get(22L).getEntity().getId().longValue(), 22L);
    Assert.assertEquals(future.get().get(22L).getEntity().getMessage(), message);
}
Also used : PagingMetadataProjections(com.linkedin.restli.examples.greetings.client.PagingMetadataProjections) Arrays(java.util.Arrays) RestLiValidationFilter(com.linkedin.restli.server.validation.RestLiValidationFilter) CollectionResponse(com.linkedin.restli.common.CollectionResponse) AutoValidationWithProjectionFluentClient(com.linkedin.restli.examples.greetings.client.AutoValidationWithProjectionFluentClient) Test(org.testng.annotations.Test) PatchGenerator(com.linkedin.restli.client.util.PatchGenerator) EntityResponse(com.linkedin.restli.common.EntityResponse) Map(java.util.Map) CreateIdEntityStatus(com.linkedin.restli.common.CreateIdEntityStatus) CreateIdStatus(com.linkedin.restli.common.CreateIdStatus) BatchfindersFluentClient(com.linkedin.restli.examples.greetings.client.BatchfindersFluentClient) ManualProjections(com.linkedin.restli.examples.greetings.client.ManualProjections) Greetings(com.linkedin.restli.examples.greetings.client.Greetings) BeforeClass(org.testng.annotations.BeforeClass) Set(java.util.Set) ParSeqRestliClientConfigBuilder(com.linkedin.restli.client.ParSeqRestliClientConfigBuilder) CollectionMetadata(com.linkedin.restli.common.CollectionMetadata) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) ParSeqRestliClientBuilder(com.linkedin.restli.client.ParSeqRestliClientBuilder) CreateGreeting(com.linkedin.restli.examples.greetings.client.CreateGreeting) AutoValidationWithProjection(com.linkedin.restli.examples.greetings.client.AutoValidationWithProjection) GreetingsFluentClient(com.linkedin.restli.examples.greetings.client.GreetingsFluentClient) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) com.linkedin.restli.examples.greetings.api.myRecord(com.linkedin.restli.examples.greetings.api.myRecord) PatchRequest(com.linkedin.restli.common.PatchRequest) Assert(org.testng.Assert) UpdateEntityStatus(com.linkedin.restli.common.UpdateEntityStatus) ManualProjectionsFluentClient(com.linkedin.restli.examples.greetings.client.ManualProjectionsFluentClient) RestLiResponseException(com.linkedin.restli.client.RestLiResponseException) Greeting(com.linkedin.restli.examples.greetings.api.Greeting) ParSeqUnitTestHelper(com.linkedin.parseq.ParSeqUnitTestHelper) Tone(com.linkedin.restli.examples.greetings.api.Tone) PartialUpdateGreetingFluentClient(com.linkedin.restli.examples.greetings.client.PartialUpdateGreetingFluentClient) IdEntityResponse(com.linkedin.restli.common.IdEntityResponse) AfterClass(org.testng.annotations.AfterClass) ValidationDemo(com.linkedin.restli.examples.greetings.api.ValidationDemo) BatchFinderCriteriaResult(com.linkedin.restli.common.BatchFinderCriteriaResult) PartialUpdateGreeting(com.linkedin.restli.examples.greetings.client.PartialUpdateGreeting) GreetingCriteria(com.linkedin.restli.examples.greetings.api.GreetingCriteria) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) CreateGreetingFluentClient(com.linkedin.restli.examples.greetings.client.CreateGreetingFluentClient) PagingMetadataProjectionsFluentClient(com.linkedin.restli.examples.greetings.client.PagingMetadataProjectionsFluentClient) ParSeqRestliClient(com.linkedin.restli.client.ParSeqRestliClient) BatchCollectionResponse(com.linkedin.restli.common.BatchCollectionResponse) com.linkedin.restli.examples.greetings.api.myItem(com.linkedin.restli.examples.greetings.api.myItem) Batchfinders(com.linkedin.restli.examples.greetings.client.Batchfinders) Sets(org.testng.collections.Sets) CreateGreeting(com.linkedin.restli.examples.greetings.client.CreateGreeting) Greeting(com.linkedin.restli.examples.greetings.api.Greeting) PartialUpdateGreeting(com.linkedin.restli.examples.greetings.client.PartialUpdateGreeting) HashMap(java.util.HashMap) PartialUpdateGreetingFluentClient(com.linkedin.restli.examples.greetings.client.PartialUpdateGreetingFluentClient) PatchRequest(com.linkedin.restli.common.PatchRequest) Map(java.util.Map) HashMap(java.util.HashMap) PartialUpdateGreeting(com.linkedin.restli.examples.greetings.client.PartialUpdateGreeting) Test(org.testng.annotations.Test)

Example 8 with PartialUpdateGreetingFluentClient

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

the class TestParseqBasedFluentClientApi method testBatchPartialUpdate.

@Test
public void testBatchPartialUpdate() throws Exception {
    PartialUpdateGreeting greetings = new PartialUpdateGreetingFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
    Map<Long, PatchRequest<Greeting>> inputs = new HashMap<>();
    Greeting original = getGreeting();
    String message = "Edited message: fluent api test partialUpdateAndGet";
    Greeting update = getGreeting(message);
    inputs.put(21L, PatchGenerator.diff(original, update));
    inputs.put(22L, PatchGenerator.diff(original, update));
    CompletionStage<Map<Long, UpdateStatus>> result = greetings.batchPartialUpdate(inputs);
    CompletableFuture<Map<Long, UpdateStatus>> future = result.toCompletableFuture();
    Assert.assertNotNull(future.get(5000, TimeUnit.MILLISECONDS));
    Assert.assertEquals(future.get().get(21L).getStatus().intValue(), 200);
    Assert.assertEquals(future.get().get(22L).getStatus().intValue(), 200);
}
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) HashMap(java.util.HashMap) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) PartialUpdateGreetingFluentClient(com.linkedin.restli.examples.greetings.client.PartialUpdateGreetingFluentClient) PatchRequest(com.linkedin.restli.common.PatchRequest) Map(java.util.Map) HashMap(java.util.HashMap) StringMap(com.linkedin.data.template.StringMap) PartialUpdateGreeting(com.linkedin.restli.examples.greetings.client.PartialUpdateGreeting) Test(org.testng.annotations.Test)

Aggregations

Greeting (com.linkedin.restli.examples.greetings.api.Greeting)8 CreateGreeting (com.linkedin.restli.examples.greetings.client.CreateGreeting)8 PartialUpdateGreeting (com.linkedin.restli.examples.greetings.client.PartialUpdateGreeting)8 PartialUpdateGreetingFluentClient (com.linkedin.restli.examples.greetings.client.PartialUpdateGreetingFluentClient)8 Test (org.testng.annotations.Test)8 PatchRequest (com.linkedin.restli.common.PatchRequest)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 StringMap (com.linkedin.data.template.StringMap)4 CustomLong (com.linkedin.restli.examples.custom.types.CustomLong)4 RestLiResponseException (com.linkedin.restli.client.RestLiResponseException)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 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