@Test @ConditionalRun(RepositoryInstalled.GitInstalled.class) public void testGetAnnotation() { final String[] revisions = {"aa35c258", "bb74b7e8"}; for (int i = 0; i < revisions.length; i++) { final int index = i; HttpServletRequest req = new DummyHttpServletRequest() { @Override public String getContextPath() { return "/source"; } @Override public String getServletPath() { return "/history"; } @Override public String getPathInfo() { return "/git/main.c"; } @Override public String getParameter(String name) { switch(name) { case "r": return revisions[index]; case "a": return "true"; } return null; } }; PageConfig cfg = PageConfig.get(req); Annotation annotation = cfg.getAnnotation(); assertNotNull(annotation); assertEquals("main.c", annotation.getFilename()); assertEquals(revisions.length - i, annotation.getFileVersionsCount()); for(int j = 1; j <= annotation.size(); j ++ ){ String tmp = annotation.getRevision(j); assertTrue(Arrays.asList(revisions).contains(tmp)); } assertEquals("The version should be reflected through the revision", revisions.length - i, annotation.getFileVersion(revisions[i])); PageConfig.cleanup(req); } }
public Annotation getAnnotation() { if (isDir() || getResourcePath().equals("/") || !annotate()) { return null; } if (annotation != null) { return annotation; } getRequestedRevision(); try { annotation = HistoryGuru.getInstance().annotate(resourceFile, rev.isEmpty() ? null : rev); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to get annotations: ", e); } return annotation; }
PageConfig { public Annotation getAnnotation() { if (isDir() || getResourcePath().equals("/") || !annotate()) { return null; } if (annotation != null) { return annotation; } getRequestedRevision(); try { annotation = HistoryGuru.getInstance().annotate(resourceFile, rev.isEmpty() ? null : rev); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to get annotations: ", e); } return annotation; } }
PageConfig { public Annotation getAnnotation() { if (isDir() || getResourcePath().equals("/") || !annotate()) { return null; } if (annotation != null) { return annotation; } getRequestedRevision(); try { annotation = HistoryGuru.getInstance().annotate(resourceFile, rev.isEmpty() ? null : rev); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to get annotations: ", e); } return annotation; } private  PageConfig(HttpServletRequest req); }
PageConfig { public Annotation getAnnotation() { if (isDir() || getResourcePath().equals("/") || !annotate()) { return null; } if (annotation != null) { return annotation; } getRequestedRevision(); try { annotation = HistoryGuru.getInstance().annotate(resourceFile, rev.isEmpty() ? null : rev); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to get annotations: ", e); } return annotation; } private  PageConfig(HttpServletRequest req); void setRequestAttribute(String attr, Object val); Object getRequestAttribute(String attr); void removeAttribute(String string); void addHeaderData(String data); String getHeaderData(); DiffData getDiffData(); DiffType getDiffType(); boolean fullDiff(); String canProcess(); List<String> getResourceFileList(); long getLastModified(); String getHistoryDirs(); int getIntParam(String name, int defaultValue); int getSearchStart(); int getSearchMaxItems(); int getRevisionMessageCollapseThreshold(); int getCurrentIndexedCollapseThreshold(); int getGroupsCollapseThreshold(); List<SortOrder> getSortOrder(); QueryBuilder getQueryBuilder(); EftarFileReader getEftarReader(); String getDefineTagsIndex(); String getRequestedRevision(); boolean hasHistory(); boolean hasAnnotations(); boolean annotate(); Annotation getAnnotation(); String[] getSearchOnlyIn(); Project getProject(); String getRequestedProjectsAsString(); SortedSet<String> getRequestedProjects(); List<String> getCookieVals(String cookieName); ProjectHelper getProjectHelper(); void setTitle(String title); String getTitle(); String getCssDir(); RuntimeEnvironment getEnv(); IgnoredNames getIgnoredNames(); String getSourceRootPath(); Prefix getPrefix(); String getPath(); File getResourceFile(String path); File getResourceFile(); String getResourcePath(); boolean resourceNotAvailable(); boolean isDir(); File[] findDataFiles(List<String> filenames); File findDataFile(); String getLatestRevision(); boolean isLatestRevision(String rev); String getRevisionLocation(String revStr); String getDirectoryRedirect(); String getUriEncodedPath(); PageConfig addScript(String name); Scripts getScripts(); File getDataRoot(); SearchHelper prepareSearch(); SearchHelper prepareInternalSearch(); static PageConfig get(HttpServletRequest request); static void cleanup(ServletRequest sr); boolean isAllowed(Project t); boolean isAllowed(Group g); SortedSet<AcceptedMessage> getMessages(); SortedSet<AcceptedMessage> getMessages(String tag); String getShortPath(String path); String getSearchTitle(); String getHistoryTitle(); String getPathTitle(); void checkSourceRootExistence(); boolean isNotModified(HttpServletRequest request, HttpServletResponse response); static String getRelativePath(String root, String path); boolean evaluateMatchOffset(); }
PageConfig { public Annotation getAnnotation() { if (isDir() || getResourcePath().equals("/") || !annotate()) { return null; } if (annotation != null) { return annotation; } getRequestedRevision(); try { annotation = HistoryGuru.getInstance().annotate(resourceFile, rev.isEmpty() ? null : rev); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to get annotations: ", e); } return annotation; } private  PageConfig(HttpServletRequest req); void setRequestAttribute(String attr, Object val); Object getRequestAttribute(String attr); void removeAttribute(String string); void addHeaderData(String data); String getHeaderData(); DiffData getDiffData(); DiffType getDiffType(); boolean fullDiff(); String canProcess(); List<String> getResourceFileList(); long getLastModified(); String getHistoryDirs(); int getIntParam(String name, int defaultValue); int getSearchStart(); int getSearchMaxItems(); int getRevisionMessageCollapseThreshold(); int getCurrentIndexedCollapseThreshold(); int getGroupsCollapseThreshold(); List<SortOrder> getSortOrder(); QueryBuilder getQueryBuilder(); EftarFileReader getEftarReader(); String getDefineTagsIndex(); String getRequestedRevision(); boolean hasHistory(); boolean hasAnnotations(); boolean annotate(); Annotation getAnnotation(); String[] getSearchOnlyIn(); Project getProject(); String getRequestedProjectsAsString(); SortedSet<String> getRequestedProjects(); List<String> getCookieVals(String cookieName); ProjectHelper getProjectHelper(); void setTitle(String title); String getTitle(); String getCssDir(); RuntimeEnvironment getEnv(); IgnoredNames getIgnoredNames(); String getSourceRootPath(); Prefix getPrefix(); String getPath(); File getResourceFile(String path); File getResourceFile(); String getResourcePath(); boolean resourceNotAvailable(); boolean isDir(); File[] findDataFiles(List<String> filenames); File findDataFile(); String getLatestRevision(); boolean isLatestRevision(String rev); String getRevisionLocation(String revStr); String getDirectoryRedirect(); String getUriEncodedPath(); PageConfig addScript(String name); Scripts getScripts(); File getDataRoot(); SearchHelper prepareSearch(); SearchHelper prepareInternalSearch(); static PageConfig get(HttpServletRequest request); static void cleanup(ServletRequest sr); boolean isAllowed(Project t); boolean isAllowed(Group g); SortedSet<AcceptedMessage> getMessages(); SortedSet<AcceptedMessage> getMessages(String tag); String getShortPath(String path); String getSearchTitle(); String getHistoryTitle(); String getPathTitle(); void checkSourceRootExistence(); boolean isNotModified(HttpServletRequest request, HttpServletResponse response); static String getRelativePath(String root, String path); boolean evaluateMatchOffset(); static final String OPEN_GROK_PROJECT; }