|
30 | 30 | import java.nio.file.Files; |
31 | 31 | import java.nio.file.Path; |
32 | 32 | import java.nio.file.Paths; |
| 33 | +import java.time.Duration; |
33 | 34 | import java.util.ArrayList; |
34 | 35 | import java.util.Arrays; |
| 36 | +import java.util.Collections; |
35 | 37 | import java.util.List; |
36 | 38 | import java.util.Map; |
37 | 39 | import java.util.Objects; |
| 40 | +import java.util.TreeMap; |
38 | 41 | import java.util.stream.Collectors; |
39 | 42 | import java.util.stream.Stream; |
40 | 43 |
|
|
56 | 59 | import org.opengrok.indexer.authorization.AuthorizationPlugin; |
57 | 60 | import org.opengrok.indexer.authorization.TestPlugin; |
58 | 61 | import org.opengrok.indexer.condition.EnabledForRepository; |
| 62 | +import org.opengrok.indexer.configuration.Group; |
59 | 63 | import org.opengrok.indexer.configuration.IndexTimestamp; |
60 | 64 | import org.opengrok.indexer.configuration.Project; |
61 | 65 | import org.opengrok.indexer.configuration.RuntimeEnvironment; |
|
69 | 73 | import org.opengrok.indexer.web.DummyHttpServletRequest; |
70 | 74 | import org.opengrok.indexer.web.QueryParameters; |
71 | 75 | import org.opengrok.indexer.web.SortOrder; |
| 76 | +import org.opengrok.indexer.web.messages.Message; |
72 | 77 |
|
73 | 78 | import static org.junit.jupiter.api.Assertions.assertAll; |
74 | 79 | import static org.junit.jupiter.api.Assertions.assertEquals; |
@@ -744,8 +749,26 @@ public String getPathInfo() { |
744 | 749 |
|
745 | 750 | @Test |
746 | 751 | void testIsNotModifiedNotModified() { |
| 752 | + RuntimeEnvironment env = RuntimeEnvironment.getInstance(); |
| 753 | + env.setProjectsEnabled(true); |
| 754 | + Map<String, Group> groups = new TreeMap<>(); |
| 755 | + Map<String, Project> projects = new TreeMap<>(); |
| 756 | + final String groupName = "test-group"; |
| 757 | + final String projectName = "test-project"; |
| 758 | + |
| 759 | + // Add message for a project in a group to increase coverage of getEtag(). |
| 760 | + groups.put(groupName, new Group(groupName, projectName)); |
| 761 | + projects.put(projectName, new Project(projectName, "/mercurial")); |
| 762 | + env.setGroups(groups); |
| 763 | + env.setProjects(projects); |
| 764 | + env.addMessage(new Message("test", |
| 765 | + Collections.singleton(projectName), |
| 766 | + Message.MessageLevel.INFO, |
| 767 | + Duration.ofMinutes(100))); |
| 768 | + assertEquals(1, env.getMessages(projectName).size()); |
| 769 | + |
747 | 770 | DummyHttpServletRequest req = mock(DummyHttpServletRequest.class); |
748 | | - when(req.getPathInfo()).thenReturn("/"); |
| 771 | + when(req.getPathInfo()).thenReturn("/mercurial/main.c"); |
749 | 772 | PageConfig cfg = PageConfig.get(req); |
750 | 773 | final String etag = cfg.getEtag(); |
751 | 774 | when(req.getHeader(HttpHeaders.IF_NONE_MATCH)).thenReturn(etag); |
|
0 commit comments