use of com.linkedin.restli.examples.greetings.client.CreateGreetingFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testCreateReturnEntity.
@Test
public void testCreateReturnEntity() throws Exception {
CreateGreeting greetings = new CreateGreetingFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
String msg = Double.toString(Math.random());
CompletionStage<IdEntityResponse<Long, Greeting>> result = greetings.createAndGet(getGreeting(msg));
CompletableFuture<IdEntityResponse<Long, Greeting>> future = result.toCompletableFuture();
Assert.assertNotNull(future.get(5000, TimeUnit.MILLISECONDS));
Assert.assertEquals(msg, future.get().getEntity().getMessage());
}
use of com.linkedin.restli.examples.greetings.client.CreateGreetingFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testCreateReturnEntityDisabled.
@Test
public void testCreateReturnEntityDisabled() throws Exception {
CreateGreeting greetings = new CreateGreetingFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
CompletionStage<Long> result = greetings.create(getGreeting());
CompletableFuture<Long> future = result.toCompletableFuture();
Assert.assertNotNull(future.get(5000, TimeUnit.MILLISECONDS));
}
use of com.linkedin.restli.examples.greetings.client.CreateGreetingFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testBatchCreateReturnEntityDisabled.
@Test
public void testBatchCreateReturnEntityDisabled() throws Exception {
CreateGreeting greetings = new CreateGreetingFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
CompletionStage<List<CreateIdStatus<Long>>> result = greetings.batchCreate(Arrays.asList(getGreeting(), getGreeting()));
CompletableFuture<List<CreateIdStatus<Long>>> future = result.toCompletableFuture();
List<CreateIdStatus<Long>> ids = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertEquals(ids.size(), 2);
}
use of com.linkedin.restli.examples.greetings.client.CreateGreetingFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApiWithProjections method testCreateAndGetWithProjection.
@Test
public void testCreateAndGetWithProjection() throws Exception {
CreateGreeting greetings = new CreateGreetingFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
String msg = Double.toString(Math.random());
CompletionStage<IdEntityResponse<Long, Greeting>> result = greetings.createAndGet(getGreeting(msg), optionalParams -> optionalParams.withMask(mask -> mask.withMessage()));
CompletableFuture<IdEntityResponse<Long, Greeting>> future = result.toCompletableFuture();
Assert.assertNotNull(future.get(5000, TimeUnit.MILLISECONDS));
Assert.assertFalse(future.get().getEntity().hasId());
Assert.assertFalse(future.get().getEntity().hasTone());
Assert.assertEquals(msg, future.get().getEntity().getMessage());
}
use of com.linkedin.restli.examples.greetings.client.CreateGreetingFluentClient in project rest.li by linkedin.
the class TestParseqBasedFluentClientApiWithProjections method testBatchCreateAndGetWithProjection.
@Test
public void testBatchCreateAndGetWithProjection() 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)), optionalParams -> optionalParams.withMask(mask -> mask.withId()));
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.assertFalse(entities.get(0).getEntity().hasMessage());
Assert.assertTrue(entities.get(0).getEntity().hasId());
Assert.assertNotNull(entities.get(1).getEntity());
Assert.assertFalse(entities.get(1).getEntity().hasMessage());
Assert.assertTrue(entities.get(1).getEntity().hasId());
}
Aggregations