### Question:
NavigationImpl implements Navigation { @Override public List<NavigationItem> getItems() { if (items == null) { items = new ArrayList<>(); PageManager pageManager = currentPage.getPageManager(); for (com.adobe.cq.wcm.core.components.models.NavigationItem wcmItem : wcmNavigation.getItems()) { addItems(pageManager, null, wcmItem, this.items); } } return items; }  @Override List<NavigationItem> getItems(); @Override String getId(); @Override String getParentId();  }### Answer:
@Test public void testNavigationPagesOnly() { String pageTitle = "Page 1"; String pageURL = "/page1"; boolean active = true; NavigationItem item = mock(NavigationItem.class); when(item.getTitle()).thenReturn(pageTitle); when(item.getURL()).thenReturn(pageURL); when(item.isActive()).thenReturn(active); navigationItems.add(item); List<com.adobe.cq.commerce.core.components.models.navigation.NavigationItem> items = navigation.getItems(); Assert.assertEquals(1, items.size()); com.adobe.cq.commerce.core.components.models.navigation.NavigationItem navigationItem = items.get(0); Assert.assertEquals(pageTitle, navigationItem.getTitle()); Assert.assertEquals(pageURL, navigationItem.getURL()); Assert.assertEquals(active, navigationItem.isActive()); Navigation activeNavigation = navigationModel.getActiveNavigation(); Assert.assertEquals(navigation, activeNavigation); List<Navigation> navigationList = navigationModel.getNavigationList(); Assert.assertEquals(1, navigationList.size()); Assert.assertEquals(navigation, navigationList.get(0)); }
@Test public void testNavigationPagesHierarchy() { String pageTitle = "Page 1"; String pageURL = "/page1"; boolean active = true; NavigationItem item = mock(NavigationItem.class); when(item.getTitle()).thenReturn(pageTitle); when(item.getURL()).thenReturn(pageURL); when(item.isActive()).thenReturn(active); navigationItems.add(item); String childPageTitle = "Page 1 1"; String childPageURL = "/page1/page11"; boolean childActive = true; NavigationItem childItem = mock(NavigationItem.class); when(childItem.getTitle()).thenReturn(childPageTitle); when(childItem.getURL()).thenReturn(childPageURL); when(childItem.isActive()).thenReturn(childActive); List<NavigationItem> children = new ArrayList<>(); children.add(childItem); when(item.getChildren()).thenReturn(children); List<com.adobe.cq.commerce.core.components.models.navigation.NavigationItem> items = navigation.getItems(); Assert.assertEquals(1, items.size()); com.adobe.cq.commerce.core.components.models.navigation.NavigationItem navigationItem = items.get(0); Assert.assertEquals(pageTitle, navigationItem.getTitle()); Assert.assertEquals(pageURL, navigationItem.getURL()); Assert.assertEquals(active, navigationItem.isActive()); Navigation activeNavigation = navigationModel.getActiveNavigation(); Assert.assertEquals(navigation, activeNavigation); List<Navigation> navigationList = navigationModel.getNavigationList(); Assert.assertEquals(2, navigationList.size()); Assert.assertEquals(navigation, navigationList.get(0)); }