ConvertingItemNavigator implements ItemNavigator<T_EXTERNAL> { @Override public T_EXTERNAL getCurrentItem() { if (currentItem == null) { T_INTERNAL internalItem = queryNavigator.getCurrentItem(); if (internalItem != null) { currentItem = converter.toNavigatorItemType(internalItem); } } return currentItem; } ConvertingItemNavigator(ItemNavigator<T_INTERNAL> queryNavigator, Converter<T_EXTERNAL, T_INTERNAL> converter); @Override T_EXTERNAL navigateTo(int itemPos); @Override T_EXTERNAL getCurrentItem(); @Override int getNumOfItems(); @Override int getCurrentItemIdx(); @Override void clearCaches();  }
@Test public void testGetCurrentItem() { assertEquals("1", convertingNavigator.getCurrentItem()); assertEquals(Integer.valueOf(1), intNavigator.getCurrentItem()); assertEquals(1, toNavigatorItemTypeCallCount); }
@Test public void testGetCurrentItemCalledTwiceCallsConverterMethodOnlyOnce() { assertEquals("1", convertingNavigator.getCurrentItem()); assertEquals("1", convertingNavigator.getCurrentItem()); assertEquals(1, toNavigatorItemTypeCallCount); }