Format user names in created bugzilla comments

As AccountAttribute does not provide a String conversion method, the
generated bugzilla comments ended in:
  ... [by com.google.gerrit.server.events.AccountAttribute@5b9b8858]
Now they end in:
  ... [by John Doe]

Change-Id: I702b83ba14ec0fd14471420e461de4d26c80baf7
diff --git a/hooks-its/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddComment.java b/hooks-its/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddComment.java
index 36fffd0..5d178a9 100644
--- a/hooks-its/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddComment.java
+++ b/hooks-its/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddComment.java
@@ -16,6 +16,8 @@
 
 import java.io.IOException;
 
+import com.google.common.base.Strings;
+import com.google.gerrit.server.config.AnonymousCowardName;
 import com.google.gerrit.server.events.AccountAttribute;
 import com.google.gerrit.server.events.ApprovalAttribute;
 import com.google.gerrit.server.events.ChangeAbandonedEvent;
@@ -32,6 +34,9 @@
   @Inject
   private ItsFacade its;
 
+  @Inject @AnonymousCowardName
+  private String anonymousCowardName;
+
   @Override
   public void doFilter(CommentAddedEvent hook) throws IOException {
     String comment = getComment(hook);
@@ -60,8 +65,16 @@
     return getChangeIdUrl(change) + " | ";
   }
 
+  private String formatAccountAttribute(AccountAttribute who) {
+    if (who != null && !Strings.isNullOrEmpty(who.name)) {
+      return who.name;
+    }
+    return anonymousCowardName;
+  }
+
   private String getComment(ChangeAttribute change, ChangeEvent hook, AccountAttribute who, String what) {
-    return getCommentPrefix(change) + "change " + what + " [by " + who + "]";
+    return getCommentPrefix(change) + "change " + what + " [by "
+        + formatAccountAttribute(who) + "]";
   }
 
   private String getComment(ChangeRestoredEvent hook) {
@@ -96,7 +109,7 @@
     }
 
     comment.append(commentAdded.comment + " ");
-    comment.append("[by " + commentAdded.author + "]");
+    comment.append("[by " + formatAccountAttribute(commentAdded.author) + "]");
     return comment.toString();
   }