Skip to content

Instantly share code, notes, and snippets.

@madhu314
Created February 22, 2017 08:59
Show Gist options
  • Save madhu314/f4eba202e2ce0d71df7e79fe41fc58f7 to your computer and use it in GitHub Desktop.
Save madhu314/f4eba202e2ce0d71df7e79fe41fc58f7 to your computer and use it in GitHub Desktop.
@Test public void testBatchedCallbacks() throws Exception {
SortedList<Article> articleSortedList = new SortedList<>(Article.class,
new SortedList.BatchedCallback<>(fixture.callbackRecorder()));
articleSortedList.beginBatchedUpdates();
for (int i = 0; i < fixture.shuffledArticles().size(); i++) {
Article articleToAdd = fixture.shuffledArticles().get(i).dupe();
articleSortedList.add(articleToAdd);
assertThat(fixture.callbackRecorder().insertions().size()).isEqualTo(0);
}
articleSortedList.endBatchedUpdates();
assertThat(fixture.callbackRecorder().insertions().size()).isEqualTo(1);
assertThat(fixture.callbackRecorder().insertions().get(0).first).isEqualTo(0);
assertThat(fixture.callbackRecorder().insertions().get(0).second).isEqualTo(
fixture.shuffledArticles().size());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment