Skip to content

Instantly share code, notes, and snippets.

@madhu314
Created February 22, 2017 08:54
Show Gist options
  • Save madhu314/24566dde806d9de295fda44c5f85c11f to your computer and use it in GitHub Desktop.
Save madhu314/24566dde806d9de295fda44c5f85c11f to your computer and use it in GitHub Desktop.
@Test public void testChanges() throws Exception {
assertThat(fixture.sortedList().size()).isEqualTo(0);
addArticles();
assertThat(fixture.callbackRecorder().insertions().size()).isEqualTo(
fixture.shuffledArticles().size());
assertThat(fixture.callbackRecorder().deletions().size()).isEqualTo(0);
assertThat(fixture.callbackRecorder().moves().size()).isEqualTo(0);
assertThat(fixture.callbackRecorder().changes().size()).isEqualTo(0);
fixture.callbackRecorder().clear();
int index = Article.Utils.randomWithRange(0, fixture.sortedList().size() - 1);
Article article = fixture.sortedList().get(index);
Article contentChanged =
article.toBuilder().content(Article.Utils.shuffleString(article.content())).build();
fixture.sortedList().add(contentChanged);
Article changed = fixture.sortedList().get(index);
assertThat(changed.content()).isEqualTo(contentChanged.content());
assertThat(changed.content()).isNotEqualTo(article.content());
assertThat(fixture.callbackRecorder().insertions().size()).isEqualTo(0);
assertThat(fixture.callbackRecorder().deletions().size()).isEqualTo(0);
assertThat(fixture.callbackRecorder().moves().size()).isEqualTo(0);
assertThat(fixture.callbackRecorder().changes().size()).isEqualTo(1);
assertThat(fixture.callbackRecorder().changes().get(0).first).isEqualTo(index);
assertThat(fixture.callbackRecorder().changes().get(0).second).isEqualTo(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment