TemplatesViewImpl extends Composite implements TemplatesView { @Override public void addEnvironment(@NotNull Map<Scope, List<Environment>> environments) { clearEnvironmentsPanel(); int i = 0; for (Environment environment : environments.get(PROJECT)) { addEnvironment(environment, PROJECT, i++); } List<Environment> systemEnvironments = environments.get(SYSTEM); for (Environment environment : systemEnvironments) { addEnvironment(environment, SYSTEM, i++); } } @Inject  TemplatesViewImpl(RunnerResources resources,
                             RunnerLocalizationConstant locale,
                             WidgetFactory widgetFactory,
                             DefaultRunnerInfo defaultRunnerInfo,
                             PopupPanel popupPanel); @Override void addEnvironment(@NotNull Map<Scope, List<Environment>> environments); @Override void selectEnvironment(@Nullable Environment selectedEnvironment); @Override void setFilterWidget(@NotNull FilterWidget filterWidget); @Override void setDefaultProjectWidget(@Nullable EnvironmentWidget widget); @Override void scrollTop(int index); @Override void showDefaultEnvironmentInfo(@NotNull Environment defaultEnvironment); @Override void clearEnvironmentsPanel(); @Override void setDelegate(@NotNull ActionDelegate delegate);  }
@Test public void environmentsShouldBeAdded() throws Exception { view.addEnvironment(environmentMap); verify(view.environmentsPanel).clear(); verify(widget, times(2)).setScope(PROJECT); verify(widget, times(2)).setScope(SYSTEM); verify(widget).update(projectEnvironment1); verify(widget).update(projectEnvironment2); verify(widget).update(systemEnvironment1); verify(widget).update(systemEnvironment2); verify(widgetFactory, times(4)).createEnvironment(); verify(view.environmentsPanel, times(4)).add(widget); }
@Test public void widgetsShouldBeGotFromCache() throws Exception { view.addEnvironment(environmentMap); view.addEnvironment(environmentMap); verify(widget, times(4)).unSelect(); verify(widgetFactory, times(4)).createEnvironment(); verify(view.environmentsPanel, times(8)).add(widget); }