use of org.xwiki.uiextension.internal.filter.SortByIdFilter in project xwiki-platform by xwiki.
the class UIExtensionScriptServiceTest method verifyExtensionsAreSortedAlphabeticallyById.
@Test
public void verifyExtensionsAreSortedAlphabeticallyById() throws Exception {
// The UIX are voluntarily added in a wrong order.
UIExtension uix3 = mock(UIExtension.class, "uix3");
when(uix3.getId()).thenReturn("id3");
when(uix3.getExtensionPointId()).thenReturn("epId");
epExtensions.add(uix3);
UIExtension uix1 = mock(UIExtension.class, "uix1");
when(uix1.getId()).thenReturn("id1");
when(uix1.getExtensionPointId()).thenReturn("epId");
epExtensions.add(uix1);
UIExtension uix2 = mock(UIExtension.class, "uix2");
when(uix2.getId()).thenReturn("id2");
when(uix2.getExtensionPointId()).thenReturn("epId");
epExtensions.add(uix2);
when(contextComponentManager.getInstance(UIExtensionManager.class, "epId")).thenThrow(new ComponentLookupException("No specific manager for extension point epId"));
when(uiExtensionManager.get("epId")).thenReturn(epExtensions);
when(contextComponentManager.getInstance(UIExtensionFilter.class, "sortById")).thenReturn(new SortByIdFilter());
HashMap<String, String> filters = new HashMap<String, String>();
filters.put("sortById", "");
UIExtensionScriptService service = (UIExtensionScriptService) componentManager.getComponentUnderTest();
List<UIExtension> extensions = service.getExtensions("epId", filters);
Assert.assertEquals("id1", extensions.get(0).getId());
Assert.assertEquals("id2", extensions.get(1).getId());
Assert.assertEquals("id3", extensions.get(2).getId());
}
Aggregations