assertThat(exceptionSpy.get()).isNull();
}
@Test
public void should_batch_with_custom_consistency_level_async() throws Exception {
Tweet tweet1 = TweetTestBuilder.tweet().randomId().content("simple_tweet1").buid();
Tweet tweet2 = TweetTestBuilder.tweet().randomId().content("simple_tweet2").buid();
Tweet tweet3 = TweetTestBuilder.tweet().randomId().content("simple_tweet3").buid();
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<Object> successSpy = new AtomicReference<>();
FutureCallback<Object> successCallBack = new FutureCallback<Object>() {
@Override
public void onSuccess(Object result) {
successSpy.getAndSet(result);
latch.countDown();
}
@Override
public void onFailure(Throwable t) {
latch.countDown();
}
};
manager.insert(tweet1).getImmediately();
// Start batch
AsyncBatch batch = manager.createBatch();
batch.startBatch(QUORUM);
logAsserter.prepareLogLevel();
Tweet foundTweet1 = manager.find(Tweet.class, tweet1.getId()).getImmediately();
assertThat(foundTweet1.getContent()).isEqualTo(tweet1.getContent());
batch.insert(tweet2);
batch.insert(tweet3);
batch.endBatch(successCallBack);