use of com.linkedin.restli.examples.greetings.client.PartialUpdateGreetingFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testPartialUpdateError.
@Test
public void testPartialUpdateError() throws Exception {
PartialUpdateGreeting greetings = new PartialUpdateGreetingFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
Greeting original = getGreeting();
String message = "Edited message: fluent api test partialUpdateAndGet";
Greeting update = getGreeting(message);
CompletionStage<Greeting> result = greetings.partialUpdateAndGet(-1L, PatchGenerator.diff(original, update));
CompletableFuture<Greeting> future = result.toCompletableFuture();
try {
future.get(5000, TimeUnit.MILLISECONDS);
Assert.fail("Expected failure");
} catch (ExecutionException e) {
Assert.assertEquals(((RestLiResponseException) e.getCause()).getStatus(), 404);
}
}
use of com.linkedin.restli.examples.greetings.client.PartialUpdateGreetingFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testBatchPartialUpdateAndGetWithErrors.
@Test
public void testBatchPartialUpdateAndGetWithErrors() 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, UpdateEntityStatus<Greeting>>> result = greetings.batchPartialUpdateAndGet(inputs);
CompletableFuture<Map<Long, UpdateEntityStatus<Greeting>>> future = result.toCompletableFuture();
Assert.assertNotNull(future.get(5000, TimeUnit.MILLISECONDS));
Assert.assertEquals(future.get().get(21L).getStatus().intValue(), 200);
Assert.assertEquals(future.get().get(21L).getEntity().getId().longValue(), 21L);
Assert.assertEquals(future.get().get(21L).getEntity().getMessage(), message);
Assert.assertEquals(future.get().get(-2L).getStatus().intValue(), 404);
Assert.assertFalse(future.get().get(-2L).hasEntity());
}
use of com.linkedin.restli.examples.greetings.client.PartialUpdateGreetingFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testBatchPartialUpdateAndGet.
@Test
public void testBatchPartialUpdateAndGet() 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);
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);
}
use of com.linkedin.restli.examples.greetings.client.PartialUpdateGreetingFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApiWithProjections method testPartialUpdateAndGetWithProjection.
@Test
public void testPartialUpdateAndGetWithProjection() throws Exception {
PartialUpdateGreeting greetings = new PartialUpdateGreetingFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
Greeting original = getGreeting();
String message = "Edited message: fluent api test partialUpdateAndGet";
Greeting update = getGreeting(message);
CompletionStage<Greeting> result = greetings.partialUpdateAndGet(21L, PatchGenerator.diff(original, update), optionalParams -> optionalParams.withMask(mask -> mask.withId()));
CompletableFuture<Greeting> future = result.toCompletableFuture();
Greeting greeting = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertFalse(greeting.hasMessage());
Assert.assertTrue(greeting.hasId());
}
use of com.linkedin.restli.examples.greetings.client.PartialUpdateGreetingFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testPartialUpdateAndGet.
@Test
public void testPartialUpdateAndGet() throws Exception {
PartialUpdateGreeting greetings = new PartialUpdateGreetingFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
Greeting original = getGreeting();
String message = "Edited message: fluent api test partialUpdateAndGet";
Greeting update = getGreeting(message);
CompletionStage<Greeting> result = greetings.partialUpdateAndGet(21L, PatchGenerator.diff(original, update));
CompletableFuture<Greeting> future = result.toCompletableFuture();
Assert.assertEquals(future.get(5000, TimeUnit.MILLISECONDS).getMessage(), message);
}
Aggregations