@Test @ConditionalRun(RepositoryInstalled.MercurialInstalled.class) public void testGetContext_3args() throws Exception { String path = "/mercurial/Makefile"; String filename = repositories.getSourceRoot() + path; TermQuery q1 = new TermQuery(new Term("hist", "dummy")); ArrayList<Hit> hits = new ArrayList<>(); boolean gotCtx = new HistoryContext(q1).getContext(filename, path, hits); assertTrue(gotCtx); assertEquals(1, hits.size()); assertTrue(hits.get(0).getLine().contains( "Created a small <b>dummy</b> program")); PhraseQuery.Builder q2 = new PhraseQuery.Builder(); q2.add(new Term("hist", "dummy")); q2.add(new Term("hist", "program")); hits.clear(); gotCtx = new HistoryContext(q2.build()).getContext(filename, path, hits); assertTrue(gotCtx); assertEquals(1, hits.size()); assertTrue(hits.get(0).getLine().contains( "Created a small <b>dummy program</b>")); TermQuery q3 = new TermQuery(new Term("hist", "term_does_not_exist")); hits.clear(); gotCtx = new HistoryContext(q3).getContext(filename, path, hits); assertFalse(gotCtx); assertEquals(0, hits.size()); BooleanQuery.Builder q4 = new BooleanQuery.Builder(); q4.add(new TermQuery(new Term("hist", "small")), Occur.SHOULD); q4.add(new TermQuery(new Term("hist", "target")), Occur.SHOULD); hits.clear(); gotCtx = new HistoryContext(q4.build()).getContext(filename, path, hits); assertTrue(gotCtx); assertEquals(2, hits.size()); assertTrue(hits.get(0).getLine().contains( "Add lint make <b>target</b> and fix lint warnings")); assertTrue(hits.get(1).getLine().contains( "Created a <b>small</b> dummy program")); }
public boolean getContext(String filename, String path, List<Hit> hits) throws HistoryException { if (m == null) { return false; } File f = new File(filename); return getHistoryContext(HistoryGuru.getInstance().getHistory(f), path, null, hits, null); }
HistoryContext { public boolean getContext(String filename, String path, List<Hit> hits) throws HistoryException { if (m == null) { return false; } File f = new File(filename); return getHistoryContext(HistoryGuru.getInstance().getHistory(f), path, null, hits, null); } }
HistoryContext { public boolean getContext(String filename, String path, List<Hit> hits) throws HistoryException { if (m == null) { return false; } File f = new File(filename); return getHistoryContext(HistoryGuru.getInstance().getHistory(f), path, null, hits, null); } HistoryContext(Query query); }
HistoryContext { public boolean getContext(String filename, String path, List<Hit> hits) throws HistoryException { if (m == null) { return false; } File f = new File(filename); return getHistoryContext(HistoryGuru.getInstance().getHistory(f), path, null, hits, null); } HistoryContext(Query query); boolean isEmpty(); boolean getContext(String filename, String path, List<Hit> hits); boolean getContext(String parent, String basename, String path, Writer out, String context); boolean getContext(File src, String path, Writer out, String context); }
HistoryContext { public boolean getContext(String filename, String path, List<Hit> hits) throws HistoryException { if (m == null) { return false; } File f = new File(filename); return getHistoryContext(HistoryGuru.getInstance().getHistory(f), path, null, hits, null); } HistoryContext(Query query); boolean isEmpty(); boolean getContext(String filename, String path, List<Hit> hits); boolean getContext(String parent, String basename, String path, Writer out, String context); boolean getContext(File src, String path, Writer out, String context);  }