TabsImpl extends PanelContainerImpl implements Tabs { @Override public String getActiveItem() { if (activeItemName == null) { this.activeItemName = Optional.ofNullable(this.activeItem) .map(resource::getChild) .map(Resource::getName) .orElseGet(() -> Optional.ofNullable(request.getResourceResolver().adaptTo(ComponentManager.class)) .flatMap(componentManager -> StreamSupport.stream(resource.getChildren().spliterator(), false) .filter(Objects::nonNull) .filter(res -> Objects.nonNull(componentManager.getComponentOfResource(res))) .findFirst() .map(Resource::getName)) .orElse(null)); } return activeItemName; }  @Override String getActiveItem(); @Override @Nullable String getAccessibilityLabel(); @Override String[] getDataLayerShownItems(); final static String RESOURCE_TYPE; }
@Test void testTabsWithItems() { Tabs tabs = getTabsUnderTest(TABS_1); Object[][] expectedItems = { {"item_1", "Tab 1"}, {"item_2", "Tab Panel 2"}, }; verifyTabItems(expectedItems, tabs.getItems()); assertEquals("item_2", tabs.getActiveItem()); Utils.testJSONExport(tabs, Utils.getTestExporterJSONPath(TEST_BASE, "tabs1")); }
@Test void testTabsDefaultActiveItem() { Tabs tabs = getTabsUnderTest(TABS_3); Object[][] expectedItems = { {"item_1", "Tab 1"}, {"item_2", "Tab Panel 2"}, }; verifyTabItems(expectedItems, tabs.getItems()); assertEquals("item_1", tabs.getActiveItem()); Utils.testJSONExport(tabs, Utils.getTestExporterJSONPath(TEST_BASE, "tabs3")); }