@Override @NotNull public Collection<ConfigProblem> getConfigProblems() { return configParts.getConfigProblems(); }
@Override public boolean hasError() { for (ConfigProblem configProblem : getConfigProblems()) { if (configProblem.isError()) { return true; } } return false; }
@Override public void apply() throws ConfigurationException { Collection<ConfigProblem> problems = null; if (isModified()) { LOG.info("Updating root configuration for " + vcsRoot); // ClientConfig oldConfig = loadConfigFromSettings(); P4VcsRootSettings settings = new P4VcsRootSettingsImpl(project, vcsRoot); MultipleConfigPart parentPart = loadParentPartFromUI(); settings.setConfigParts(parentPart.getChildren()); mapping.setRootSettings(settings); if (parentPart.hasError()) { problems = parentPart.getConfigProblems(); } } else { LOG.info("Skipping root configuration update; nothing modified for " + vcsRoot); } // Send the update events regarding the root configuration updates. Do this even in the // case of an error, or if there were no updates. The no updates use case is for the situation where // events were fired in an unexpected order, then the user can rerun the apply to re-trigger everything. // It's a hack, yes. project.getMessageBus().syncPublisher(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED) .directoryMappingChanged(); if (problems != null) { LOG.warn("Configuration problems discovered; not adding: " + problems); throw new ConfigurationException(toMessage(problems), P4Bundle.getString("configuration.error.title")); } }
assertThat(part.getConfigProblems(), hasSize(4)); List<ConfigProblem> allProblems = new ArrayList<>(mockPartFirst.getConfigProblems()); allProblems.addAll(mockPartLast.getConfigProblems()); assertThat(part.getConfigProblems(), containsAll( allProblems )); assertThat(part.getConfigProblems(), hasSize(2)); assertThat(part.getConfigProblems(), containsAll(mockPartFirst.getConfigProblems())); assertFalse(part.hasError());
assertThat(part.getConfigProblems(), hasSize(2)); assertThat(part.getConfigProblems(), containsAll(mockPart.getConfigProblems())); assertTrue(part.hasError()); assertTrue(part.hasServerNameSet());
assertEmpty(part.getConfigProblems()); assertFalse(part.hasError()); assertFalse(part.hasServerNameSet());