Unverified Commit 7bbe85a3 authored by Steve Ikeoka's avatar Steve Ikeoka Committed by GitHub
Browse files

Merge pull request #3364 from sikeoka/GEOS-9121_2.15.x

[GEOS-9121][2.15.x] Added a fixed sort order to the module status table.
parents 78a387eb 55b3a3e4
......@@ -4,8 +4,8 @@
*/
package org.geoserver.web.admin;
import java.util.Comparator;
import java.util.List;
import java.util.ListIterator;
import java.util.stream.Collectors;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
......@@ -51,19 +51,14 @@ public class ModuleStatusPanel extends Panel {
add(popup);
// get the list of ModuleStatuses
GeoServerExtensions gse = new GeoServerExtensions();
List<ModuleStatus> applicationStatus =
gse.extensions(ModuleStatus.class)
GeoServerExtensions.extensions(ModuleStatus.class)
.stream()
.filter(status -> !status.getModule().matches("\\A[system-](.*)"))
.map(ModuleStatusImpl::new)
.sorted(Comparator.comparing(ModuleStatus::getModule))
.collect(Collectors.toList());
ListIterator<ModuleStatus> iter = applicationStatus.listIterator();
while (iter.hasNext()) {
if (iter.next().getModule().toString().matches("\\A[system-](.*)")) {
iter.remove();
}
}
final ListView<ModuleStatus> moduleView =
new ListView<ModuleStatus>("modules", applicationStatus) {
private static final long serialVersionUID = 235576083712961710L;
......
......@@ -5,16 +5,23 @@
*/
package org.geoserver.web.admin;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.junit.Assert.*;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.wicket.Component;
import org.apache.wicket.Page;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.geoserver.data.test.SystemTestData;
import org.geoserver.platform.ModuleStatus;
import org.geoserver.platform.ModuleStatusImpl;
import org.geoserver.web.GeoServerWicketTestSupport;
import org.junit.Assume;
......@@ -102,6 +109,35 @@ public class StatusPageTest extends GeoServerWicketTestSupport {
tester.assertContains("gs-main");
}
@SuppressWarnings("unchecked")
@Test
public void testModuleStatusPanelOrder() {
tester.assertRenderedPage(StatusPage.class);
tester.clickLink("tabs:tabs-container:tabs:1:link", true);
tester.assertContains("gs-main");
Component component =
tester.getComponentFromLastRenderedPage("tabs:panel:listViewContainer:modules");
assertThat(component, instanceOf(ListView.class));
List<String> modules =
((ListView<ModuleStatus>) component)
.getList()
.stream()
.map(ModuleStatus::getModule)
.collect(Collectors.toList());
// verify that the expected modules are present
assertThat(modules, hasItem("gs-main"));
assertThat(modules, hasItem("gs-web-core"));
assertThat(modules, hasItem("jvm"));
// verify that the system modules are filtered
assertThat(modules, not(hasItem(startsWith("system-"))));
// verify that the modules are sorted
List<String> sorted = modules.stream().sorted().collect(Collectors.toList());
assertEquals(sorted, modules);
}
@Test
public void testModuleStatusPanelVersion() {
// Skip this test if we are excecuting from an IDE; the version is extracted from the
......@@ -117,7 +153,7 @@ public class StatusPageTest extends GeoServerWicketTestSupport {
tester.assertContains("gs-main");
Component component =
tester.getComponentFromLastRenderedPage(
"tabs:panel:listViewContainer:modules:1:version");
"tabs:panel:listViewContainer:modules:0:version");
assertTrue(component instanceof Label);
assertNotNull(component.getDefaultModelObjectAsString());
assertNotEquals("", component.getDefaultModelObjectAsString().trim());
......@@ -127,7 +163,7 @@ public class StatusPageTest extends GeoServerWicketTestSupport {
public void testModuleStatusPopup() {
tester.assertRenderedPage(StatusPage.class);
tester.clickLink("tabs:tabs-container:tabs:1:link", true);
tester.clickLink("tabs:panel:listViewContainer:modules:1:msg", true);
tester.clickLink("tabs:panel:listViewContainer:modules:0:msg", true);
tester.assertRenderedPage(StatusPage.class);
tester.assertContains("GeoServer Main");
tester.assertContains("gs-main");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment