YeomanPartPresenter extends BasePresenter implements YeomanPartView.ActionDelegate,
                                                                  BuildFinishedCallback { public void generate() { List<String> targets = new ArrayList<>(); for (Map.Entry<YeomanGeneratorType, List<String>> entry : namesByTypes.entrySet()) { YeomanGeneratorType type = entry.getKey(); List<String> names = entry.getValue(); for (String name : names) { targets.add("angular:".concat(type.getName().toLowerCase(Locale.ENGLISH))); targets.add(name); } } BuildOptions buildOptions = dtoFactory.createDto(BuildOptions.class).withTargets(targets).withBuilderName("yeoman"); builderAgent.build(buildOptions, "Using Yeoman generator...", "The Yeoman generator has finished", "Failed to use Yeoman generator", "yeoman", this); view.disableGenerateButton(); view.enableProgressOnGenerateButton(); } @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 testGenerate() { presenter.addItem(CONTROLLER1, CONTROLLER); presenter.addItem(CONTROLLER2, CONTROLLER); presenter.addItem(ROUTE1, ROUTE); verify(yeomanPartView, atLeast(1)).enableGenerateButton(); presenter.generate(); verify(builderAgent).build(buildOptionsArgumentCaptor.capture(), anyString(), anyString(), anyString(), eq("yeoman"), eq(presenter)); verify(buildOptions).withTargets(listArgumentCaptor.capture()); List<String> lst = listArgumentCaptor.getValue(); int i = 0; if ("angular:controller".equals(lst.get(0))) { assertEquals("angular:controller", lst.get(i++)); assertEquals(CONTROLLER1, lst.get(i++)); assertEquals("angular:controller", lst.get(i++)); assertEquals(CONTROLLER2, lst.get(i++)); assertEquals("angular:route", lst.get(i++)); assertEquals(ROUTE1, lst.get(i++)); } else if ("angular:route".equals(lst.get(0))){ assertEquals("angular:route", lst.get(i++)); assertEquals(ROUTE1, lst.get(i++)); assertEquals("angular:controller", lst.get(i++)); assertEquals(CONTROLLER1, lst.get(i++)); assertEquals("angular:controller", lst.get(i++)); assertEquals(CONTROLLER2, lst.get(i++)); } else { fail("List should contain either angular:controller or angular:route"); } }