Merge "Add a rerun field to verifications"
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/PostVerification.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/PostVerification.java
index 4cee0af..8198981 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/PostVerification.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/PostVerification.java
@@ -126,6 +126,9 @@
         if (Boolean.TRUE.equals(ent.getValue().abstain)) {
           c.setAbstain(true);
         }
+        if (Boolean.TRUE.equals(ent.getValue().rerun)) {
+          c.setRerun(true);
+        }
         String url = ent.getValue().url;
         if (url != null) {
           c.setUrl(url);
@@ -161,6 +164,7 @@
                 new LabelId(job_id)),
             value, ts);
         c.setAbstain(ent.getValue().abstain);
+        c.setRerun(ent.getValue().rerun);
         c.setUrl(ent.getValue().url);
         c.setName(name);
         c.setReporter(ent.getValue().reporter);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java
index b8de4ba..b2da1de 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java
@@ -114,10 +114,12 @@
     checkArgument(value != null, "Verification is missing a value");
     checkArgument(!value.isEmpty(), "Verification is missing a value");
     String abstain = params.get("abstain");
+    String rerun = params.get("rerun");
     VerificationInfo data = new VerificationInfo();
     data.name = name;
     data.value = Short.parseShort(value);
     data.abstain = Boolean.valueOf(abstain);
+    data.rerun = Boolean.valueOf(rerun);
     data.url = params.get("url");
     data.reporter = params.get("reporter");
     data.comment = params.get("comment");
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsDropDownPanel.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsDropDownPanel.java
index 9fd378f..e3a9e31 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsDropDownPanel.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsDropDownPanel.java
@@ -99,6 +99,11 @@
         img.setTitle("non voting");
         p.add(img);
       }
+      if (jobs.get(key).rerun()) {
+        Image img = new Image(VerifyStatusPlugin.RESOURCES.rerun());
+        img.setTitle("re-run");
+        p.add(img);
+      }
       grid.setWidget(row, 1, p);
       InlineLabel catLabel = new InlineLabel(jobs.get(key).category());
       catLabel.setTitle("category");
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsPanel.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsPanel.java
index 727da7f..81465b1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsPanel.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsPanel.java
@@ -95,9 +95,9 @@
           new InlineLabel(" (" + jobs.get(key).duration() + ")");
       label.setTitle("duration");
       p.add(label);
-      if (jobs.get(key).category() == "recheck") {
+      if (jobs.get(key).rerun()) {
         Image img = new Image(VerifyStatusPlugin.RESOURCES.rerun());
-        img.setTitle("recheck");
+        img.setTitle("re-run");
         p.add(img);
       }
       if (jobs.get(key).abstain()) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsScreen.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsScreen.java
index 508ed1a..37aa615 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsScreen.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsScreen.java
@@ -75,9 +75,10 @@
     t.setText(0, 1, "Name");
     t.setText(0, 2, "Duration");
     t.setText(0, 3, "Voting");
-    t.setText(0, 4, "Category");
-    t.setText(0, 5, "Reporter");
-    t.setText(0, 6, "Date");
+    t.setText(0, 4, "Rerun");
+    t.setText(0, 5, "Category");
+    t.setText(0, 6, "Reporter");
+    t.setText(0, 7, "Date");
 
     int row = 1;
     for (String key : jobs.keySet()) {
@@ -104,10 +105,15 @@
       } else {
         t.setText(row, 3, "voting");
       }
+      if (vi.rerun()) {
+        t.setText(row, 4, "Y");
+      } else {
+        t.setText(row, 4, "N");
+      }
 
-      t.setText(row, 4, vi.category());
-      t.setText(row, 5, vi.reporter());
-      t.setText(row, 6, FormatUtil.shortFormat(vi.granted()));
+      t.setText(row, 5, vi.category());
+      t.setText(row, 6, vi.reporter());
+      t.setText(row, 7, FormatUtil.shortFormat(vi.granted()));
       row++;
     }
     add(t);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/VerificationInfo.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/VerificationInfo.java
index a3b3b17..958bdd7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/VerificationInfo.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/VerificationInfo.java
@@ -12,6 +12,7 @@
   public final native String comment() /*-{ return this.comment; }-*/;
   public final native short value() /*-{ return this.value; }-*/;
   public final native boolean abstain() /*-{ return this.abstain || false; }-*/;
+  public final native boolean rerun() /*-{ return this.rerun || false; }-*/;
   public final native String category() /*-{ return this.category; }-*/;
   public final native String duration() /*-{ return this.duration; }-*/;
   public final native String reporter() /*-{ return this.reporter; }-*/;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/common/VerificationInfo.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/common/VerificationInfo.java
index d280fa0..52385a8 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/common/VerificationInfo.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/common/VerificationInfo.java
@@ -21,6 +21,7 @@
   public String url;
   public Short value;
   public boolean abstain;
+  public boolean rerun;
   public String reporter;
   public String comment;
   public Timestamp granted;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetVerifications.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetVerifications.java
index 42be9b2..6e1e59c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetVerifications.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetVerifications.java
@@ -61,6 +61,7 @@
     VerificationInfo info = new VerificationInfo();
     info.value = v.getValue();
     info.abstain = v.getAbstain();
+    info.rerun = v.getRerun();
     info.url = v.getUrl();
     info.name = v.getName();
     info.reporter = v.getReporter();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerification.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerification.java
index 58f9735..4801321 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerification.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerification.java
@@ -88,6 +88,9 @@
   @Column(id = 10, notNull = false, length = 255)
   protected String name;
 
+  @Column(id = 11)
+  protected boolean rerun;
+
   protected PatchSetVerification() {
   }
 
@@ -126,6 +129,14 @@
     abstain = a;
   }
 
+  public boolean getRerun() {
+    return rerun;
+  }
+
+  public void setRerun(boolean r) {
+    rerun = r;
+  }
+
   public Timestamp getGranted() {
     return granted;
   }
diff --git a/src/main/resources/Documentation/rest-api-changes.md b/src/main/resources/Documentation/rest-api-changes.md
index 43a6143..7f9ea18 100644
--- a/src/main/resources/Documentation/rest-api-changes.md
+++ b/src/main/resources/Documentation/rest-api-changes.md
@@ -210,6 +210,7 @@
 |name        |required|The name of this job|
 |value       |required|The pass/fail result for this job|
 |abstain     |optional|Whether the value counts as a vote (defaults to false)|
+|rerun       |optional|Whether this result is from a re-test on the same patchset|
 |comment     |optional|A short comment about this job|
 |url         |optional|The url link to more info about this job|
 |reporter    |optional|The user that verified this job|
@@ -217,10 +218,6 @@
 |duration    |optional|The time it took to run this job|
 
 
-*__Notice__: There is a special category called 'recheck' that indicates that
-the job was a rerun on the same patchset.  An icon will appear on the change
-screen for these jobs.
-
 ### <a id="revision-info"></a>RevisionInfo
 
 The `RevisionInfo` entity contains information about a patch set.
@@ -242,6 +239,7 @@
 |name       |The name of this job|
 |value      |The pass/fail result for this job|
 |abstain    |Whether the value counts as a vote|
+|rerun      |Whether this result is from a re-test on the same patchset|
 |comment    |A short comment about this job|
 |url        |The url link to more info about this job|
 |reporter   |The user that verified this job|
diff --git a/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java b/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java
index 0550ffd..df879e6 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java
@@ -48,6 +48,7 @@
       "CATEGORY     VARCHAR(255)," +
       "DURATION     VARCHAR(255)," +
       "ABSTAIN      CHAR(1) DEFAULT 'N' NOT NULL," +
+      "RERUN        CHAR(1) DEFAULT 'N' NOT NULL," +
       "NAME         VARCHAR(255)," +
       "CHANGE_ID    INTEGER DEFAULT 0 NOT NULL," +
       "PATCH_SET_ID INTEGER DEFAULT 0 NOT NULL," +
@@ -94,6 +95,7 @@
     i.name = "job42";
     i.value = 1;
     i.reporter = "zuul@openstack.org";
+    i.rerun = true;
     i.comment = "Test CI";
     i.url = "url";
     i.category = "bar";
@@ -170,5 +172,6 @@
     assertThat(r.url).isEqualTo(e.url);
     assertThat(r.category).isEqualTo(e.category);
     assertThat(r.duration).isEqualTo(e.duration);
+    assertThat(r.rerun).isEqualTo(e.rerun);
   }
 }