use of org.opensolaris.opengrok.history.Annotation in project OpenGrok by OpenGrok.
the class PageConfigTest method testGetAnnotation.
@Test
@ConditionalRun(condition = 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);
}
}
Aggregations