@Test
public void testCheckoutBranch() throws Exception {
insertAndAdd(points1);
final RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
final Ref branch1 = geogig.command(BranchCreateOp.class).setName("branch1").call();
insertAndAdd(points2);
final RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
final Ref branch2 = geogig.command(BranchCreateOp.class).setName("branch2").call();
insertAndAdd(lines1);
final RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for " + idL2).call();
final Ref branch3 = geogig.command(BranchCreateOp.class).setName("branch3").call();
CheckoutResult result;
result = geogig.command(CheckoutOp.class).setSource("branch1").call();
assertEquals(c1.getTreeId(), result.getNewTree());
assertTrue(geogig.command(RefParse.class).setName(Ref.HEAD).call().get() instanceof SymRef);
assertEquals(branch1.getName(), ((SymRef) geogig.command(RefParse.class).setName(Ref.HEAD)
.call().get()).getTarget());
result = geogig.command(CheckoutOp.class).setSource("branch2").call();
assertEquals(c2.getTreeId(), result.getNewTree());
assertTrue(geogig.command(RefParse.class).setName(Ref.HEAD).call().get() instanceof SymRef);
assertEquals(branch2.getName(), ((SymRef) geogig.command(RefParse.class).setName(Ref.HEAD)
.call().get()).getTarget());
result = geogig.command(CheckoutOp.class).setSource("branch3").call();
assertEquals(c3.getTreeId(), result.getNewTree());
assertTrue(geogig.command(RefParse.class).setName(Ref.HEAD).call().get() instanceof SymRef);
assertEquals(branch3.getName(), ((SymRef) geogig.command(RefParse.class).setName(Ref.HEAD)
.call().get()).getTarget());
}