use of org.eclipse.jgit.transport.ReceiveCommand in project gerrit by GerritCodeReview.
the class RepoViewTest method getRefsOverwritesCachedValueWithCommand.
@Test
public void getRefsOverwritesCachedValueWithCommand() throws Exception {
ObjectId master1 = repo.exactRef(MASTER).getObjectId();
assertThat(view.getRef(MASTER)).hasValue(master1);
ObjectId master2 = tr.commit().create();
view.getCommands().add(new ReceiveCommand(master1, master2, MASTER));
assertThat(repo.exactRef(MASTER).getObjectId()).isEqualTo(master1);
assertThat(view.getRef(MASTER)).hasValue(master2);
assertThat(view.getRefs(R_HEADS)).containsExactly("master", master2);
view.getCommands().add(new ReceiveCommand(master2, ObjectId.zeroId(), MASTER));
assertThat(repo.exactRef(MASTER).getObjectId()).isEqualTo(master1);
assertThat(view.getRef(MASTER)).isEmpty();
assertThat(view.getRefs(R_HEADS)).isEmpty();
}
use of org.eclipse.jgit.transport.ReceiveCommand in project gerrit by GerritCodeReview.
the class RepoViewTest method getRefsReflectsCommands.
@Test
public void getRefsReflectsCommands() throws Exception {
ObjectId master1 = repo.exactRef(MASTER).getObjectId();
assertThat(view.getRefs(R_HEADS)).containsExactly("master", master1);
ObjectId master2 = tr.commit().create();
view.getCommands().add(new ReceiveCommand(master1, master2, MASTER));
assertThat(repo.exactRef(MASTER).getObjectId()).isEqualTo(master1);
assertThat(view.getRef(MASTER)).hasValue(master2);
assertThat(view.getRefs(R_HEADS)).containsExactly("master", master2);
view.getCommands().add(new ReceiveCommand(master2, ObjectId.zeroId(), MASTER));
assertThat(repo.exactRef(MASTER).getObjectId()).isEqualTo(master1);
assertThat(view.getRef(MASTER)).isEmpty();
assertThat(view.getRefs(R_HEADS)).isEmpty();
}
Aggregations