@Test
public void testSortByName() throws Exception {

  Map<String, Ref> u = new LinkedHashMap<String, Ref>();
  u.put("foo", new ObjectIdRef.Unpeeled(LOOSE, R_HEADS + "foo", idA));
  u.put("bar", new ObjectIdRef.Unpeeled(LOOSE, R_HEADS + "bar", idA));
  u.put(HEAD, new SymbolicRef(HEAD, new ObjectIdRef.Unpeeled(LOOSE, R_HEADS
      + "master", null)));
  validate().andReturn(pc);
  expect(grm.openRepository(eq(name))).andReturn(mockDb);
  expect(mockDb.getAllRefs()).andReturn(u);
  for (Ref ref : u.values()) {
    assumeVisible(ref, true, targets(u));
  }
  expect(pc.canAddRefs()).andReturn(true);
  mockDb.close();
  expectLastCall();
  doReplay();
  final ListBranchesResult r = new ListBranches(pcf, grm, name).call();
  doVerify();
  assertNotNull(r);
  assertEquals(3, r.getBranches().size());
  assertEquals(HEAD, r.getBranches().get(0).getShortName());
  assertEquals("bar", r.getBranches().get(1).getShortName());
  assertEquals("foo", r.getBranches().get(2).getShortName());
}