use of com.linkedin.restli.examples.greetings.client.Greetings in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testCollectionActionWithReturn.
@Test
public void testCollectionActionWithReturn() throws Exception {
Greetings greetings = new GreetingsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
Assert.assertTrue(greetings.purge().toCompletableFuture().get(5000, TimeUnit.MILLISECONDS) == 100);
}
use of com.linkedin.restli.examples.greetings.client.Greetings in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testCreate.
@Test
public void testCreate() throws Exception {
Greetings greetings = new GreetingsFluentClient(_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.Greetings in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testCreateAndThenBatchDeleteWithFailures.
@Test
public void testCreateAndThenBatchDeleteWithFailures() throws Exception {
Greetings greetings = new GreetingsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
// Create entities first so we don't delete those used by other tests.
CompletionStage<List<CreateIdStatus<Long>>> createResult = greetings.batchCreate(Arrays.asList(getGreeting(), getGreeting()));
CompletionStage<Map<Long, UpdateStatus>> result = createResult.thenCompose(ids -> {
Set<Long> deleteIds = Sets.newHashSet(ids.stream().map(CreateIdStatus::getKey).collect(Collectors.toList()));
deleteIds.add(-1L);
return greetings.batchDelete(deleteIds);
});
CompletableFuture<Map<Long, UpdateStatus>> future = result.toCompletableFuture();
Map<Long, UpdateStatus> ids = future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertEquals(ids.size(), 3);
Assert.assertEquals(ids.remove(-1L).getStatus().intValue(), 404);
for (UpdateStatus status : ids.values()) {
Assert.assertEquals(status.getStatus().intValue(), 204);
}
}
use of com.linkedin.restli.examples.greetings.client.Greetings in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testCreateAndThenDelete.
@Test
public void testCreateAndThenDelete() throws Exception {
Greetings greetings = new GreetingsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
// Create entities first so we don't delete those used by other tests.
CompletionStage<Long> createResult = greetings.create(getGreeting());
CompletionStage<Void> result = createResult.thenCompose(greetings::delete);
CompletableFuture<Void> future = result.toCompletableFuture();
future.get(5000, TimeUnit.MILLISECONDS);
Assert.assertFalse(future.isCompletedExceptionally());
}
use of com.linkedin.restli.examples.greetings.client.Greetings in project rest.li by linkedin.
the class TestParseqBasedFluentClientApi method testCreateNullId.
@Test
public void testCreateNullId() throws Exception {
Greetings greetings = new GreetingsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
CompletionStage<Long> result = greetings.create(getGreeting(), params -> params.setIsNullId(true));
CompletableFuture<Long> future = result.toCompletableFuture();
Assert.assertNull(future.get(5000, TimeUnit.MILLISECONDS));
}
Aggregations