use of com.linkedin.restli.examples.greetings.client.GreetingsFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testUpdateFailure.
@Test
public void testUpdateFailure() throws Exception {
Greetings greetings = new GreetingsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
CompletionStage<Void> result = greetings.update(-7L, getGreeting());
CompletableFuture<Void> 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.GreetingsFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testBatchGetRequest.
@Test
public void testBatchGetRequest() throws Exception {
Greetings greetings = new GreetingsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
Set<Long> ids = Sets.newHashSet(Arrays.asList(1L, 2L, 3L));
CompletionStage<Map<Long, EntityResponse<Greeting>>> result = greetings.batchGet(ids);
CompletableFuture<Map<Long, EntityResponse<Greeting>>> future = result.toCompletableFuture();
Map<Long, EntityResponse<Greeting>> resultMap = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertEquals(resultMap.size(), ids.size());
for (Long id : ids) {
EntityResponse<Greeting> g = resultMap.get(id);
Assert.assertNotNull(g);
Assert.assertTrue(g.hasEntry());
Assert.assertEquals(id, g.getEntity().getId());
}
}
use of com.linkedin.restli.examples.greetings.client.GreetingsFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testCollectionActionWithNoReturn.
@Test
public void testCollectionActionWithNoReturn() throws Exception {
Greetings greetings = new GreetingsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
CompletableFuture<Void> stage = greetings.anotherAction(param -> param.setBitfield(new BooleanArray()).setRequest(new TransferOwnershipRequest()).setSomeString("").setStringMap(new StringMap())).toCompletableFuture();
Assert.assertNull(stage.get(5000, TimeUnit.MILLISECONDS));
assert (!stage.isCompletedExceptionally());
}
use of com.linkedin.restli.examples.greetings.client.GreetingsFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testGetRequest.
@Test
public void testGetRequest() throws Exception {
Greetings greetings = new GreetingsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
CompletionStage<Greeting> result = greetings.get(1L);
CompletableFuture<Greeting> future = result.toCompletableFuture();
Greeting greeting = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertTrue(greeting.hasId());
Assert.assertEquals((Long) 1L, greeting.getId());
}
use of com.linkedin.restli.examples.greetings.client.GreetingsFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testGetRequestFailure.
@Test
public void testGetRequestFailure() throws Exception {
Greetings greetings = new GreetingsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
CompletionStage<Greeting> result = greetings.get(-1L);
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);
}
}
Aggregations