@Test public void testExecuteValidation() { final POM pom = mock(POM.class); doReturn(true).when(validationService).validate(eq(pom)); generalSettingsPresenter.executeValidation(s -> s.validate(pom), "Test message").then(valid -> { verify(validationService).validate(eq(pom)); Assert.assertEquals(valid, true); return promises.resolve(); }).catch_(e -> { Assert.fail("Promise should've been resolved!"); return promises.resolve(); }); }
<T> Promise<Boolean> executeValidation(final Caller<T> caller, final Function<T, Boolean> call, final String errorMessage) { return promises .promisify(caller, call) .then(valid -> valid ? promises.resolve(true) : promises.reject(errorMessage)); }
GeneralSettingsPresenter extends Section<ProjectScreenModel> { <T> Promise<Boolean> executeValidation(final Caller<T> caller, final Function<T, Boolean> call, final String errorMessage) { return promises .promisify(caller, call) .then(valid -> valid ? promises.resolve(true) : promises.reject(errorMessage)); } }
GeneralSettingsPresenter extends Section<ProjectScreenModel> { <T> Promise<Boolean> executeValidation(final Caller<T> caller, final Function<T, Boolean> call, final String errorMessage) { return promises .promisify(caller, call) .then(valid -> valid ? promises.resolve(true) : promises.reject(errorMessage)); } @Inject  GeneralSettingsPresenter(final View view,
                                    final Promises promises,
                                    final MenuItem<ProjectScreenModel> menuItem,
                                    final Caller<ValidationService> validationService,
                                    final Caller<WorkspaceProjectService> projectService,
                                    final Event<SettingsSectionChange<ProjectScreenModel>> settingsSectionChangeEvent,
                                    final GAVPreferences gavPreferences,
                                    final ProjectScopedResolutionStrategySupplier projectScopedResolutionStrategySupplier,
                                    final GitUrlsPresenter gitUrlsPresenter,
                                    final LibraryPlaces libraryPlaces); }
GeneralSettingsPresenter extends Section<ProjectScreenModel> { <T> Promise<Boolean> executeValidation(final Caller<T> caller, final Function<T, Boolean> call, final String errorMessage) { return promises .promisify(caller, call) .then(valid -> valid ? promises.resolve(true) : promises.reject(errorMessage)); } @Inject  GeneralSettingsPresenter(final View view,
                                    final Promises promises,
                                    final MenuItem<ProjectScreenModel> menuItem,
                                    final Caller<ValidationService> validationService,
                                    final Caller<WorkspaceProjectService> projectService,
                                    final Event<SettingsSectionChange<ProjectScreenModel>> settingsSectionChangeEvent,
                                    final GAVPreferences gavPreferences,
                                    final ProjectScopedResolutionStrategySupplier projectScopedResolutionStrategySupplier,
                                    final GitUrlsPresenter gitUrlsPresenter,
                                    final LibraryPlaces libraryPlaces); @Override Promise<Void> setup(final ProjectScreenModel model); @Override Promise<Object> validate(); @Override Promise<Void> save(final String comment,
                              final Supplier<Promise<Void>> chain); @Override int currentHashCode(); GitUrlsPresenter getGitUrlsPresenter(); @Override SectionView<?> getView(); }
GeneralSettingsPresenter extends Section<ProjectScreenModel> { <T> Promise<Boolean> executeValidation(final Caller<T> caller, final Function<T, Boolean> call, final String errorMessage) { return promises .promisify(caller, call) .then(valid -> valid ? promises.resolve(true) : promises.reject(errorMessage)); } @Inject  GeneralSettingsPresenter(final View view,
                                    final Promises promises,
                                    final MenuItem<ProjectScreenModel> menuItem,
                                    final Caller<ValidationService> validationService,
                                    final Caller<WorkspaceProjectService> projectService,
                                    final Event<SettingsSectionChange<ProjectScreenModel>> settingsSectionChangeEvent,
                                    final GAVPreferences gavPreferences,
                                    final ProjectScopedResolutionStrategySupplier projectScopedResolutionStrategySupplier,
                                    final GitUrlsPresenter gitUrlsPresenter,
                                    final LibraryPlaces libraryPlaces); @Override Promise<Void> setup(final ProjectScreenModel model); @Override Promise<Object> validate(); @Override Promise<Void> save(final String comment,
                              final Supplier<Promise<Void>> chain); @Override int currentHashCode(); GitUrlsPresenter getGitUrlsPresenter(); @Override SectionView<?> getView();  }