Merge "Add more unit tests for Util.java"
diff --git a/src/test/java/com/googlesource/gerrit/plugins/findowners/OwnersValidatorTest.java b/src/test/java/com/googlesource/gerrit/plugins/findowners/OwnersValidatorTest.java
index 08c8dfe..cc60789 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/findowners/OwnersValidatorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/findowners/OwnersValidatorTest.java
@@ -128,10 +128,16 @@
}
}
+ private static final String INCLUDE_STMT1 = " include p1/p2 : /d1/owners";
+
+ private static final String INCLUDE_STMT2 = "include ../d2/owners ";
+
private static final ImmutableMap<String, String> FILES_WITH_NO_ERROR =
ImmutableMap.of(
OWNERS,
"\n\n#comments ...\n ### more comments\n"
+ + INCLUDE_STMT1 + "\n"
+ + INCLUDE_STMT2 + "\n"
+ " user1@google.com # comment\n"
+ "u1+review@g.com###\n"
+ " * # everyone can approve\n"
@@ -143,16 +149,24 @@
private static final ImmutableSet<String> EXPECTED_VERBOSE_OUTPUT =
ImmutableSet.of(
"MSG: validate: " + OWNERS,
+ "MSG: unchecked: OWNERS:5: " + INCLUDE_STMT1,
+ "MSG: unchecked: OWNERS:6: " + INCLUDE_STMT2,
"MSG: owner: u1+review@g.com",
"MSG: owner: u1@g.com",
"MSG: owner: u2.m@g.com",
"MSG: owner: user1@google.com");
+ private static final ImmutableSet<String> EXPECTED_NON_VERBOSE_OUTPUT =
+ ImmutableSet.of(
+ "MSG: unchecked: OWNERS:5: " + INCLUDE_STMT1,
+ "MSG: unchecked: OWNERS:6: " + INCLUDE_STMT2);
+
@Test
public void testGoodInput() throws Exception {
try (RevWalk rw = new RevWalk(repo)) {
RevCommit c = makeCommit(rw, "Commit good files", FILES_WITH_NO_ERROR);
- assertThat(validate(rw, c, false, ENABLED_CONFIG)).isEmpty();
+ assertThat(validate(rw, c, false, ENABLED_CONFIG))
+ .containsExactlyElementsIn(EXPECTED_NON_VERBOSE_OUTPUT);
assertThat(validate(rw, c, true, ENABLED_CONFIG))
.containsExactlyElementsIn(EXPECTED_VERBOSE_OUTPUT);
}