YeomanPartPresenter extends BasePresenter implements YeomanPartView.ActionDelegate,
                                                                  BuildFinishedCallback { public void addItem(String generatedName, YeomanGeneratorType selectedType) { if (generatedName == null || "".equals(generatedName)) { return; } if (selectedType == null) { return; } List<String> generatedNames = namesByTypes.get(selectedType); if (generatedNames == null) { FoldingPanel foldingPanel = foldingPanelFactory.create(selectedType.getLabelName()); widgetByTypes.put(selectedType, foldingPanel); view.addFoldingPanel(foldingPanel); generatedNames = new ArrayList<>(); namesByTypes.put(selectedType, generatedNames); } if (generatedNames.contains(generatedName)) { return; } generatedNames.add(generatedName); GeneratedItemView item = generatedItemViewFactory.create(generatedName, selectedType); item.setAnchor(view); widgetByTypes.get(selectedType).add(item); updateGenerateButton(); } @Inject  YeomanPartPresenter(YeomanPartView view, FoldingPanelFactory foldingPanelFactory,
                               GeneratedItemViewFactory generatedItemViewFactory, DtoFactory dtoFactory,
                               BuilderAgent builderAgent, ProjectExplorerPresenter projectExplorer); @Override String getTitle(); @Override ImageResource getTitleImage(); @Override String getTitleToolTip(); @Override void go(AcceptsOneWidget container); void addItem(String generatedName, YeomanGeneratorType selectedType); @Override void onFinished(BuildStatus buildStatus); void generate(); void removeItem(YeomanGeneratorType type, String name, GeneratedItemView itemView); Map<YeomanGeneratorType, FoldingPanel> getWidgetByTypes(); Map<YeomanGeneratorType, List<String>> getNamesByTypes();  }
@Test public void testAddItem() { assertTrue(presenter.getNamesByTypes().isEmpty()); assertTrue(presenter.getWidgetByTypes().isEmpty()); presenter.addItem(CONTROLLER1, CONTROLLER); verify(yeomanPartView).addFoldingPanel(foldingPanelController); assertEquals(1, presenter.getWidgetByTypes().size()); assertEquals(1, presenter.getNamesByTypes().size()); verify(foldingPanelController).add(itemController1); List<String> names = presenter.getNamesByTypes().get(CONTROLLER); assertNotNull(names); assertEquals(1, names.size()); assertEquals(CONTROLLER1, names.get(0)); FoldingPanel foundWidget = presenter.getWidgetByTypes().get(CONTROLLER); assertNotNull(foundWidget); assertEquals(foldingPanelController, foundWidget); assertEquals(CONTROLLER.getLabelName(), foundWidget.getName()); }
@Test public void testDisableByDefaultGenerateButton() { verify(yeomanPartView).disableGenerateButton(); verify(yeomanPartView, times(0)).enableGenerateButton(); presenter.addItem(CONTROLLER1, CONTROLLER); verify(yeomanPartView).enableGenerateButton(); }