[project.config] Override ValidationError equals()
Change-Id: Iebea816ff95c57dbe778df88f2ccae0e0e34fc90
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.git;
|
package com.google.gerrit.server.git;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
/** Indicates a problem with Git based data. */
|
/** Indicates a problem with Git based data. */
|
||||||
@@ -48,4 +49,21 @@ public class ValidationError {
|
|||||||
public static Sink createLoggerSink(String message, Logger log) {
|
public static Sink createLoggerSink(String message, Logger log) {
|
||||||
return error -> log.error(message + error.getMessage());
|
return error -> log.error(message + error.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (o == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o instanceof ValidationError) {
|
||||||
|
ValidationError that = (ValidationError) o;
|
||||||
|
return Objects.equals(this.message, that.message);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ package com.google.gerrit.server.git;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth.assertWithMessage;
|
import static com.google.common.truth.Truth.assertWithMessage;
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.gerrit.common.data.AccessSection;
|
import com.google.gerrit.common.data.AccessSection;
|
||||||
@@ -516,12 +515,13 @@ public class ProjectConfigTest extends GerritBaseTests {
|
|||||||
.create();
|
.create();
|
||||||
ProjectConfig cfg = read(rev);
|
ProjectConfig cfg = read(rev);
|
||||||
assertThat(cfg.getCommentLinkSections()).isEmpty();
|
assertThat(cfg.getCommentLinkSections()).isEmpty();
|
||||||
assertThat(cfg.getValidationErrors().stream().map(ValidationError::getMessage))
|
assertThat(cfg.getValidationErrors())
|
||||||
.containsExactly(
|
.containsExactly(
|
||||||
"project.config: Invalid pattern \"(bugs{+#?)(d+)\" in commentlink.bugzilla.match: "
|
new ValidationError(
|
||||||
+ "Illegal repetition near index 4\n"
|
"project.config: Invalid pattern \"(bugs{+#?)(d+)\" in commentlink.bugzilla.match: "
|
||||||
+ "(bugs{+#?)(d+)\n"
|
+ "Illegal repetition near index 4\n"
|
||||||
+ " ^");
|
+ "(bugs{+#?)(d+)\n"
|
||||||
|
+ " ^"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -536,10 +536,11 @@ public class ProjectConfigTest extends GerritBaseTests {
|
|||||||
.create();
|
.create();
|
||||||
ProjectConfig cfg = read(rev);
|
ProjectConfig cfg = read(rev);
|
||||||
assertThat(cfg.getCommentLinkSections()).isEmpty();
|
assertThat(cfg.getCommentLinkSections()).isEmpty();
|
||||||
assertThat(cfg.getValidationErrors().stream().map(ValidationError::getMessage))
|
assertThat(cfg.getValidationErrors())
|
||||||
.containsExactly(
|
.containsExactly(
|
||||||
"project.config: Error in pattern \"(bugs#?)(d+)\" in commentlink.bugzilla.match: "
|
new ValidationError(
|
||||||
+ "Raw html replacement not allowed");
|
"project.config: Error in pattern \"(bugs#?)(d+)\" in commentlink.bugzilla.match: "
|
||||||
|
+ "Raw html replacement not allowed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -550,10 +551,11 @@ public class ProjectConfigTest extends GerritBaseTests {
|
|||||||
.create();
|
.create();
|
||||||
ProjectConfig cfg = read(rev);
|
ProjectConfig cfg = read(rev);
|
||||||
assertThat(cfg.getCommentLinkSections()).isEmpty();
|
assertThat(cfg.getCommentLinkSections()).isEmpty();
|
||||||
assertThat(cfg.getValidationErrors().stream().map(ValidationError::getMessage))
|
assertThat(cfg.getValidationErrors())
|
||||||
.containsExactly(
|
.containsExactly(
|
||||||
"project.config: Error in pattern \"(bugs#?)(d+)\" in commentlink.bugzilla.match: "
|
new ValidationError(
|
||||||
+ "commentlink.bugzilla must have either link or html");
|
"project.config: Error in pattern \"(bugs#?)(d+)\" in commentlink.bugzilla.match: "
|
||||||
|
+ "commentlink.bugzilla must have either link or html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProjectConfig read(RevCommit rev) throws IOException, ConfigInvalidException {
|
private ProjectConfig read(RevCommit rev) throws IOException, ConfigInvalidException {
|
||||||
|
|||||||
Reference in New Issue
Block a user