diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java index b3e8076a5ef..97ce06e4e86 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java @@ -136,7 +136,7 @@ public final class Configuration { private boolean authorizationWatchdogEnabled; private AuthorizationStack pluginStack; private Map projects; // project name -> Project - private Map groups; // project name -> Group + private Map groups; // group name -> Group private String sourceRoot; private String dataRoot; /** diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java index 941eee11f87..707a714cd25 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java @@ -18,7 +18,7 @@ */ /* - * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. * Portions Copyright (c) 2017, 2020, Chris Fraire . */ package org.opengrok.indexer.configuration; @@ -2062,7 +2062,7 @@ public SortedSet getMessages(final String tag) { /** * Add a message to the application. - * Also schedules a expiration timer to remove this message after its expiration. + * Also schedules an expiration timer to remove this message after its expiration. * * @param message the message */ diff --git a/opengrok-web/src/test/java/org/opengrok/web/PageConfigTest.java b/opengrok-web/src/test/java/org/opengrok/web/PageConfigTest.java index db7ba46bd7f..d8353dee60b 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/PageConfigTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/PageConfigTest.java @@ -30,11 +30,14 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.TreeMap; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -56,6 +59,7 @@ import org.opengrok.indexer.authorization.AuthorizationPlugin; import org.opengrok.indexer.authorization.TestPlugin; import org.opengrok.indexer.condition.EnabledForRepository; +import org.opengrok.indexer.configuration.Group; import org.opengrok.indexer.configuration.IndexTimestamp; import org.opengrok.indexer.configuration.Project; import org.opengrok.indexer.configuration.RuntimeEnvironment; @@ -69,6 +73,7 @@ import org.opengrok.indexer.web.DummyHttpServletRequest; import org.opengrok.indexer.web.QueryParameters; import org.opengrok.indexer.web.SortOrder; +import org.opengrok.indexer.web.messages.Message; import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -744,8 +749,26 @@ public String getPathInfo() { @Test void testIsNotModifiedNotModified() { + RuntimeEnvironment env = RuntimeEnvironment.getInstance(); + env.setProjectsEnabled(true); + Map groups = new TreeMap<>(); + Map projects = new TreeMap<>(); + final String groupName = "test-group"; + final String projectName = "test-project"; + + // Add message for a project in a group to increase coverage of getEtag(). + groups.put(groupName, new Group(groupName, projectName)); + projects.put(projectName, new Project(projectName, "/mercurial")); + env.setGroups(groups); + env.setProjects(projects); + env.addMessage(new Message("test", + Collections.singleton(projectName), + Message.MessageLevel.INFO, + Duration.ofMinutes(100))); + assertEquals(1, env.getMessages(projectName).size()); + DummyHttpServletRequest req = mock(DummyHttpServletRequest.class); - when(req.getPathInfo()).thenReturn("/"); + when(req.getPathInfo()).thenReturn("/mercurial/main.c"); PageConfig cfg = PageConfig.get(req); final String etag = cfg.getEtag(); when(req.getHeader(HttpHeaders.IF_NONE_MATCH)).thenReturn(etag);