Add tests for ChangeNotesParser parse failures

Change-Id: I895b75bb502c2057aea0eb24c6b43c721efda7b9
This commit is contained in:
Dave Borowitz
2014-08-12 15:32:22 -07:00
parent 6d1b56e545
commit 3e377a1a40
4 changed files with 234 additions and 7 deletions

View File

@@ -15,9 +15,7 @@
package com.google.gerrit.server.notedb;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.GERRIT_PLACEHOLDER_HOST;
import com.google.gerrit.common.data.AccountInfo;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
@@ -171,10 +169,8 @@ public abstract class AbstractChangeUpdate extends VersionedMetaData {
}
protected PersonIdent newIdent(Account author, Date when) {
return new PersonIdent(
new AccountInfo(author).getName(anonymousCowardName),
author.getId().get() + "@" + GERRIT_PLACEHOLDER_HOST,
when, serverIdent.getTimeZone());
return ChangeNoteUtil.newIdent(author, when, serverIdent,
anonymousCowardName);
}
/**

View File

@@ -14,11 +14,16 @@
package com.google.gerrit.server.notedb;
import com.google.gerrit.common.data.AccountInfo;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.RefNames;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.revwalk.FooterKey;
import java.util.Date;
public class ChangeNoteUtil {
static final String GERRIT_PLACEHOLDER_HOST = "gerrit";
@@ -43,6 +48,14 @@ public class ChangeNoteUtil {
return r.toString();
}
static PersonIdent newIdent(Account author, Date when,
PersonIdent serverIdent, String anonymousCowardName) {
return new PersonIdent(
new AccountInfo(author).getName(anonymousCowardName),
author.getId().get() + "@" + GERRIT_PLACEHOLDER_HOST,
when, serverIdent.getTimeZone());
}
private ChangeNoteUtil() {
}
}