Convert ChangeNotes tests to Truth

Change-Id: Iccf749da8bfb347e48b28f525f5b75fe1073cb3d
This commit is contained in:
Dave Borowitz
2015-04-29 14:22:31 -07:00
parent b37f9bec74
commit 0ddecca16c
2 changed files with 215 additions and 262 deletions

View File

@@ -14,14 +14,11 @@
package com.google.gerrit.server.notedb; package com.google.gerrit.server.notedb;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.server.notedb.ReviewerState.CC; import static com.google.gerrit.server.notedb.ReviewerState.CC;
import static com.google.gerrit.server.notedb.ReviewerState.REVIEWER; import static com.google.gerrit.server.notedb.ReviewerState.REVIEWER;
import static com.google.gerrit.testutil.TestChanges.incrementPatchSet; import static com.google.gerrit.testutil.TestChanges.incrementPatchSet;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
@@ -71,22 +68,23 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertEquals(1, notes.getApprovals().keySet().size()); assertThat(notes.getApprovals().keySet())
.containsExactly(c.currentPatchSetId());
List<PatchSetApproval> psas = List<PatchSetApproval> psas =
notes.getApprovals().get(c.currentPatchSetId()); notes.getApprovals().get(c.currentPatchSetId());
assertEquals(2, psas.size()); assertThat(psas).hasSize(2);
assertEquals(c.currentPatchSetId(), psas.get(0).getPatchSetId()); assertThat(psas.get(0).getPatchSetId()).isEqualTo(c.currentPatchSetId());
assertEquals(1, psas.get(0).getAccountId().get()); assertThat(psas.get(0).getAccountId().get()).isEqualTo(1);
assertEquals("Code-Review", psas.get(0).getLabel()); assertThat(psas.get(0).getLabel()).isEqualTo("Code-Review");
assertEquals((short) -1, psas.get(0).getValue()); assertThat(psas.get(0).getValue()).isEqualTo((short) -1);
assertEquals(truncate(after(c, 1000)), psas.get(0).getGranted()); assertThat(psas.get(0).getGranted()).isEqualTo(truncate(after(c, 1000)));
assertEquals(c.currentPatchSetId(), psas.get(1).getPatchSetId()); assertThat(psas.get(1).getPatchSetId()).isEqualTo(c.currentPatchSetId());
assertEquals(1, psas.get(1).getAccountId().get()); assertThat(psas.get(1).getAccountId().get()).isEqualTo(1);
assertEquals("Verified", psas.get(1).getLabel()); assertThat(psas.get(1).getLabel()).isEqualTo("Verified");
assertEquals((short) 1, psas.get(1).getValue()); assertThat(psas.get(1).getValue()).isEqualTo((short) 1);
assertEquals(psas.get(0).getGranted(), psas.get(1).getGranted()); assertThat(psas.get(1).getGranted()).isEqualTo(psas.get(0).getGranted());
} }
@Test @Test
@@ -105,21 +103,21 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
ListMultimap<PatchSet.Id, PatchSetApproval> psas = notes.getApprovals(); ListMultimap<PatchSet.Id, PatchSetApproval> psas = notes.getApprovals();
assertEquals(2, notes.getApprovals().keySet().size()); assertThat(psas).hasSize(2);
PatchSetApproval psa1 = Iterables.getOnlyElement(psas.get(ps1)); PatchSetApproval psa1 = Iterables.getOnlyElement(psas.get(ps1));
assertEquals(ps1, psa1.getPatchSetId()); assertThat(psa1.getPatchSetId()).isEqualTo(ps1);
assertEquals(1, psa1.getAccountId().get()); assertThat(psa1.getAccountId().get()).isEqualTo(1);
assertEquals("Code-Review", psa1.getLabel()); assertThat(psa1.getLabel()).isEqualTo("Code-Review");
assertEquals((short) -1, psa1.getValue()); assertThat(psa1.getValue()).isEqualTo((short) -1);
assertEquals(truncate(after(c, 1000)), psa1.getGranted()); assertThat(psa1.getGranted()).isEqualTo(truncate(after(c, 1000)));
PatchSetApproval psa2 = Iterables.getOnlyElement(psas.get(ps2)); PatchSetApproval psa2 = Iterables.getOnlyElement(psas.get(ps2));
assertEquals(ps2, psa2.getPatchSetId()); assertThat(psa2.getPatchSetId()).isEqualTo(ps2);
assertEquals(1, psa2.getAccountId().get()); assertThat(psa2.getAccountId().get()).isEqualTo(1);
assertEquals("Code-Review", psa2.getLabel()); assertThat(psa2.getLabel()).isEqualTo("Code-Review");
assertEquals((short) +1, psa2.getValue()); assertThat(psa2.getValue()).isEqualTo((short) +1);
assertEquals(truncate(after(c, 2000)), psa2.getGranted()); assertThat(psa2.getGranted()).isEqualTo(truncate(after(c, 2000)));
} }
@Test @Test
@@ -132,8 +130,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
PatchSetApproval psa = Iterables.getOnlyElement( PatchSetApproval psa = Iterables.getOnlyElement(
notes.getApprovals().get(c.currentPatchSetId())); notes.getApprovals().get(c.currentPatchSetId()));
assertEquals("Code-Review", psa.getLabel()); assertThat(psa.getLabel()).isEqualTo("Code-Review");
assertEquals((short) -1, psa.getValue()); assertThat(psa.getValue()).isEqualTo((short) -1);
update = newUpdate(c, changeOwner); update = newUpdate(c, changeOwner);
update.putApproval("Code-Review", (short) 1); update.putApproval("Code-Review", (short) 1);
@@ -142,8 +140,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
notes = newNotes(c); notes = newNotes(c);
psa = Iterables.getOnlyElement( psa = Iterables.getOnlyElement(
notes.getApprovals().get(c.currentPatchSetId())); notes.getApprovals().get(c.currentPatchSetId()));
assertEquals("Code-Review", psa.getLabel()); assertThat(psa.getLabel()).isEqualTo("Code-Review");
assertEquals((short) 1, psa.getValue()); assertThat(psa.getValue()).isEqualTo((short) 1);
} }
@Test @Test
@@ -158,22 +156,23 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertEquals(1, notes.getApprovals().keySet().size()); assertThat(notes.getApprovals().keySet())
.containsExactly(c.currentPatchSetId());
List<PatchSetApproval> psas = List<PatchSetApproval> psas =
notes.getApprovals().get(c.currentPatchSetId()); notes.getApprovals().get(c.currentPatchSetId());
assertEquals(2, psas.size()); assertThat(psas).hasSize(2);
assertEquals(c.currentPatchSetId(), psas.get(0).getPatchSetId()); assertThat(psas.get(0).getPatchSetId()).isEqualTo(c.currentPatchSetId());
assertEquals(1, psas.get(0).getAccountId().get()); assertThat(psas.get(0).getAccountId().get()).isEqualTo(1);
assertEquals("Code-Review", psas.get(0).getLabel()); assertThat(psas.get(0).getLabel()).isEqualTo("Code-Review");
assertEquals((short) -1, psas.get(0).getValue()); assertThat(psas.get(0).getValue()).isEqualTo((short) -1);
assertEquals(truncate(after(c, 1000)), psas.get(0).getGranted()); assertThat(psas.get(0).getGranted()).isEqualTo(truncate(after(c, 1000)));
assertEquals(c.currentPatchSetId(), psas.get(1).getPatchSetId()); assertThat(psas.get(1).getPatchSetId()).isEqualTo(c.currentPatchSetId());
assertEquals(2, psas.get(1).getAccountId().get()); assertThat(psas.get(1).getAccountId().get()).isEqualTo(2);
assertEquals("Code-Review", psas.get(1).getLabel()); assertThat(psas.get(1).getLabel()).isEqualTo("Code-Review");
assertEquals((short) 1, psas.get(1).getValue()); assertThat(psas.get(1).getValue()).isEqualTo((short) 1);
assertEquals(truncate(after(c, 2000)), psas.get(1).getGranted()); assertThat(psas.get(1).getGranted()).isEqualTo(truncate(after(c, 2000)));
} }
@Test @Test
@@ -186,16 +185,16 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
PatchSetApproval psa = Iterables.getOnlyElement( PatchSetApproval psa = Iterables.getOnlyElement(
notes.getApprovals().get(c.currentPatchSetId())); notes.getApprovals().get(c.currentPatchSetId()));
assertEquals(1, psa.getAccountId().get()); assertThat(psa.getAccountId().get()).isEqualTo(1);
assertEquals("Not-For-Long", psa.getLabel()); assertThat(psa.getLabel()).isEqualTo("Not-For-Long");
assertEquals((short) 1, psa.getValue()); assertThat(psa.getValue()).isEqualTo((short) 1);
update = newUpdate(c, changeOwner); update = newUpdate(c, changeOwner);
update.removeApproval("Not-For-Long"); update.removeApproval("Not-For-Long");
update.commit(); update.commit();
notes = newNotes(c); notes = newNotes(c);
assertTrue(notes.getApprovals().isEmpty()); assertThat(notes.getApprovals()).isEmpty();
} }
@Test @Test
@@ -207,10 +206,10 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertEquals(ImmutableSetMultimap.of( assertThat(notes.getReviewers()).isEqualTo(
ImmutableSetMultimap.of(
REVIEWER, new Account.Id(1), REVIEWER, new Account.Id(1),
REVIEWER, new Account.Id(2)), REVIEWER, new Account.Id(2)));
notes.getReviewers());
} }
@Test @Test
@@ -222,10 +221,10 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertEquals(ImmutableSetMultimap.of( assertThat(notes.getReviewers()).isEqualTo(
REVIEWER, new Account.Id(1), ImmutableSetMultimap.of(
CC, new Account.Id(2)), REVIEWER, new Account.Id(1),
notes.getReviewers()); CC, new Account.Id(2)));
} }
@Test @Test
@@ -236,18 +235,16 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertEquals(ImmutableSetMultimap.of( assertThat(notes.getReviewers()).isEqualTo(
REVIEWER, new Account.Id(2)), ImmutableSetMultimap.of(REVIEWER, new Account.Id(2)));
notes.getReviewers());
update = newUpdate(c, otherUser); update = newUpdate(c, otherUser);
update.putReviewer(otherUser.getAccount().getId(), CC); update.putReviewer(otherUser.getAccount().getId(), CC);
update.commit(); update.commit();
notes = newNotes(c); notes = newNotes(c);
assertEquals(ImmutableSetMultimap.of( assertThat(notes.getReviewers()).isEqualTo(
CC, new Account.Id(2)), ImmutableSetMultimap.of(CC, new Account.Id(2)));
notes.getReviewers());
} }
@Test @Test
@@ -268,9 +265,11 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
List<PatchSetApproval> psas = List<PatchSetApproval> psas =
notes.getApprovals().get(c.currentPatchSetId()); notes.getApprovals().get(c.currentPatchSetId());
assertEquals(2, psas.size()); assertThat(psas).hasSize(2);
assertEquals(changeOwner.getAccount().getId(), psas.get(0).getAccountId()); assertThat(psas.get(0).getAccountId())
assertEquals(otherUser.getAccount().getId(), psas.get(1).getAccountId()); .isEqualTo(changeOwner.getAccount().getId());
assertThat(psas.get(1).getAccountId())
.isEqualTo(otherUser.getAccount().getId());
update = newUpdate(c, changeOwner); update = newUpdate(c, changeOwner);
update.removeReviewer(otherUser.getAccount().getId()); update.removeReviewer(otherUser.getAccount().getId());
@@ -278,8 +277,9 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
notes = newNotes(c); notes = newNotes(c);
psas = notes.getApprovals().get(c.currentPatchSetId()); psas = notes.getApprovals().get(c.currentPatchSetId());
assertEquals(1, psas.size()); assertThat(psas).hasSize(1);
assertEquals(changeOwner.getAccount().getId(), psas.get(0).getAccountId()); assertThat(psas.get(0).getAccountId())
.isEqualTo(changeOwner.getAccount().getId());
} }
@Test @Test
@@ -299,13 +299,15 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
List<SubmitRecord> recs = notes.getSubmitRecords(); List<SubmitRecord> recs = notes.getSubmitRecords();
assertEquals(2, recs.size()); assertThat(recs).hasSize(2);
assertEquals(submitRecord("NOT_READY", null, assertThat(recs.get(0)).isEqualTo(
submitLabel("Verified", "OK", changeOwner.getAccountId()), submitRecord("NOT_READY", null,
submitLabel("Code-Review", "NEED", null)), recs.get(0)); submitLabel("Verified", "OK", changeOwner.getAccountId()),
assertEquals(submitRecord("NOT_READY", null, submitLabel("Code-Review", "NEED", null)));
submitLabel("Verified", "OK", changeOwner.getAccountId()), assertThat(recs.get(1)).isEqualTo(
submitLabel("Alternative-Code-Review", "NEED", null)), recs.get(1)); submitRecord("NOT_READY", null,
submitLabel("Verified", "OK", changeOwner.getAccountId()),
submitLabel("Alternative-Code-Review", "NEED", null)));
} }
@Test @Test
@@ -327,16 +329,16 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertEquals(submitRecord("OK", null, assertThat(notes.getSubmitRecords()).containsExactly(
submitLabel("Code-Review", "OK", changeOwner.getAccountId())), submitRecord("OK", null,
Iterables.getOnlyElement(notes.getSubmitRecords())); submitLabel("Code-Review", "OK", changeOwner.getAccountId())));
} }
@Test @Test
public void emptyChangeUpdate() throws Exception { public void emptyChangeUpdate() throws Exception {
ChangeUpdate update = newUpdate(newChange(), changeOwner); ChangeUpdate update = newUpdate(newChange(), changeOwner);
update.commit(); update.commit();
assertNull(update.getRevision()); assertThat(update.getRevision()).isNull();
} }
@Test @Test
@@ -351,7 +353,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
try (RevWalk walk = new RevWalk(repo)) { try (RevWalk walk = new RevWalk(repo)) {
RevCommit commit = walk.parseCommit(update.getRevision()); RevCommit commit = walk.parseCommit(update.getRevision());
walk.parseBody(commit); walk.parseBody(commit);
assertTrue(commit.getFullMessage().endsWith("Hashtags: tag1,tag2\n")); assertThat(commit.getFullMessage()).endsWith("Hashtags: tag1,tag2\n");
} }
} }
@@ -366,7 +368,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertEquals(hashtags, notes.getHashtags()); assertThat(notes.getHashtags()).isEqualTo(hashtags);
} }
@Test @Test
@@ -374,7 +376,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeUpdate update = newUpdate(newChange(), changeOwner); ChangeUpdate update = newUpdate(newChange(), changeOwner);
update.setSubject("Create change"); update.setSubject("Create change");
update.commit(); update.commit();
assertNotNull(update.getRevision()); assertThat(update.getRevision()).isNotNull();
} }
@Test @Test
@@ -398,15 +400,17 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
List<PatchSetApproval> psas = List<PatchSetApproval> psas =
notes.getApprovals().get(c.currentPatchSetId()); notes.getApprovals().get(c.currentPatchSetId());
assertEquals(2, psas.size()); assertThat(psas).hasSize(2);
assertEquals(changeOwner.getAccount().getId(), psas.get(0).getAccountId()); assertThat(psas.get(0).getAccountId())
assertEquals("Verified", psas.get(0).getLabel()); .isEqualTo(changeOwner.getAccount().getId());
assertEquals((short) 1, psas.get(0).getValue()); assertThat(psas.get(0).getLabel()).isEqualTo("Verified");
assertThat(psas.get(0).getValue()).isEqualTo((short) 1);
assertEquals(otherUser.getAccount().getId(), psas.get(1).getAccountId()); assertThat(psas.get(1).getAccountId())
assertEquals("Code-Review", psas.get(1).getLabel()); .isEqualTo(otherUser.getAccount().getId());
assertEquals((short) 2, psas.get(1).getValue()); assertThat(psas.get(1).getLabel()).isEqualTo("Code-Review");
assertThat(psas.get(1).getValue()).isEqualTo((short) 2);
} }
@Test @Test
@@ -437,17 +441,17 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
ObjectId tip = notes.getRevision(); ObjectId tip = notes.getRevision();
RevCommit commitWithApprovals = rw.parseCommit(tip); RevCommit commitWithApprovals = rw.parseCommit(tip);
assertNotNull(commitWithApprovals); assertThat(commitWithApprovals).isNotNull();
RevCommit commitWithComments = commitWithApprovals.getParent(0); RevCommit commitWithComments = commitWithApprovals.getParent(0);
assertNotNull(commitWithComments); assertThat(commitWithComments).isNotNull();
ChangeNotesParser notesWithComments = ChangeNotesParser notesWithComments =
new ChangeNotesParser(c, commitWithComments.copy(), rw, repoManager); new ChangeNotesParser(c, commitWithComments.copy(), rw, repoManager);
notesWithComments.parseAll(); notesWithComments.parseAll();
ImmutableListMultimap<PatchSet.Id, PatchSetApproval> approvals1 = ImmutableListMultimap<PatchSet.Id, PatchSetApproval> approvals1 =
notesWithComments.buildApprovals(); notesWithComments.buildApprovals();
assertEquals(0, approvals1.size()); assertThat(approvals1).isEmpty();
assertEquals(1, notesWithComments.commentsForBase.size()); assertThat(notesWithComments.commentsForBase).hasSize(1);
notesWithComments.close(); notesWithComments.close();
ChangeNotesParser notesWithApprovals = ChangeNotesParser notesWithApprovals =
@@ -455,8 +459,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
notesWithApprovals.parseAll(); notesWithApprovals.parseAll();
ImmutableListMultimap<PatchSet.Id, PatchSetApproval> approvals2 = ImmutableListMultimap<PatchSet.Id, PatchSetApproval> approvals2 =
notesWithApprovals.buildApprovals(); notesWithApprovals.buildApprovals();
assertEquals(1, approvals2.size()); assertThat(approvals2).hasSize(1);
assertEquals(1, notesWithApprovals.commentsForBase.size()); assertThat(notesWithApprovals.commentsForBase).hasSize(1);
notesWithApprovals.close(); notesWithApprovals.close();
} finally { } finally {
batch.close(); batch.close();
@@ -481,12 +485,12 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
batch1 = update1.openUpdateInBatch(bru); batch1 = update1.openUpdateInBatch(bru);
batch1.write(update1, new CommitBuilder()); batch1.write(update1, new CommitBuilder());
batch1.commit(); batch1.commit();
assertNull(repo.getRef(update1.getRefName())); assertThat(repo.getRef(update1.getRefName())).isNull();
batch2 = update2.openUpdateInBatch(bru); batch2 = update2.openUpdateInBatch(bru);
batch2.write(update2, new CommitBuilder()); batch2.write(update2, new CommitBuilder());
batch2.commit(); batch2.commit();
assertNull(repo.getRef(update2.getRefName())); assertThat(repo.getRef(update2.getRefName())).isNull();
} finally { } finally {
if (batch1 != null) { if (batch1 != null) {
batch1.close(); batch1.close();
@@ -497,19 +501,19 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
} }
List<ReceiveCommand> cmds = bru.getCommands(); List<ReceiveCommand> cmds = bru.getCommands();
assertEquals(2, cmds.size()); assertThat(cmds).hasSize(2);
assertEquals(update1.getRefName(), cmds.get(0).getRefName()); assertThat(cmds.get(0).getRefName()).isEqualTo(update1.getRefName());
assertEquals(update2.getRefName(), cmds.get(1).getRefName()); assertThat(cmds.get(1).getRefName()).isEqualTo(update2.getRefName());
try (RevWalk rw = new RevWalk(repo)) { try (RevWalk rw = new RevWalk(repo)) {
bru.execute(rw, NullProgressMonitor.INSTANCE); bru.execute(rw, NullProgressMonitor.INSTANCE);
} }
assertEquals(ReceiveCommand.Result.OK, cmds.get(0).getResult()); assertThat(cmds.get(0).getResult()).isEqualTo(ReceiveCommand.Result.OK);
assertEquals(ReceiveCommand.Result.OK, cmds.get(1).getResult()); assertThat(cmds.get(1).getResult()).isEqualTo(ReceiveCommand.Result.OK);
assertNotNull(repo.getRef(update1.getRefName())); assertThat(repo.getRef(update1.getRefName())).isNotNull();
assertNotNull(repo.getRef(update2.getRefName())); assertThat(repo.getRef(update2.getRefName())).isNotNull();
} }
@Test @Test
@@ -524,14 +528,12 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
ListMultimap<PatchSet.Id, ChangeMessage> changeMessages = ListMultimap<PatchSet.Id, ChangeMessage> changeMessages =
notes.getChangeMessages(); notes.getChangeMessages();
assertEquals(1, changeMessages.keySet().size()); assertThat(changeMessages.keySet()).containsExactly(ps1);
ChangeMessage cm = Iterables.getOnlyElement(changeMessages.get(ps1)); ChangeMessage cm = Iterables.getOnlyElement(changeMessages.get(ps1));
assertEquals("Just a little code change.\n", assertThat(cm.getMessage()).isEqualTo("Just a little code change.\n");
cm.getMessage()); assertThat(cm.getAuthor()).isEqualTo(changeOwner.getAccount().getId());
assertEquals(changeOwner.getAccount().getId(), assertThat(cm.getPatchSetId()).isEqualTo(ps1);
cm.getAuthor());
assertEquals(ps1, cm.getPatchSetId());
} }
@Test @Test
@@ -542,9 +544,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
ListMultimap<PatchSet.Id, ChangeMessage> changeMessages = assertThat(notes.getChangeMessages()).isEmpty();
notes.getChangeMessages();
assertEquals(0, changeMessages.keySet().size());
} }
@Test @Test
@@ -559,11 +559,11 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
ListMultimap<PatchSet.Id, ChangeMessage> changeMessages = ListMultimap<PatchSet.Id, ChangeMessage> changeMessages =
notes.getChangeMessages(); notes.getChangeMessages();
assertEquals(1, changeMessages.keySet().size()); assertThat(changeMessages).hasSize(1);
ChangeMessage cm1 = Iterables.getOnlyElement(changeMessages.get(ps1)); ChangeMessage cm1 = Iterables.getOnlyElement(changeMessages.get(ps1));
assertEquals("Testing trailing double newline\n" + "\n", cm1.getMessage()); assertThat(cm1.getMessage()).isEqualTo("Testing trailing double newline\n" + "\n");
assertEquals(changeOwner.getAccount().getId(), cm1.getAuthor()); assertThat(cm1.getAuthor()).isEqualTo(changeOwner.getAccount().getId());
} }
@Test @Test
@@ -581,15 +581,15 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
ListMultimap<PatchSet.Id, ChangeMessage> changeMessages = ListMultimap<PatchSet.Id, ChangeMessage> changeMessages =
notes.getChangeMessages(); notes.getChangeMessages();
assertEquals(1, changeMessages.keySet().size()); assertThat(changeMessages).hasSize(1);
ChangeMessage cm1 = Iterables.getOnlyElement(changeMessages.get(ps1)); ChangeMessage cm1 = Iterables.getOnlyElement(changeMessages.get(ps1));
assertEquals("Testing paragraph 1\n" assertThat(cm1.getMessage()).isEqualTo("Testing paragraph 1\n"
+ "\n" + "\n"
+ "Testing paragraph 2\n" + "Testing paragraph 2\n"
+ "\n" + "\n"
+ "Testing paragraph 3", cm1.getMessage()); + "Testing paragraph 3");
assertEquals(changeOwner.getAccount().getId(), cm1.getAuthor()); assertThat(cm1.getAuthor()).isEqualTo(changeOwner.getAccount().getId());
} }
@Test @Test
@@ -611,20 +611,19 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
ListMultimap<PatchSet.Id, ChangeMessage> changeMessages = ListMultimap<PatchSet.Id, ChangeMessage> changeMessages =
notes.getChangeMessages(); notes.getChangeMessages();
assertEquals(2, changeMessages.keySet().size()); assertThat(changeMessages).hasSize(2);
ChangeMessage cm1 = Iterables.getOnlyElement(changeMessages.get(ps1)); ChangeMessage cm1 = Iterables.getOnlyElement(changeMessages.get(ps1));
assertEquals("This is the change message for the first PS.", assertThat(cm1.getMessage())
cm1.getMessage()); .isEqualTo("This is the change message for the first PS.");
assertEquals(changeOwner.getAccount().getId(), assertThat(cm1.getAuthor()).isEqualTo(changeOwner.getAccount().getId());
cm1.getAuthor());
ChangeMessage cm2 = Iterables.getOnlyElement(changeMessages.get(ps2)); ChangeMessage cm2 = Iterables.getOnlyElement(changeMessages.get(ps2));
assertEquals(ps1, cm1.getPatchSetId()); assertThat(cm1.getPatchSetId()).isEqualTo(ps1);
assertEquals("This is the change message for the second PS.", assertThat(cm2.getMessage())
cm2.getMessage()); .isEqualTo("This is the change message for the second PS.");
assertEquals(changeOwner.getAccount().getId(), cm2.getAuthor()); assertThat(cm2.getAuthor()).isEqualTo(changeOwner.getAccount().getId());
assertEquals(ps2, cm2.getPatchSetId()); assertThat(cm2.getPatchSetId()).isEqualTo(ps2);
} }
@Test @Test
@@ -645,20 +644,18 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
ListMultimap<PatchSet.Id, ChangeMessage> changeMessages = ListMultimap<PatchSet.Id, ChangeMessage> changeMessages =
notes.getChangeMessages(); notes.getChangeMessages();
assertEquals(1, changeMessages.keySet().size()); assertThat(changeMessages.keySet()).hasSize(1);
List<ChangeMessage> cm = changeMessages.get(ps1); List<ChangeMessage> cm = changeMessages.get(ps1);
assertEquals(2, cm.size()); assertThat(cm).hasSize(2);
assertEquals("First change message.\n", assertThat(cm.get(0).getMessage()).isEqualTo("First change message.\n");
cm.get(0).getMessage()); assertThat(cm.get(0).getAuthor())
assertEquals(changeOwner.getAccount().getId(), .isEqualTo(changeOwner.getAccount().getId());
cm.get(0).getAuthor()); assertThat(cm.get(0).getPatchSetId()).isEqualTo(ps1);
assertEquals(ps1, cm.get(0).getPatchSetId()); assertThat(cm.get(1).getMessage()).isEqualTo("Second change message.\n");
assertEquals("Second change message.\n", assertThat(cm.get(1).getAuthor())
cm.get(1).getMessage()); .isEqualTo(changeOwner.getAccount().getId());
assertEquals(changeOwner.getAccount().getId(), assertThat(cm.get(1).getPatchSetId()).isEqualTo(ps1);
cm.get(1).getAuthor());
assertEquals(ps1, cm.get(1).getPatchSetId());
} }
@Test @Test
@@ -713,7 +710,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
walk.getObjectReader().open( walk.getObjectReader().open(
note.getData(), Constants.OBJ_BLOB).getBytes(); note.getData(), Constants.OBJ_BLOB).getBytes();
String noteString = new String(bytes, UTF_8); String noteString = new String(bytes, UTF_8);
assertEquals("Patch-set: 1\n" assertThat(noteString).isEqualTo("Patch-set: 1\n"
+ "Revision: abcd1234abcd1234abcd1234abcd1234abcd1234\n" + "Revision: abcd1234abcd1234abcd1234abcd1234abcd1234\n"
+ "File: file1\n" + "File: file1\n"
+ "\n" + "\n"
@@ -739,8 +736,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
+ "UUID: uuid3\n" + "UUID: uuid3\n"
+ "Bytes: 9\n" + "Bytes: 9\n"
+ "comment 3\n" + "comment 3\n"
+ "\n", + "\n");
noteString);
} }
} }
@@ -784,7 +780,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
walk.getObjectReader().open( walk.getObjectReader().open(
note.getData(), Constants.OBJ_BLOB).getBytes(); note.getData(), Constants.OBJ_BLOB).getBytes();
String noteString = new String(bytes, UTF_8); String noteString = new String(bytes, UTF_8);
assertEquals("Base-for-patch-set: 1\n" assertThat(noteString).isEqualTo("Base-for-patch-set: 1\n"
+ "Revision: abcd1234abcd1234abcd1234abcd1234abcd1234\n" + "Revision: abcd1234abcd1234abcd1234abcd1234abcd1234\n"
+ "File: file1\n" + "File: file1\n"
+ "\n" + "\n"
@@ -801,8 +797,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
+ "UUID: uuid2\n" + "UUID: uuid2\n"
+ "Bytes: 9\n" + "Bytes: 9\n"
+ "comment 2\n" + "comment 2\n"
+ "\n", + "\n");
noteString);
} }
} }
@@ -841,13 +836,11 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
notes.getBaseComments(); notes.getBaseComments();
Multimap<PatchSet.Id, PatchLineComment> commentsForPS = Multimap<PatchSet.Id, PatchLineComment> commentsForPS =
notes.getPatchSetComments(); notes.getPatchSetComments();
assertEquals(commentsForBase.size(), 1); assertThat(commentsForBase).hasSize(1);
assertEquals(commentsForPS.size(), 1); assertThat(commentsForPS).hasSize(1);
assertEquals(commentForBase, assertThat(commentsForBase.get(psId)).containsExactly(commentForBase);
Iterables.getOnlyElement(commentsForBase.get(psId))); assertThat(commentsForPS.get(psId)).containsExactly(commentForPS);
assertEquals(commentForPS,
Iterables.getOnlyElement(commentsForPS.get(psId)));
} }
@Test @Test
@@ -883,17 +876,11 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
notes.getBaseComments(); notes.getBaseComments();
Multimap<PatchSet.Id, PatchLineComment> commentsForPS = Multimap<PatchSet.Id, PatchLineComment> commentsForPS =
notes.getPatchSetComments(); notes.getPatchSetComments();
assertEquals(commentsForBase.size(), 0); assertThat(commentsForBase).isEmpty();
assertEquals(commentsForPS.size(), 2); assertThat(commentsForPS).hasSize(2);
ImmutableList<PatchLineComment> commentsForThisPS = assertThat(commentsForPS.get(psId))
(ImmutableList<PatchLineComment>) commentsForPS.get(psId); .containsExactly(comment1, comment2).inOrder();
assertEquals(commentsForThisPS.size(), 2);
PatchLineComment commentFromNotes1 = commentsForThisPS.get(0);
PatchLineComment commentFromNotes2 = commentsForThisPS.get(1);
assertEquals(comment1, commentFromNotes1);
assertEquals(comment2, commentFromNotes2);
} }
@Test @Test
@@ -925,21 +912,15 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
Multimap<PatchSet.Id, PatchLineComment> commentsForBase = ListMultimap<PatchSet.Id, PatchLineComment> commentsForBase =
notes.getBaseComments(); notes.getBaseComments();
Multimap<PatchSet.Id, PatchLineComment> commentsForPS = ListMultimap<PatchSet.Id, PatchLineComment> commentsForPS =
notes.getPatchSetComments(); notes.getPatchSetComments();
assertEquals(commentsForBase.size(), 0); assertThat(commentsForBase).isEmpty();
assertEquals(commentsForPS.size(), 2); assertThat(commentsForPS).hasSize(2);
ImmutableList<PatchLineComment> commentsForThisPS = assertThat(commentsForPS.get(psId))
(ImmutableList<PatchLineComment>) commentsForPS.get(psId); .containsExactly(comment1, comment2).inOrder();
assertEquals(commentsForThisPS.size(), 2);
PatchLineComment commentFromNotes1 = commentsForThisPS.get(0);
PatchLineComment commentFromNotes2 = commentsForThisPS.get(1);
assertEquals(comment1, commentFromNotes1);
assertEquals(comment2, commentFromNotes2);
} }
@Test @Test
@@ -977,19 +958,13 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
LinkedListMultimap.create(notes.getBaseComments()); LinkedListMultimap.create(notes.getBaseComments());
LinkedListMultimap<PatchSet.Id, PatchLineComment> commentsForPS = LinkedListMultimap<PatchSet.Id, PatchLineComment> commentsForPS =
LinkedListMultimap.create(notes.getPatchSetComments()); LinkedListMultimap.create(notes.getPatchSetComments());
assertEquals(commentsForBase.keys().size(), 0); assertThat(commentsForBase).isEmpty();
assertEquals(commentsForPS.values().size(), 2); assertThat(commentsForPS).hasSize(2);
List<PatchLineComment> commentsForPS1 = commentsForPS.get(ps1); assertThat(commentsForPS).containsExactly(
assertEquals(commentsForPS1.size(), 1); ImmutableListMultimap.of(
PatchLineComment commentFromPs1 = commentsForPS1.get(0); ps1, comment1,
ps2, comment2));
List<PatchLineComment> commentsForPS2 = commentsForPS.get(ps2);
assertEquals(commentsForPS2.size(), 1);
PatchLineComment commentFromPs2 = commentsForPS2.get(0);
assertEquals(comment1, commentFromPs1);
assertEquals(comment2, commentFromPs2);
} }
@Test @Test
@@ -1011,8 +986,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertEquals(1, notes.getDraftPsComments(otherUserId).values().size()); assertThat(notes.getDraftPsComments(otherUserId)).hasSize(1);
assertEquals(0, notes.getDraftBaseComments(otherUserId).values().size()); assertThat(notes.getDraftBaseComments(otherUserId)).isEmpty();
comment1.setStatus(Status.PUBLISHED); comment1.setStatus(Status.PUBLISHED);
update = newUpdate(c, otherUser); update = newUpdate(c, otherUser);
@@ -1022,13 +997,11 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
notes = newNotes(c); notes = newNotes(c);
assertTrue(notes.getDraftPsComments(otherUserId).values().isEmpty()); assertThat(notes.getDraftPsComments(otherUserId).values()).isEmpty();
assertTrue(notes.getDraftBaseComments(otherUserId).values().isEmpty()); assertThat(notes.getDraftBaseComments(otherUserId).values()).isEmpty();
assertTrue(notes.getBaseComments().values().isEmpty()); assertThat(notes.getBaseComments()).isEmpty();
PatchLineComment commentFromNotes = assertThat(notes.getPatchSetComments().values()).containsExactly(comment1);
Iterables.getOnlyElement(notes.getPatchSetComments().values());
assertEquals(comment1, commentFromNotes);
} }
@Test @Test
@@ -1059,11 +1032,10 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertTrue(notes.getDraftBaseComments(otherUserId).values().isEmpty()); assertThat(notes.getDraftBaseComments(otherUserId)).isEmpty();
assertEquals(2, notes.getDraftPsComments(otherUserId).values().size());
assertTrue(notes.getDraftPsComments(otherUserId).containsValue(comment1)); assertThat(notes.getDraftPsComments(otherUserId).values())
assertTrue(notes.getDraftPsComments(otherUserId).containsValue(comment2)); .containsExactly(comment1, comment2);
// Publish first draft. // Publish first draft.
update = newUpdate(c, otherUser); update = newUpdate(c, otherUser);
@@ -1073,14 +1045,12 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
notes = newNotes(c); notes = newNotes(c);
assertEquals(comment1, assertThat(notes.getPatchSetComments().get(psId)).containsExactly(comment1);
Iterables.getOnlyElement(notes.getPatchSetComments().get(psId))); assertThat(notes.getDraftPsComments(otherUserId).values())
assertEquals(comment2, .containsExactly(comment2);
Iterables.getOnlyElement(
notes.getDraftPsComments(otherUserId).values()));
assertTrue(notes.getBaseComments().values().isEmpty()); assertThat(notes.getBaseComments()).isEmpty();
assertTrue(notes.getDraftBaseComments(otherUserId).values().isEmpty()); assertThat(notes.getDraftBaseComments(otherUserId)).isEmpty();
} }
@Test @Test
@@ -1112,15 +1082,10 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
PatchLineComment baseDraftCommentFromNotes = assertThat(notes.getDraftBaseComments(otherUserId).values())
Iterables.getOnlyElement( .containsExactly(baseComment);
notes.getDraftBaseComments(otherUserId).values()); assertThat(notes.getDraftPsComments(otherUserId).values())
PatchLineComment psDraftCommentFromNotes = .containsExactly(psComment);
Iterables.getOnlyElement(
notes.getDraftPsComments(otherUserId).values());
assertEquals(baseComment, baseDraftCommentFromNotes);
assertEquals(psComment, psDraftCommentFromNotes);
// Publish both comments. // Publish both comments.
update = newUpdate(c, otherUser); update = newUpdate(c, otherUser);
@@ -1134,16 +1099,12 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
notes = newNotes(c); notes = newNotes(c);
PatchLineComment baseCommentFromNotes = assertThat(notes.getBaseComments().get(psId)).containsExactly(baseComment);
Iterables.getOnlyElement(notes.getBaseComments().values()); assertThat(notes.getPatchSetComments().get(psId))
PatchLineComment psCommentFromNotes = .containsExactly(psComment);
Iterables.getOnlyElement(notes.getPatchSetComments().values());
assertEquals(baseComment, baseCommentFromNotes); assertThat(notes.getDraftBaseComments(otherUserId)).isEmpty();
assertEquals(psComment, psCommentFromNotes); assertThat(notes.getDraftPsComments(otherUserId)).isEmpty();
assertTrue(notes.getDraftBaseComments(otherUserId).values().isEmpty());
assertTrue(notes.getDraftPsComments(otherUserId).values().isEmpty());
} }
@Test @Test
@@ -1164,14 +1125,9 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
Multimap<PatchSet.Id, PatchLineComment> commentsForBase = assertThat(notes.getPatchSetComments()).isEmpty();
notes.getBaseComments(); assertThat(notes.getBaseComments().get(psId))
Multimap<PatchSet.Id, PatchLineComment> commentsForPs = .containsExactly(commentForBase);
notes.getPatchSetComments();
assertTrue(commentsForPs.isEmpty());
assertEquals(commentForBase,
Iterables.getOnlyElement(commentsForBase.get(psId)));
} }
@Test @Test
@@ -1192,13 +1148,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
Multimap<PatchSet.Id, PatchLineComment> commentsForBase = assertThat(notes.getPatchSetComments()).isEmpty();
notes.getBaseComments(); assertThat(notes.getBaseComments().get(psId))
Multimap<PatchSet.Id, PatchLineComment> commentsForPs = .containsExactly(commentForBase);
notes.getPatchSetComments();
assertTrue(commentsForPs.isEmpty());
assertEquals(commentForBase,
Iterables.getOnlyElement(commentsForBase.get(psId)));
} }
} }

View File

@@ -14,9 +14,9 @@
package com.google.gerrit.server.notedb; package com.google.gerrit.server.notedb;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.server.notedb.ReviewerState.CC; import static com.google.gerrit.server.notedb.ReviewerState.CC;
import static com.google.gerrit.server.notedb.ReviewerState.REVIEWER; import static com.google.gerrit.server.notedb.ReviewerState.REVIEWER;
import static org.junit.Assert.assertEquals;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
@@ -43,7 +43,7 @@ public class CommitMessageOutputTest extends AbstractChangeNotesTest {
update.putReviewer(changeOwner.getAccount().getId(), REVIEWER); update.putReviewer(changeOwner.getAccount().getId(), REVIEWER);
update.putReviewer(otherUser.getAccount().getId(), CC); update.putReviewer(otherUser.getAccount().getId(), CC);
update.commit(); update.commit();
assertEquals("refs/changes/01/1/meta", update.getRefName()); assertThat(update.getRefName()).isEqualTo("refs/changes/01/1/meta");
RevCommit commit = parseCommit(update.getRevision()); RevCommit commit = parseCommit(update.getRevision());
assertBodyEquals("Update patch set 1\n" assertBodyEquals("Update patch set 1\n"
@@ -56,17 +56,18 @@ public class CommitMessageOutputTest extends AbstractChangeNotesTest {
commit); commit);
PersonIdent author = commit.getAuthorIdent(); PersonIdent author = commit.getAuthorIdent();
assertEquals("Change Owner", author.getName()); assertThat(author.getName()).isEqualTo("Change Owner");
assertEquals("1@gerrit", author.getEmailAddress()); assertThat(author.getEmailAddress()).isEqualTo("1@gerrit");
assertEquals(new Date(c.getCreatedOn().getTime() + 1000), assertThat(author.getWhen())
author.getWhen()); .isEqualTo(new Date(c.getCreatedOn().getTime() + 1000));
assertEquals(TimeZone.getTimeZone("GMT-7:00"), author.getTimeZone()); assertThat(author.getTimeZone())
.isEqualTo(TimeZone.getTimeZone("GMT-7:00"));
PersonIdent committer = commit.getCommitterIdent(); PersonIdent committer = commit.getCommitterIdent();
assertEquals("Gerrit Server", committer.getName()); assertThat(committer.getName()).isEqualTo("Gerrit Server");
assertEquals("noreply@gerrit.com", committer.getEmailAddress()); assertThat(committer.getEmailAddress()).isEqualTo("noreply@gerrit.com");
assertEquals(author.getWhen(), committer.getWhen()); assertThat(committer.getWhen()).isEqualTo(author.getWhen());
assertEquals(author.getTimeZone(), committer.getTimeZone()); assertThat(committer.getTimeZone()).isEqualTo(author.getTimeZone());
} }
@Test @Test
@@ -76,7 +77,7 @@ public class CommitMessageOutputTest extends AbstractChangeNotesTest {
update.setChangeMessage("Just a little code change.\n" update.setChangeMessage("Just a little code change.\n"
+ "How about a new line"); + "How about a new line");
update.commit(); update.commit();
assertEquals("refs/changes/01/1/meta", update.getRefName()); assertThat(update.getRefName()).isEqualTo("refs/changes/01/1/meta");
assertBodyEquals("Update patch set 1\n" assertBodyEquals("Update patch set 1\n"
+ "\n" + "\n"
@@ -130,17 +131,18 @@ public class CommitMessageOutputTest extends AbstractChangeNotesTest {
commit); commit);
PersonIdent author = commit.getAuthorIdent(); PersonIdent author = commit.getAuthorIdent();
assertEquals("Change Owner", author.getName()); assertThat(author.getName()).isEqualTo("Change Owner");
assertEquals("1@gerrit", author.getEmailAddress()); assertThat(author.getEmailAddress()).isEqualTo("1@gerrit");
assertEquals(new Date(c.getCreatedOn().getTime() + 1000), assertThat(author.getWhen())
author.getWhen()); .isEqualTo(new Date(c.getCreatedOn().getTime() + 1000));
assertEquals(TimeZone.getTimeZone("GMT-7:00"), author.getTimeZone()); assertThat(author.getTimeZone())
.isEqualTo(TimeZone.getTimeZone("GMT-7:00"));
PersonIdent committer = commit.getCommitterIdent(); PersonIdent committer = commit.getCommitterIdent();
assertEquals("Gerrit Server", committer.getName()); assertThat(committer.getName()).isEqualTo("Gerrit Server");
assertEquals("noreply@gerrit.com", committer.getEmailAddress()); assertThat(committer.getEmailAddress()).isEqualTo("noreply@gerrit.com");
assertEquals(author.getWhen(), committer.getWhen()); assertThat(committer.getWhen()).isEqualTo(author.getWhen());
assertEquals(author.getTimeZone(), committer.getTimeZone()); assertThat(committer.getTimeZone()).isEqualTo(author.getTimeZone());
} }
@Test @Test
@@ -161,8 +163,8 @@ public class CommitMessageOutputTest extends AbstractChangeNotesTest {
commit); commit);
PersonIdent author = commit.getAuthorIdent(); PersonIdent author = commit.getAuthorIdent();
assertEquals("Anonymous Coward (3)", author.getName()); assertThat(author.getName()).isEqualTo("Anonymous Coward (3)");
assertEquals("3@gerrit", author.getEmailAddress()); assertThat(author.getEmailAddress()).isEqualTo("3@gerrit");
} }
@Test @Test
@@ -252,6 +254,6 @@ public class CommitMessageOutputTest extends AbstractChangeNotesTest {
private void assertBodyEquals(String expected, ObjectId commitId) private void assertBodyEquals(String expected, ObjectId commitId)
throws Exception { throws Exception {
RevCommit commit = parseCommit(commitId); RevCommit commit = parseCommit(commitId);
assertEquals(expected, commit.getFullMessage()); assertThat(commit.getFullMessage()).isEqualTo(expected);
} }
} }