Merge branch 'stable-3.2' into stable-3.3
* stable-3.2:
Fix test due to change in Gerrit core
Index change when combined state changes
ChecksSubmitRule.Module: Demote base class to AbstractModule
Change-Id: I67a1bccc4f5d81261320afc1b3d9b31fce49a8f3
diff --git a/BUILD b/BUILD
index 79ebe56..e1a244a 100644
--- a/BUILD
+++ b/BUILD
@@ -1,3 +1,8 @@
+load(
+ "//tools/bzl:plugin.bzl",
+ "gerrit_plugin",
+)
+
package_group(
name = "visibility",
packages = ["//plugins/checks/..."],
@@ -5,11 +10,6 @@
package(default_visibility = [":visibility"])
-load(
- "//tools/bzl:plugin.bzl",
- "gerrit_plugin",
-)
-
gerrit_plugin(
name = "checks",
srcs = glob(["java/com/google/gerrit/plugins/checks/**/*.java"]),
diff --git a/gr-checks/BUILD b/gr-checks/BUILD
index 3889aae..034acd2 100644
--- a/gr-checks/BUILD
+++ b/gr-checks/BUILD
@@ -1,3 +1,7 @@
+load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
+load("//tools/bzl:js.bzl", "polygerrit_plugin")
+load("//tools/bzl:genrule2.bzl", "genrule2")
+
package_group(
name = "visibility",
packages = ["//plugins/checks/..."],
@@ -5,10 +9,6 @@
package(default_visibility = [":visibility"])
-load("@npm_bazel_rollup//:index.bzl", "rollup_bundle")
-load("//tools/bzl:js.bzl", "polygerrit_plugin")
-load("//tools/bzl:genrule2.bzl", "genrule2")
-
polygerrit_plugin(
name = "gr-checks",
app = "checks-bundle.js",
@@ -19,9 +19,9 @@
name = "checks-bundle",
srcs = glob(["*.js"]),
entry_point = "gr-checks.js",
+ format = "iife",
rollup_bin = "//tools/node_tools:rollup-bin",
sourcemap = "hidden",
- format = 'iife',
deps = [
"@tools_npm//rollup-plugin-node-resolve",
],
diff --git a/gr-checks/gr-checkers-list.js b/gr-checks/gr-checkers-list.js
index b7441e9..da61b22 100644
--- a/gr-checks/gr-checkers-list.js
+++ b/gr-checks/gr-checkers-list.js
@@ -200,7 +200,7 @@
}
_handleEditCancel(e) {
- if (e.detail.reload) {
+ if (e.detail && e.detail.reload) {
this._getCheckers();
}
this.$.editOverlay.close();
diff --git a/java/com/google/gerrit/plugins/checks/CheckerMergeValidator.java b/java/com/google/gerrit/plugins/checks/CheckerMergeValidator.java
index 1df2759..0e454eb 100644
--- a/java/com/google/gerrit/plugins/checks/CheckerMergeValidator.java
+++ b/java/com/google/gerrit/plugins/checks/CheckerMergeValidator.java
@@ -19,6 +19,7 @@
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.git.CodeReviewCommit;
+import com.google.gerrit.server.git.CodeReviewCommit.CodeReviewRevWalk;
import com.google.gerrit.server.git.validators.MergeValidationException;
import com.google.gerrit.server.git.validators.MergeValidationListener;
import com.google.gerrit.server.project.ProjectState;
@@ -37,6 +38,7 @@
@Override
public void onPreMerge(
Repository repo,
+ CodeReviewRevWalk revWalk,
CodeReviewCommit commit,
ProjectState destProject,
BranchNameKey destBranch,
diff --git a/java/com/google/gerrit/plugins/checks/ChecksUpdate.java b/java/com/google/gerrit/plugins/checks/ChecksUpdate.java
index 6191cd2..336a961 100644
--- a/java/com/google/gerrit/plugins/checks/ChecksUpdate.java
+++ b/java/com/google/gerrit/plugins/checks/ChecksUpdate.java
@@ -35,6 +35,7 @@
import com.google.gerrit.server.ServerInitiated;
import com.google.gerrit.server.UserInitiated;
import com.google.gerrit.server.change.NotifyResolver;
+import com.google.gerrit.server.mail.send.MessageIdGenerator;
import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
@@ -68,6 +69,7 @@
private final Checks checks;
private final Checkers checkers;
private final NotifyResolver notifyResolver;
+ private final MessageIdGenerator messageIdGenerator;
private final Changes changes;
private final Optional<IdentifiedUser> currentUser;
@@ -81,6 +83,7 @@
Checks checks,
Checkers checkers,
NotifyResolver notifyResolver,
+ MessageIdGenerator messageIdGenerator,
Changes changes,
@Assisted IdentifiedUser currentUser) {
this.checksStorageUpdate = checksStorageUpdate;
@@ -91,6 +94,7 @@
this.checks = checks;
this.checkers = checkers;
this.notifyResolver = notifyResolver;
+ this.messageIdGenerator = messageIdGenerator;
this.changes = changes;
this.currentUser = Optional.of(currentUser);
}
@@ -105,6 +109,7 @@
Checks checks,
Checkers checkers,
NotifyResolver notifyResolver,
+ MessageIdGenerator messageIdGenerator,
Changes changes) {
this.checksStorageUpdate = checksStorageUpdate;
this.combinedCheckStateCache = combinedCheckStateCache;
@@ -114,6 +119,7 @@
this.checks = checks;
this.checkers = checkers;
this.notifyResolver = notifyResolver;
+ this.messageIdGenerator = messageIdGenerator;
this.changes = changes;
this.currentUser = Optional.empty();
}
@@ -227,6 +233,8 @@
updatedCheck);
sender.setNotify(notify);
sender.setChecksByChecker(getAllChecksByChecker(checkKey));
+ sender.setMessageId(
+ messageIdGenerator.fromChangeUpdate(checkKey.repository(), checkKey.patchSet()));
sender.send();
} catch (Exception e) {
logger.atSevere().withCause(e).log(
diff --git a/java/com/google/gerrit/plugins/checks/api/ChecksFactory.java b/java/com/google/gerrit/plugins/checks/api/ChecksFactory.java
index 2aeaf8c..01cd6e6 100644
--- a/java/com/google/gerrit/plugins/checks/api/ChecksFactory.java
+++ b/java/com/google/gerrit/plugins/checks/api/ChecksFactory.java
@@ -67,7 +67,7 @@
private ChangeResource getChangeResource(Change.Id changeId) throws RestApiException {
try {
- ChangeNotes notes = changeNotesFactory.createChecked(changeId);
+ ChangeNotes notes = changeNotesFactory.createCheckedUsingIndexLookup(changeId);
return changeResourceFactory.create(notes, user.get());
} catch (NoSuchChangeException e) {
throw new ResourceNotFoundException(String.format("Change %d not found", changeId.get()), e);
diff --git a/java/com/google/gerrit/plugins/checks/email/CombinedCheckStateUpdatedSender.java b/java/com/google/gerrit/plugins/checks/email/CombinedCheckStateUpdatedSender.java
index 26e4841..d8f4e73 100644
--- a/java/com/google/gerrit/plugins/checks/email/CombinedCheckStateUpdatedSender.java
+++ b/java/com/google/gerrit/plugins/checks/email/CombinedCheckStateUpdatedSender.java
@@ -23,13 +23,13 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.gerrit.entities.Change;
+import com.google.gerrit.entities.NotifyConfig.NotifyType;
import com.google.gerrit.entities.Project;
import com.google.gerrit.exceptions.EmailException;
import com.google.gerrit.plugins.checks.Check;
import com.google.gerrit.plugins.checks.Checker;
import com.google.gerrit.plugins.checks.api.CheckState;
import com.google.gerrit.plugins.checks.api.CombinedCheckState;
-import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.mail.send.ChangeEmail;
import com.google.gerrit.server.mail.send.EmailArguments;
import com.google.gerrit.server.mail.send.ReplyToChangeSender;
@@ -164,9 +164,4 @@
appendHtml(soyHtmlTemplate("CombinedCheckStateUpdatedHtml"));
}
}
-
- @Override
- protected boolean supportsHtml() {
- return true;
- }
}
diff --git a/java/com/google/gerrit/plugins/checks/rules/ChecksSubmitRule.java b/java/com/google/gerrit/plugins/checks/rules/ChecksSubmitRule.java
index 6d3ac4e..4f7ab1c 100644
--- a/java/com/google/gerrit/plugins/checks/rules/ChecksSubmitRule.java
+++ b/java/com/google/gerrit/plugins/checks/rules/ChecksSubmitRule.java
@@ -16,12 +16,12 @@
import com.google.common.collect.ImmutableList;
import com.google.common.flogger.FluentLogger;
-import com.google.gerrit.common.data.SubmitRecord;
-import com.google.gerrit.common.data.SubmitRecord.Status;
-import com.google.gerrit.common.data.SubmitRequirement;
import com.google.gerrit.entities.Change;
import com.google.gerrit.entities.PatchSet;
import com.google.gerrit.entities.Project;
+import com.google.gerrit.entities.SubmitRecord;
+import com.google.gerrit.entities.SubmitRecord.Status;
+import com.google.gerrit.entities.SubmitRequirement;
import com.google.gerrit.extensions.annotations.Exports;
import com.google.gerrit.plugins.checks.Checks;
import com.google.gerrit.server.query.change.ChangeData;
@@ -63,9 +63,9 @@
Project.NameKey project = changeData.project();
Change.Id changeId = changeData.getId();
- PatchSet.Id currentPathSetId;
+ PatchSet.Id currentPatchSetId;
try {
- currentPathSetId = changeData.currentPatchSet().id();
+ currentPatchSetId = changeData.currentPatchSet().id();
} catch (RuntimeException e) {
String errorMessage =
String.format("failed to load the current patch set of change %s", changeId);
@@ -76,7 +76,7 @@
boolean areAllRequiredCheckersPassing;
try {
areAllRequiredCheckersPassing =
- checks.areAllRequiredCheckersPassing(project, currentPathSetId);
+ checks.areAllRequiredCheckersPassing(project, currentPatchSetId);
} catch (IOException e) {
String errorMessage =
String.format("failed to evaluate check states for change %s", changeId);
diff --git a/javatests/com/google/gerrit/plugins/checks/BUILD b/javatests/com/google/gerrit/plugins/checks/BUILD
index aeded72..e76fbfa 100644
--- a/javatests/com/google/gerrit/plugins/checks/BUILD
+++ b/javatests/com/google/gerrit/plugins/checks/BUILD
@@ -1,7 +1,7 @@
-package(default_visibility = ["//plugins/checks:visibility"])
-
load("//tools/bzl:junit.bzl", "junit_tests")
+package(default_visibility = ["//plugins/checks:visibility"])
+
junit_tests(
name = "checks_tests",
srcs = glob(["*.java"]),
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/BUILD b/javatests/com/google/gerrit/plugins/checks/acceptance/BUILD
index e279935..78075c6 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/BUILD
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/BUILD
@@ -1,7 +1,7 @@
-package(default_visibility = ["//plugins/checks:visibility"])
-
load("//javatests/com/google/gerrit/acceptance:tests.bzl", "acceptance_tests")
+package(default_visibility = ["//plugins/checks:visibility"])
+
acceptance_tests(
srcs = glob(["*IT.java"]),
group = "checks",
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/CheckerRefsIT.java b/javatests/com/google/gerrit/plugins/checks/acceptance/CheckerRefsIT.java
index 8afc373..abb015a 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/CheckerRefsIT.java
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/CheckerRefsIT.java
@@ -25,9 +25,9 @@
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.SkipProjectClone;
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
-import com.google.gerrit.common.data.Permission;
import com.google.gerrit.entities.BranchNameKey;
import com.google.gerrit.entities.Change;
+import com.google.gerrit.entities.Permission;
import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.client.ChangeStatus;
import com.google.gerrit.extensions.common.ChangeInput;
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/api/ChecksEmailIT.java b/javatests/com/google/gerrit/plugins/checks/acceptance/api/ChecksEmailIT.java
index d4fe337..b706898 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/api/ChecksEmailIT.java
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/api/ChecksEmailIT.java
@@ -64,6 +64,9 @@
@Inject private GroupOperations groupOperations;
@Inject private ProjectOperations projectOperations;
+ private static final String GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE =
+ "Gerrit-MessageType: combinedCheckStateUpdate";
+
private TestAccount bot;
private TestAccount owner;
private TestAccount ignoringReviewer;
@@ -77,7 +80,7 @@
public void setup() throws Exception {
// Create a bot account, create a bots group and add the bot as member and allow the bots group
// to post checks.
- bot = accountCreator.create("bot", "bot@test.com", "Bot", null);
+ bot = accountCreator.create("bot", "bot@example.com", "Bot", null);
AccountGroup.UUID botsAccountGroupUuid =
groupOperations.newGroup().name("bots").addMember(bot.id()).create();
projectOperations
@@ -93,16 +96,16 @@
patchSetId = result.getPatchSetId();
// Add a reviewer.
- reviewer = accountCreator.create("reviewer", "reviewer@test.com", "Reviewer", null);
+ reviewer = accountCreator.create("reviewer", "reviewer@example.com", "Reviewer", null);
gApi.changes().id(patchSetId.changeId().get()).addReviewer(reviewer.username());
// Star the change from some user.
- starrer = accountCreator.create("starred", "starrer@test.com", "Starrer", null);
+ starrer = accountCreator.create("starred", "starrer@example.com", "Starrer", null);
requestScopeOperations.setApiUser(starrer.id());
gApi.accounts().self().starChange(patchSetId.changeId().toString());
// Watch all comments of change from some user.
- watcher = accountCreator.create("watcher", "watcher@test.com", "Watcher", null);
+ watcher = accountCreator.create("watcher", "watcher@example.com", "Watcher", null);
requestScopeOperations.setApiUser(watcher.id());
ProjectWatchInfo projectWatchInfo = new ProjectWatchInfo();
projectWatchInfo.project = project.get();
@@ -114,7 +117,7 @@
TestAccount changeCreationWatcher =
accountCreator.create(
"changeCreationWatcher",
- "changeCreationWatcher@test.com",
+ "changeCreationWatcher@example.com",
"Change Creation Watcher",
null);
requestScopeOperations.setApiUser(changeCreationWatcher.id());
@@ -125,7 +128,7 @@
gApi.accounts().self().setWatchedProjects(ImmutableList.of(projectWatchInfo));
// Add a reviewer that ignores the change --> user doesn't get notified by checks plugin.
- ignoringReviewer = accountCreator.create("ignorer", "ignorer@test.com", "Ignorer", null);
+ ignoringReviewer = accountCreator.create("ignorer", "ignorer@example.com", "Ignorer", null);
requestScopeOperations.setApiUser(admin.id());
gApi.changes().id(patchSetId.changeId().get()).addReviewer(ignoringReviewer.username());
requestScopeOperations.setApiUser(ignoringReviewer.id());
@@ -570,18 +573,18 @@
Message message = messages.get(0);
assertThat(message.body())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedText(CombinedCheckState.SUCCESSFUL)
+ allChecksOverviewText(
- ImmutableMap.of(CheckState.SUCCESSFUL, ImmutableList.of(checkerName)))
- + textEmailFooterForCombinedCheckStateUpdate());
+ ImmutableMap.of(CheckState.SUCCESSFUL, ImmutableList.of(checkerName))));
+ assertThat(message.body()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
assertThat(message.htmlBody())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedHtml(CombinedCheckState.SUCCESSFUL)
+ allChecksOverviewHtml(
- ImmutableMap.of(CheckState.SUCCESSFUL, ImmutableList.of(checkerName)))
- + htmlEmailFooterForCombinedCheckStateUpdate());
+ ImmutableMap.of(CheckState.SUCCESSFUL, ImmutableList.of(checkerName))));
+ assertThat(message.htmlBody()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
}
@Test
@@ -600,7 +603,7 @@
Message message = messages.get(0);
assertThat(message.body())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedText(CombinedCheckState.FAILED)
+ "\n"
+ "Checker "
@@ -609,11 +612,11 @@
+ CheckState.FAILED
+ ".\n"
+ allChecksOverviewText(
- ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName)))
- + textEmailFooterForCombinedCheckStateUpdate());
+ ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName))));
+ assertThat(message.body()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
assertThat(message.htmlBody())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedHtml(CombinedCheckState.FAILED)
+ "<p>Checker <strong>"
+ checkerName
@@ -621,8 +624,8 @@
+ CheckState.FAILED
+ ".</p>"
+ allChecksOverviewHtml(
- ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName)))
- + htmlEmailFooterForCombinedCheckStateUpdate());
+ ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName))));
+ assertThat(message.htmlBody()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
}
@Test
@@ -649,7 +652,7 @@
Message message = messages.get(0);
assertThat(message.body())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedText(CombinedCheckState.FAILED)
+ "\n"
+ "Checker "
@@ -660,11 +663,11 @@
+ CheckState.FAILED
+ ".\n"
+ allChecksOverviewText(
- ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName)))
- + textEmailFooterForCombinedCheckStateUpdate());
+ ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName))));
+ assertThat(message.body()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
assertThat(message.htmlBody())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedHtml(CombinedCheckState.FAILED)
+ "<p>Checker <a href=\""
+ checkerUrl
@@ -674,8 +677,8 @@
+ CheckState.FAILED
+ ".</p>"
+ allChecksOverviewHtml(
- ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName)))
- + htmlEmailFooterForCombinedCheckStateUpdate());
+ ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName))));
+ assertThat(message.htmlBody()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
}
@Test
@@ -696,7 +699,7 @@
Message message = messages.get(0);
assertThat(message.body())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedText(CombinedCheckState.FAILED)
+ "\n"
+ "Checker "
@@ -707,11 +710,11 @@
+ checkMessage
+ "\n"
+ allChecksOverviewText(
- ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName)))
- + textEmailFooterForCombinedCheckStateUpdate());
+ ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName))));
+ assertThat(message.body()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
assertThat(message.htmlBody())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedHtml(CombinedCheckState.FAILED)
+ "<p>Checker <strong>"
+ checkerName
@@ -721,8 +724,8 @@
+ checkMessage
+ "</p>"
+ allChecksOverviewHtml(
- ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName)))
- + htmlEmailFooterForCombinedCheckStateUpdate());
+ ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName))));
+ assertThat(message.htmlBody()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
}
@Test
@@ -743,7 +746,7 @@
Message message = messages.get(0);
assertThat(message.body())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedText(CombinedCheckState.FAILED)
+ "\n"
+ "Checker "
@@ -754,11 +757,11 @@
+ checkUrl
+ " ).\n"
+ allChecksOverviewText(
- ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName)))
- + textEmailFooterForCombinedCheckStateUpdate());
+ ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName))));
+ assertThat(message.body()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
assertThat(message.htmlBody())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedHtml(CombinedCheckState.FAILED)
+ "<p>Checker <strong>"
+ checkerName
@@ -769,8 +772,8 @@
+ "</a>.</p>"
+ allChecksOverviewHtml(
ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName)),
- ImmutableMap.of(checkerName, checkUrl))
- + htmlEmailFooterForCombinedCheckStateUpdate());
+ ImmutableMap.of(checkerName, checkUrl)));
+ assertThat(message.htmlBody()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
}
@Test
@@ -789,7 +792,7 @@
Message message = messages.get(0);
assertThat(message.body())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedText(CombinedCheckState.WARNING)
+ "\n"
+ "Checker "
@@ -798,11 +801,11 @@
+ CheckState.FAILED
+ ".\n"
+ allChecksOverviewText(
- ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName)))
- + textEmailFooterForCombinedCheckStateUpdate());
+ ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName))));
+ assertThat(message.body()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
assertThat(message.htmlBody())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedHtml(CombinedCheckState.WARNING)
+ "<p>Checker <strong>"
+ checkerName
@@ -810,8 +813,8 @@
+ CheckState.FAILED
+ ".</p>"
+ allChecksOverviewHtml(
- ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName)))
- + htmlEmailFooterForCombinedCheckStateUpdate());
+ ImmutableMap.of(CheckState.FAILED, ImmutableList.of(checkerName))));
+ assertThat(message.htmlBody()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
}
@Test
@@ -842,26 +845,26 @@
Message message = messages.get(0);
assertThat(message.body())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedText(CombinedCheckState.WARNING)
+ allChecksOverviewText(
ImmutableMap.of(
CheckState.SUCCESSFUL,
ImmutableList.of(checkerNameRequired),
CheckState.FAILED,
- ImmutableList.of(checkerNameOptional)))
- + textEmailFooterForCombinedCheckStateUpdate());
+ ImmutableList.of(checkerNameOptional))));
+ assertThat(message.body()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
assertThat(message.htmlBody())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedHtml(CombinedCheckState.WARNING)
+ allChecksOverviewHtml(
ImmutableMap.of(
CheckState.SUCCESSFUL,
ImmutableList.of(checkerNameRequired),
CheckState.FAILED,
- ImmutableList.of(checkerNameOptional)))
- + htmlEmailFooterForCombinedCheckStateUpdate());
+ ImmutableList.of(checkerNameOptional))));
+ assertThat(message.htmlBody()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
}
@Test
@@ -897,7 +900,7 @@
Message message = messages.get(0);
assertThat(message.body())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedText(CombinedCheckState.FAILED)
+ "\n"
+ "Checker "
@@ -905,19 +908,19 @@
+ " updated the check state to "
+ CheckState.FAILED
+ ".\n"
- + allChecksOverviewText(expectedCheckersByState)
- + textEmailFooterForCombinedCheckStateUpdate());
+ + allChecksOverviewText(expectedCheckersByState));
+ assertThat(message.body()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
assertThat(message.htmlBody())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedHtml(CombinedCheckState.FAILED)
+ "<p>Checker <strong>"
+ checkerNameFailed
+ "</strong> updated the check state to "
+ CheckState.FAILED
+ ".</p>"
- + allChecksOverviewHtml(expectedCheckersByState)
- + htmlEmailFooterForCombinedCheckStateUpdate());
+ + allChecksOverviewHtml(expectedCheckersByState));
+ assertThat(message.htmlBody()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
}
@Test
@@ -974,7 +977,7 @@
Message message = messages.get(0);
assertThat(message.body())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedText(CombinedCheckState.FAILED)
+ "\n"
+ "Checker "
@@ -982,19 +985,19 @@
+ " updated the check state to "
+ CheckState.FAILED
+ ".\n"
- + allChecksOverviewText(expectedCheckersByState)
- + textEmailFooterForCombinedCheckStateUpdate());
+ + allChecksOverviewText(expectedCheckersByState));
+ assertThat(message.body()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
assertThat(message.htmlBody())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedHtml(CombinedCheckState.FAILED)
+ "<p>Checker <strong>"
+ checkerNameFailed
+ "</strong> updated the check state to "
+ CheckState.FAILED
+ ".</p>"
- + allChecksOverviewHtml(expectedCheckersByState)
- + htmlEmailFooterForCombinedCheckStateUpdate());
+ + allChecksOverviewHtml(expectedCheckersByState));
+ assertThat(message.htmlBody()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
}
@Test
@@ -1042,7 +1045,7 @@
Message message = messages.get(0);
assertThat(message.body())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedText(CombinedCheckState.FAILED)
+ "\n"
+ "Checker "
@@ -1050,11 +1053,11 @@
+ " updated the check state to "
+ CheckState.FAILED
+ ".\n"
- + allChecksOverviewText(expectedCheckersByState)
- + textEmailFooterForCombinedCheckStateUpdate());
+ + allChecksOverviewText(expectedCheckersByState));
+ assertThat(message.body()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
assertThat(message.htmlBody())
- .isEqualTo(
+ .contains(
combinedCheckStateUpdatedHtml(CombinedCheckState.FAILED)
+ "<p>Checker <strong>"
+ checkerNameFailed
@@ -1064,8 +1067,8 @@
+ allChecksOverviewHtml(
expectedCheckersByState,
ImmutableMap.of(
- checkerNameRunningFoo, checkUrlFoo, checkerNameRunningBar, checkUrlBar))
- + htmlEmailFooterForCombinedCheckStateUpdate());
+ checkerNameRunningFoo, checkUrlFoo, checkerNameRunningBar, checkUrlBar)));
+ assertThat(message.htmlBody()).contains(GERRIT_MESSAGE_TYPE_COMBINED_CHECK_STATE_UPDATE);
}
@Test
@@ -1138,53 +1141,6 @@
return b.toString();
}
- private String textEmailFooterForCombinedCheckStateUpdate() {
- return "\n"
- + "Change subject: "
- + change.getSubject()
- + "\n"
- + "......................................................................\n"
- + "-- \n"
- + "To view, visit "
- + changeUrl(change)
- + "\n"
- + "To unsubscribe, or for help writing mail filters, visit "
- + canonicalWebUrl.get()
- + "settings\n"
- + "\n"
- + "Gerrit-Project: "
- + project.get()
- + "\n"
- + "Gerrit-Branch: "
- + change.getDest().shortName()
- + "\n"
- + "Gerrit-Change-Id: "
- + change.getKey().get()
- + "\n"
- + "Gerrit-Change-Number: "
- + change.getChangeId()
- + "\n"
- + "Gerrit-PatchSet: "
- + patchSetId.get()
- + "\n"
- + "Gerrit-Owner: "
- + owner.fullName()
- + " <"
- + owner.email()
- + ">\n"
- + "Gerrit-Reviewer: "
- + ignoringReviewer.fullName()
- + " <"
- + ignoringReviewer.email()
- + ">\n"
- + "Gerrit-Reviewer: "
- + reviewer.fullName()
- + " <"
- + reviewer.email()
- + ">\n"
- + "Gerrit-MessageType: combinedCheckStateUpdate\n";
- }
-
private String combinedCheckStateUpdatedHtml(CombinedCheckState combinedCheckState) {
return "<p>The combined check state has been updated to <strong>"
+ combinedCheckState
@@ -1255,54 +1211,6 @@
return "<p><a href=\"" + changeUrl(change) + "\">View Change</a></p>";
}
- private String htmlEmailFooterForCombinedCheckStateUpdate() {
- return htmlViewChangeButton()
- + "<p>To view, visit <a href=\""
- + changeUrl(change)
- + "\">change "
- + change.getChangeId()
- + "</a>."
- + " To unsubscribe, or for help writing mail filters, visit <a href=\""
- + canonicalWebUrl.get()
- + "settings\">settings</a>.</p>"
- + "<div itemscope itemtype=\"http://schema.org/EmailMessage\">"
- + "<div itemscope itemprop=\"action\" itemtype=\"http://schema.org/ViewAction\">"
- + "<link itemprop=\"url\" href=\""
- + changeUrl(change)
- + "\"/>"
- + "<meta itemprop=\"name\" content=\"View Change\"/>"
- + "</div>"
- + "</div>\n\n"
- + "<div style=\"display:none\"> Gerrit-Project: "
- + project.get()
- + " </div>\n"
- + "<div style=\"display:none\"> Gerrit-Branch: "
- + change.getDest().shortName()
- + " </div>\n"
- + "<div style=\"display:none\"> Gerrit-Change-Id: "
- + change.getKey().get()
- + " </div>\n"
- + "<div style=\"display:none\"> Gerrit-Change-Number: "
- + change.getChangeId()
- + " </div>\n"
- + "<div style=\"display:none\"> Gerrit-PatchSet: "
- + patchSetId.get()
- + " </div>\n"
- + "<div style=\"display:none\"> Gerrit-Owner: Administrator <admin@example.com> </div>\n"
- + "<div style=\"display:none\"> Gerrit-Reviewer: "
- + ignoringReviewer.fullName()
- + " <"
- + ignoringReviewer.email()
- + "> </div>\n"
- + "<div style=\"display:none\"> Gerrit-Reviewer: "
- + reviewer.fullName()
- + " <"
- + reviewer.email()
- + "> </div>\n"
- + "<div style=\"display:none\"> Gerrit-MessageType: combinedCheckStateUpdate </div>\n"
- + "\n";
- }
-
private String changeUrl(Change change) {
return canonicalWebUrl.get() + "c/" + change.getProject().get() + "/+/" + change.getChangeId();
}
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/api/QueryPendingChecksIT.java b/javatests/com/google/gerrit/plugins/checks/acceptance/api/QueryPendingChecksIT.java
index 47b8fe1..94033f4 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/api/QueryPendingChecksIT.java
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/api/QueryPendingChecksIT.java
@@ -26,8 +26,8 @@
import com.google.gerrit.acceptance.UseClockStep;
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
-import com.google.gerrit.common.data.Permission;
import com.google.gerrit.entities.PatchSet;
+import com.google.gerrit.entities.Permission;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.plugins.checks.CheckKey;
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/db/BUILD b/javatests/com/google/gerrit/plugins/checks/acceptance/db/BUILD
index 03caa7d..af19b27 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/db/BUILD
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/db/BUILD
@@ -1,7 +1,7 @@
-package(default_visibility = ["//plugins/checks:visibility"])
-
load("//javatests/com/google/gerrit/acceptance:tests.bzl", "acceptance_tests")
+package(default_visibility = ["//plugins/checks:visibility"])
+
acceptance_tests(
srcs = glob(["*IT.java"]),
group = "get_combined_check_state",
diff --git a/javatests/com/google/gerrit/plugins/checks/acceptance/testsuite/BUILD b/javatests/com/google/gerrit/plugins/checks/acceptance/testsuite/BUILD
index 692ac74..535f220 100644
--- a/javatests/com/google/gerrit/plugins/checks/acceptance/testsuite/BUILD
+++ b/javatests/com/google/gerrit/plugins/checks/acceptance/testsuite/BUILD
@@ -1,7 +1,7 @@
-package(default_visibility = ["//plugins/checks:visibility"])
-
load("//javatests/com/google/gerrit/acceptance:tests.bzl", "acceptance_tests")
+package(default_visibility = ["//plugins/checks:visibility"])
+
acceptance_tests(
srcs = glob(["*Test.java"]),
group = "checks",
diff --git a/javatests/com/google/gerrit/plugins/checks/rules/ChecksSubmitRuleTest.java b/javatests/com/google/gerrit/plugins/checks/rules/ChecksSubmitRuleTest.java
index 7fe9c72..d96c7b6 100644
--- a/javatests/com/google/gerrit/plugins/checks/rules/ChecksSubmitRuleTest.java
+++ b/javatests/com/google/gerrit/plugins/checks/rules/ChecksSubmitRuleTest.java
@@ -20,11 +20,11 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.entities.Account;
import com.google.gerrit.entities.Change;
import com.google.gerrit.entities.PatchSet;
import com.google.gerrit.entities.Project;
+import com.google.gerrit.entities.SubmitRecord;
import com.google.gerrit.plugins.checks.Checks;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.util.time.TimeUtil;