source: class ListBranchesTest extends Handler<ListBranchesResult> {
  
    private ObjectId idA;
    private Project.NameKey name;
    private Repository realDb;
    private Repository mockDb;
    private ProjectControl.Factory pcf;
    private ProjectControl pc;
    private GitRepositoryManager grm;
    private List<RefControl> refMocks;
  
    @Test
    public void testHeadVisibleButBranchHidden() throws Exception {
  
target:     ObjectIdRef.Unpeeled bar =
          new ObjectIdRef.Unpeeled(LOOSE, R_HEADS + "bar", idA);
      ObjectIdRef.Unpeeled foo =
          new ObjectIdRef.Unpeeled(LOOSE, R_HEADS + "foo", idA);
  
      Map<String, Ref> u = new LinkedHashMap<String, Ref>();
      u.put(bar.getName(), bar);
      u.put(HEAD, new SymbolicRef(HEAD, bar));
      u.put(foo.getName(), foo);
  
      validate().andReturn(pc);
      expect(grm.openRepository(eq(name))).andReturn(mockDb);
      expect(mockDb.getAllRefs()).andReturn(u);
      assumeVisible(bar, true, targets(u));
      assumeVisible(bar, true, targets(u));
      assumeVisible(foo, false, targets(u));
      expect(pc.canAddRefs()).andReturn(true);
      mockDb.close();
      expectLastCall();
  
      doReplay();
      final ListBranchesResult r = new ListBranches(pcf, grm, name).call();
      doVerify();
      assertNotNull(r);
  
      assertEquals(2, r.getBranches().size());
  
      assertEquals(HEAD, r.getBranches().get(0).getShortName());
      assertFalse(r.getBranches().get(0).getCanDelete());
  
      assertEquals("bar", r.getBranches().get(1).getShortName());
      assertFalse(r.getBranches().get(1).getCanDelete());
    }
  
  }