TemplatesPresenter implements TemplatesContainer, FilterWidget.ActionDelegate, TemplatesView.ActionDelegate { @Override public void createNewEnvironment() { createSimpleEnvironment(); } @Inject  TemplatesPresenter(TemplatesView view,
                              FilterWidget filter,
                              EnvironmentWidget defaultEnvWidget,
                              AppContext appContext,
                              GetProjectEnvironmentsAction projectEnvironmentsAction,
                              GetSystemEnvironmentsAction systemEnvironmentsAction,
                              GetEnvironmentsUtil environmentUtil,
                              PropertiesContainer propertiesContainer,
                              SelectionManager selectionManager,
                              AsyncCallbackBuilder<ItemReference> asyncCallbackBuilder,
                              RunnerManagerView runnerManagerView,
                              NotificationManager notificationManager,
                              RunnerUtil runnerUtil,
                              RunnerResources resources,
                              PanelState panelState,
                              ProjectServiceClient projectService,
                              AsyncCallbackBuilder<ProjectDescriptor> asyncDescriptorCallbackBuilder,
                              ChooseRunnerAction chooseRunnerAction); @Override void select(@Nullable Environment environment); @Override List<Environment> addEnvironments(@NotNull RunnerEnvironmentTree tree, @NotNull Scope scope); @NotNull List<Environment> getProjectEnvironments(); @Override void showEnvironments(); @Override void selectEnvironment(); @Override void onValueChanged(); @Override void changeEnableStateRunButton(); @Override void setDefaultEnvironment(@Nullable Environment environment); @Override void onDefaultRunnerMouseOver(); @Override void createNewEnvironment(); @Override void go(@NotNull AcceptsOneWidget container); @NotNull @Override IsWidget getView(); @Override void setVisible(boolean visible);  }
@Test public void environmentShouldBeCreated() throws Exception { presenter.createNewEnvironment(); verify(asyncCallbackBuilder).unmarshaller(ItemReference.class); verify(asyncCallbackBuilder).success(successCallbackArgumentCaptor.capture()); successCallbackArgumentCaptor.getValue().onSuccess(itemReference1); verify(projectService).createFolder(anyString(), eq(asyncRequestCallbackItemReference)); verify(descriptor, times(2)).getPath(); verify(asyncCallbackBuilder, times(2)).unmarshaller(ItemReference.class); verify(asyncCallbackBuilder, times(2)).success(successCallbackArgumentCaptor.capture()); successCallbackArgumentCaptor.getValue().onSuccess(itemReference1); verify(projectEnvironmentsAction).perform(); }
@Test public void notificationMessageShouldBeShowedIfParentFolderDoesNotCreate() throws Exception { presenter.createNewEnvironment(); verify(asyncCallbackBuilder).unmarshaller(ItemReference.class); verify(asyncCallbackBuilder).failure(failureCallbackArgumentCaptor.capture()); failureCallbackArgumentCaptor.getValue().onFailure(exception); verify(notificationManager).showError(SOME_TEXT); }
@Test public void environmentDoesNotCreatedIfDockerFileNotCrested() throws Exception { presenter.createNewEnvironment(); verify(asyncCallbackBuilder).unmarshaller(ItemReference.class); verify(asyncCallbackBuilder).success(successCallbackArgumentCaptor.capture()); successCallbackArgumentCaptor.getValue().onSuccess(itemReference1); verify(projectService).createFolder(anyString(), eq(asyncRequestCallbackItemReference)); verify(descriptor, times(2)).getPath(); verify(asyncCallbackBuilder, times(2)).unmarshaller(ItemReference.class); verify(asyncCallbackBuilder, times(2)).failure(failureCallbackArgumentCaptor.capture()); failureCallbackArgumentCaptor.getValue().onFailure(exception); verify(projectEnvironmentsAction, never()).perform(); }