SelectionCalculator { public boolean canCalculateFor(Revision r, Progress p) { try { doGetSelectionFor(r, p); } catch (ContentIsUnavailableException e) { return false; } return true; } SelectionCalculator(IdeaGateway gw, List<Revision> rr, int fromLine, int toLine); boolean canCalculateFor(Revision r, Progress p); Block getSelectionFor(Revision r, Progress p);  }
@Test public void testCanNotCalculateIfThereWasUnavailableContent() { List<Revision> rr = createRevisions(cf("one"), bigContentFactory(), cf("two")); SelectionCalculator c = new SelectionCalculator(gw, rr, 0, 0); assertTrue(c.canCalculateFor(rr.get(0), new NullProgress())); assertFalse(c.canCalculateFor(rr.get(1), new NullProgress())); assertFalse(c.canCalculateFor(rr.get(2), new NullProgress())); }
@Test public void testProgressOnCanCalculate() { List<Revision> rr = createRevisions("one", "two"); SelectionCalculator c = new SelectionCalculator(gw, rr, 0, 0); Progress p = createMock(Progress.class); p.processed(50); p.processed(100); replay(p); c.canCalculateFor(rr.get(1), p); verify(p); }