@Test public void testValidate() { generalSettingsPresenter.pom = new POM("Name", null, "url", new GAV("GroupId:ArtifactId:Version"), false); doReturn("EmptyNameMessage").when(view).getEmptyNameMessage(); doReturn("InvalidNameMessage").when(view).getInvalidNameMessage(); doReturn("DuplicatedProjectNameMessage").when(view).getDuplicatedProjectNameMessage(); doReturn("EmptyGroupIdMessage").when(view).getEmptyGroupIdMessage(); doReturn("InvalidGroupIdMessage").when(view).getInvalidGroupIdMessage(); doReturn("EmptyArtifactIdMessage").when(view).getEmptyArtifactIdMessage(); doReturn("InvalidArtifactIdMessage").when(view).getInvalidArtifactIdMessage(); doReturn("EmptyVersionMessage").when(view).getEmptyVersionMessage(); doReturn("InvalidVersionMessage").when(view).getInvalidVersionMessage(); doReturn(true).when(validationService).isProjectNameValid(eq("Name")); doReturn(true).when(validationService).validateGroupId(eq("GroupId")); doReturn(true).when(validationService).validateArtifactId(eq("ArtifactId")); doReturn(true).when(validationService).validateGAVVersion(eq("Version")); doReturn(true).when(projectService).spaceHasNoProjectsWithName(any(), eq("Name"), eq(project)); generalSettingsPresenter.validate().catch_(i -> { Assert.fail("Promise should've been resolved!"); return promises.resolve(); }); verify(view).hideError(); verify(generalSettingsPresenter).validateStringIsNotEmpty(eq("Name"), eq("EmptyNameMessage")); verify(generalSettingsPresenter).executeValidation(any(), eq("InvalidNameMessage")); verify(validationService).isProjectNameValid(eq("Name")); verify(generalSettingsPresenter).executeValidation(eq(projectServiceCaller), any(), eq("DuplicatedProjectNameMessage")); verify(projectService).spaceHasNoProjectsWithName(any(), eq("Name"), eq(project)); verify(generalSettingsPresenter).validateStringIsNotEmpty(eq("GroupId"), eq("EmptyGroupIdMessage")); verify(generalSettingsPresenter).executeValidation(any(), eq("InvalidGroupIdMessage")); verify(validationService).validateGroupId(eq("GroupId")); verify(generalSettingsPresenter).validateStringIsNotEmpty(eq("ArtifactId"), eq("EmptyArtifactIdMessage")); verify(generalSettingsPresenter).executeValidation(any(), eq("InvalidArtifactIdMessage")); verify(validationService).validateArtifactId(eq("ArtifactId")); verify(generalSettingsPresenter).validateStringIsNotEmpty(eq("Version"), eq("EmptyVersionMessage")); verify(generalSettingsPresenter).executeValidation(any(), eq("InvalidVersionMessage")); verify(validationService).validateGAVVersion(eq("Version")); }
@Override public Promise<Object> validate() { view.hideError(); return promises.all( validateStringIsNotEmpty(pom.getName(), view.getEmptyNameMessage()) .then(o -> executeValidation(s -> s.isProjectNameValid(pom.getName()), view.getInvalidNameMessage())) .then(o -> executeValidation(projectService, s -> s.spaceHasNoProjectsWithName(libraryPlaces.getActiveWorkspace().getOrganizationalUnit(), pom.getName(), libraryPlaces.getActiveWorkspace()), view.getDuplicatedProjectNameMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getGroupId(), view.getEmptyGroupIdMessage()) .then(o -> executeValidation(s -> s.validateGroupId(pom.getGav().getGroupId()), view.getInvalidGroupIdMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getArtifactId(), view.getEmptyArtifactIdMessage()) .then(o -> executeValidation(s -> s.validateArtifactId(pom.getGav().getArtifactId()), view.getInvalidArtifactIdMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getVersion(), view.getEmptyVersionMessage()) .then(o -> executeValidation(s -> s.validateGAVVersion(pom.getGav().getVersion()), view.getInvalidVersionMessage())) .catch_(this::showErrorAndReject) ); }
GeneralSettingsPresenter extends Section<ProjectScreenModel> { @Override public Promise<Object> validate() { view.hideError(); return promises.all( validateStringIsNotEmpty(pom.getName(), view.getEmptyNameMessage()) .then(o -> executeValidation(s -> s.isProjectNameValid(pom.getName()), view.getInvalidNameMessage())) .then(o -> executeValidation(projectService, s -> s.spaceHasNoProjectsWithName(libraryPlaces.getActiveWorkspace().getOrganizationalUnit(), pom.getName(), libraryPlaces.getActiveWorkspace()), view.getDuplicatedProjectNameMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getGroupId(), view.getEmptyGroupIdMessage()) .then(o -> executeValidation(s -> s.validateGroupId(pom.getGav().getGroupId()), view.getInvalidGroupIdMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getArtifactId(), view.getEmptyArtifactIdMessage()) .then(o -> executeValidation(s -> s.validateArtifactId(pom.getGav().getArtifactId()), view.getInvalidArtifactIdMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getVersion(), view.getEmptyVersionMessage()) .then(o -> executeValidation(s -> s.validateGAVVersion(pom.getGav().getVersion()), view.getInvalidVersionMessage())) .catch_(this::showErrorAndReject) ); } }
GeneralSettingsPresenter extends Section<ProjectScreenModel> { @Override public Promise<Object> validate() { view.hideError(); return promises.all( validateStringIsNotEmpty(pom.getName(), view.getEmptyNameMessage()) .then(o -> executeValidation(s -> s.isProjectNameValid(pom.getName()), view.getInvalidNameMessage())) .then(o -> executeValidation(projectService, s -> s.spaceHasNoProjectsWithName(libraryPlaces.getActiveWorkspace().getOrganizationalUnit(), pom.getName(), libraryPlaces.getActiveWorkspace()), view.getDuplicatedProjectNameMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getGroupId(), view.getEmptyGroupIdMessage()) .then(o -> executeValidation(s -> s.validateGroupId(pom.getGav().getGroupId()), view.getInvalidGroupIdMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getArtifactId(), view.getEmptyArtifactIdMessage()) .then(o -> executeValidation(s -> s.validateArtifactId(pom.getGav().getArtifactId()), view.getInvalidArtifactIdMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getVersion(), view.getEmptyVersionMessage()) .then(o -> executeValidation(s -> s.validateGAVVersion(pom.getGav().getVersion()), view.getInvalidVersionMessage())) .catch_(this::showErrorAndReject) ); } @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> { @Override public Promise<Object> validate() { view.hideError(); return promises.all( validateStringIsNotEmpty(pom.getName(), view.getEmptyNameMessage()) .then(o -> executeValidation(s -> s.isProjectNameValid(pom.getName()), view.getInvalidNameMessage())) .then(o -> executeValidation(projectService, s -> s.spaceHasNoProjectsWithName(libraryPlaces.getActiveWorkspace().getOrganizationalUnit(), pom.getName(), libraryPlaces.getActiveWorkspace()), view.getDuplicatedProjectNameMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getGroupId(), view.getEmptyGroupIdMessage()) .then(o -> executeValidation(s -> s.validateGroupId(pom.getGav().getGroupId()), view.getInvalidGroupIdMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getArtifactId(), view.getEmptyArtifactIdMessage()) .then(o -> executeValidation(s -> s.validateArtifactId(pom.getGav().getArtifactId()), view.getInvalidArtifactIdMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getVersion(), view.getEmptyVersionMessage()) .then(o -> executeValidation(s -> s.validateGAVVersion(pom.getGav().getVersion()), view.getInvalidVersionMessage())) .catch_(this::showErrorAndReject) ); } @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> { @Override public Promise<Object> validate() { view.hideError(); return promises.all( validateStringIsNotEmpty(pom.getName(), view.getEmptyNameMessage()) .then(o -> executeValidation(s -> s.isProjectNameValid(pom.getName()), view.getInvalidNameMessage())) .then(o -> executeValidation(projectService, s -> s.spaceHasNoProjectsWithName(libraryPlaces.getActiveWorkspace().getOrganizationalUnit(), pom.getName(), libraryPlaces.getActiveWorkspace()), view.getDuplicatedProjectNameMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getGroupId(), view.getEmptyGroupIdMessage()) .then(o -> executeValidation(s -> s.validateGroupId(pom.getGav().getGroupId()), view.getInvalidGroupIdMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getArtifactId(), view.getEmptyArtifactIdMessage()) .then(o -> executeValidation(s -> s.validateArtifactId(pom.getGav().getArtifactId()), view.getInvalidArtifactIdMessage())) .catch_(this::showErrorAndReject), validateStringIsNotEmpty(pom.getGav().getVersion(), view.getEmptyVersionMessage()) .then(o -> executeValidation(s -> s.validateGAVVersion(pom.getGav().getVersion()), view.getInvalidVersionMessage())) .catch_(this::showErrorAndReject) ); } @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();  }