DisplayerSubtypeSelector implements IsWidget { public void init(DisplayerType type, DisplayerSubType selectedSubType) { view.clear(); RendererLibrary rendererLibrary = rendererManager.getRendererForType(type); if (rendererLibrary != null) { List<DisplayerSubType> supportedSubTypes = rendererLibrary.getSupportedSubtypes(type); if (supportedSubTypes != null && !supportedSubTypes.isEmpty()) { for (int i = 0; i < supportedSubTypes.size(); i++) { DisplayerSubType subtype = supportedSubTypes.get(i); if (!type.getSubTypes().contains(subtype)) { throw new RuntimeException("Wrong subtype (" + subtype + ") indicated for type " + type + " by renderer library " + rendererLibrary.getUUID()); } boolean initiallySelected = selectedSubType != null ? subtype == selectedSubType : i == 0; view.show(type, subtype); if (initiallySelected) { view.select(subtype); } } } else { view.showDefault(type); } } } @Inject  DisplayerSubtypeSelector(View view,
                                    RendererManager rendererManager,
                                    Event<DisplayerSubtypeSelectedEvent> selectEvent); @Override Widget asWidget(); DisplayerSubType getSelectedSubtype(); void init(DisplayerType type, DisplayerSubType selectedSubType);  }
@Test public void testInitialization1() { presenter.init(BARCHART, BAR); verify(subtypeView).show(BARCHART, BAR); verify(subtypeView).show(BARCHART, BAR_STACKED); verify(subtypeView).select(BAR); }
@Test public void testInitialization2() { presenter.init(LINECHART, null); verify(subtypeView).show(LINECHART, LINE); verify(subtypeView).show(LINECHART, SMOOTH); verify(subtypeView).select(LINE); }
@Test public void testInitialization3() { presenter.init(BUBBLECHART, null); verify(subtypeView, never()).show(any(DisplayerType.class), any(DisplayerSubType.class)); verify(subtypeView).showDefault(BUBBLECHART); }