Search in sources :

Example 1 with Annotation

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);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Annotation(org.opensolaris.opengrok.history.Annotation) ConditionalRun(org.opensolaris.opengrok.condition.ConditionalRun) Test(org.junit.Test)

Aggregations

HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Test (org.junit.Test)1 ConditionalRun (org.opensolaris.opengrok.condition.ConditionalRun)1 Annotation (org.opensolaris.opengrok.history.Annotation)1