Adapt to SubmitRule interface change

Change-Id: I56fe59a28db4a9ef94e16e5eea7a54b513166d44
diff --git a/src/main/java/com/googlesource/gerrit/plugins/simplesubmitrules/rules/NoUnresolvedCommentsRule.java b/src/main/java/com/googlesource/gerrit/plugins/simplesubmitrules/rules/NoUnresolvedCommentsRule.java
index c6107a9..231ff63 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/simplesubmitrules/rules/NoUnresolvedCommentsRule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/simplesubmitrules/rules/NoUnresolvedCommentsRule.java
@@ -14,7 +14,6 @@
 
 package com.googlesource.gerrit.plugins.simplesubmitrules.rules;
 
-import com.google.common.collect.ImmutableList;
 import com.google.gerrit.common.data.SubmitRecord;
 import com.google.gerrit.common.data.SubmitRequirement;
 import com.google.gerrit.exceptions.StorageException;
@@ -27,8 +26,8 @@
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.googlesource.gerrit.plugins.simplesubmitrules.SimpleSubmitRulesConfig;
-import java.util.Collection;
 import java.util.Collections;
+import java.util.Optional;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,7 +51,7 @@
   }
 
   @Override
-  public Collection<SubmitRecord> evaluate(ChangeData cd) {
+  public Optional<SubmitRecord> evaluate(ChangeData cd) {
     PluginConfig config;
     try {
       config = pluginConfigFactory.getFromProjectConfig(cd.project(), pluginName);
@@ -66,7 +65,7 @@
         config.getBoolean(SimpleSubmitRulesConfig.KEY_BLOCK_IF_UNRESOLVED_COMMENTS, false);
 
     if (!ruleEnabled) {
-      return Collections.emptyList();
+      return Optional.empty();
     }
 
     Integer unresolvedComments;
@@ -85,13 +84,13 @@
             ? SubmitRecord.Status.NOT_READY
             : SubmitRecord.Status.OK;
 
-    return ImmutableList.of(sr);
+    return Optional.of(sr);
   }
 
-  private static Collection<SubmitRecord> error(String errorMessage) {
+  private static Optional<SubmitRecord> error(String errorMessage) {
     SubmitRecord sr = new SubmitRecord();
     sr.status = SubmitRecord.Status.RULE_ERROR;
     sr.errorMessage = errorMessage;
-    return ImmutableList.of(sr);
+    return Optional.of(sr);
   }
 }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/simplesubmitrules/rules/NoUnresolvedCommentsRuleIT.java b/src/test/java/com/googlesource/gerrit/plugins/simplesubmitrules/rules/NoUnresolvedCommentsRuleIT.java
index 265b03a..087d747 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/simplesubmitrules/rules/NoUnresolvedCommentsRuleIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/simplesubmitrules/rules/NoUnresolvedCommentsRuleIT.java
@@ -15,6 +15,7 @@
 package com.googlesource.gerrit.plugins.simplesubmitrules.rules;
 
 import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth8.assertThat;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
@@ -27,7 +28,7 @@
 import com.google.gerrit.extensions.client.Side;
 import com.google.gerrit.server.query.change.ChangeData;
 import com.googlesource.gerrit.plugins.simplesubmitrules.SimpleSubmitRulesConfig;
-import java.util.Collection;
+import java.util.Optional;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -49,10 +50,10 @@
     comment.unresolved = true;
     PushOneCommit.Result r = createChangeWithComment(comment);
 
-    Collection<SubmitRecord> submitRecords = evaluate(r.getChange());
+    Optional<SubmitRecord> submitRecords = evaluate(r.getChange());
 
-    assertThat(submitRecords).hasSize(1);
-    SubmitRecord result = submitRecords.iterator().next();
+    assertThat(submitRecords).isPresent();
+    SubmitRecord result = submitRecords.get();
     assertThat(result.status).isEqualTo(SubmitRecord.Status.NOT_READY);
     assertThat(result.labels).isNull();
     assertThat(result.requirements).hasSize(1);
@@ -64,10 +65,10 @@
     comment.unresolved = false;
     PushOneCommit.Result r = createChangeWithComment(comment);
 
-    Collection<SubmitRecord> submitRecords = evaluate(r.getChange());
+    Optional<SubmitRecord> submitRecords = evaluate(r.getChange());
 
-    assertThat(submitRecords).hasSize(1);
-    SubmitRecord result = submitRecords.iterator().next();
+    assertThat(submitRecords).isPresent();
+    SubmitRecord result = submitRecords.get();
     assertThat(result.status).isEqualTo(SubmitRecord.Status.OK);
     assertThat(result.labels).isNull();
     assertThat(result.requirements).hasSize(1);
@@ -77,10 +78,10 @@
   public void doesNotBlockWithOnlyResolvedComments() throws Exception {
     PushOneCommit.Result change = createChange("refs/for/master");
 
-    Collection<SubmitRecord> submitRecords = evaluate(change.getChange());
+    Optional<SubmitRecord> submitRecords = evaluate(change.getChange());
 
-    assertThat(submitRecords).hasSize(1);
-    SubmitRecord result = submitRecords.iterator().next();
+    assertThat(submitRecords).isPresent();
+    SubmitRecord result = submitRecords.get();
     assertThat(result.status).isEqualTo(SubmitRecord.Status.OK);
     assertThat(result.labels).isNull();
     assertThat(result.requirements).hasSize(1);
@@ -95,7 +96,7 @@
 
     enableRule(false);
 
-    Collection<SubmitRecord> submitRecords = evaluate(r.getChange());
+    Optional<SubmitRecord> submitRecords = evaluate(r.getChange());
     assertThat(submitRecords).isEmpty();
   }
 
@@ -118,7 +119,7 @@
     }
   }
 
-  private Collection<SubmitRecord> evaluate(ChangeData cd) {
+  private Optional<SubmitRecord> evaluate(ChangeData cd) {
     NoUnresolvedCommentsRule rule =
         plugin.getSysInjector().getInstance(NoUnresolvedCommentsRule.class);