That is the common style and yields better diagnostics on failure.
Change-Id: I831a55615a812734af0912a5d6bbfd1edc75308e
PullResult res = target.pull().call();
// nothing to update since we don't have different data yet
assertTrue(res.getFetchResult().getTrackingRefUpdates().isEmpty());
- assertTrue(res.getRebaseResult().getStatus().equals(Status.UP_TO_DATE));
+ assertEquals(Status.UP_TO_DATE, res.getRebaseResult().getStatus());
assertFileContentsEqual(targetFile, "Hello world");
ConfigConstants.CONFIG_KEY_URL);
assertFalse(res.getFetchResult().getTrackingRefUpdates().isEmpty());
- assertTrue(res.getRebaseResult().getStatus().equals(Status.STOPPED));
+ assertEquals(Status.STOPPED, res.getRebaseResult().getStatus());
String result = "<<<<<<< Upstream, based on branch 'master' of "
+ remoteUri
+ "\nSource change\n=======\nTarget change\n>>>>>>> 42453fd Target change in local\n";
.call();
// check if HEAD points to initial commit now
ObjectId head = db.resolve(Constants.HEAD);
- assertTrue(head.equals(initialCommit));
+ assertEquals(initialCommit, head);
// check if files were removed
assertFalse(indexFile.exists());
assertTrue(untrackedFile.exists());
.call();
// check if HEAD points to initial commit now
ObjectId head = db.resolve(Constants.HEAD);
- assertTrue(head.equals(initialCommit));
+ assertEquals(initialCommit, head);
// check if files still exist
assertTrue(untrackedFile.exists());
assertTrue(indexFile.exists());
.call();
// check if HEAD points to initial commit now
ObjectId head = db.resolve(Constants.HEAD);
- assertTrue(head.equals(initialCommit));
+ assertEquals(initialCommit, head);
// check if files still exist
assertTrue(untrackedFile.exists());
assertTrue(indexFile.exists());
// check that HEAD hasn't moved
ObjectId head = db.resolve(Constants.HEAD);
- assertTrue(head.equals(secondCommit));
+ assertEquals(secondCommit, head);
// check if files still exist
assertTrue(untrackedFile.exists());
assertTrue(indexFile.exists());
// check that HEAD hasn't moved
ObjectId head = db.resolve(Constants.HEAD);
- assertTrue(head.equals(secondCommit));
+ assertEquals(secondCommit, head);
// check if files still exist
assertTrue(untrackedFile.exists());
assertTrue(inHead("dir/b.txt"));
// check that HEAD hasn't moved
ObjectId head = db.resolve(Constants.HEAD);
- assertTrue(head.equals(secondCommit));
+ assertEquals(secondCommit, head);
// check if files still exist
assertTrue(untrackedFile.exists());
assertTrue(indexFile.exists());
git.reset().setRef(tagName).setMode(HARD).call();
ObjectId head = db.resolve(Constants.HEAD);
- assertTrue(head.equals(secondCommit));
+ assertEquals(secondCommit, head);
}
@Test
assertEquals("content", read(committedFile));
validateStashedCommit(stashed);
- assertTrue(stashed.getTree().equals(stashed.getParent(1).getTree()));
+ assertEquals(stashed.getParent(1).getTree(), stashed.getTree());
List<DiffEntry> workingDiffs = diffWorkingAgainstHead(stashed);
assertEquals(1, workingDiffs.size());
validateStashedCommit(stashed);
- assertTrue(stashed.getTree().equals(stashed.getParent(1).getTree()));
+ assertEquals(stashed.getParent(1).getTree(), stashed.getTree());
List<DiffEntry> workingDiffs = diffWorkingAgainstHead(stashed);
assertEquals(1, workingDiffs.size());
assertTrue(l.isEmpty());
assertEquals("EditList[]", l.toString());
- assertTrue(l.equals(l));
- assertTrue(l.equals(new EditList()));
+ assertEquals(l, l);
+ assertEquals(new EditList(), l);
assertFalse(l.equals(""));
assertEquals(l.hashCode(), new EditList().hashCode());
}
assertSame(e, l.get(0));
assertSame(e, l.iterator().next());
- assertTrue(l.equals(l));
+ assertEquals(l, l);
assertFalse(l.equals(new EditList()));
final EditList l2 = new EditList();
l2.add(e);
- assertTrue(l.equals(l2));
- assertTrue(l2.equals(l));
+ assertEquals(l2, l);
+ assertEquals(l, l2);
assertEquals(l.hashCode(), l2.hashCode());
}
assertSame(e1, i.next());
assertSame(e2, i.next());
- assertTrue(l.equals(l));
+ assertEquals(l, l);
assertFalse(l.equals(new EditList()));
final EditList l2 = new EditList();
l2.add(e1);
l2.add(e2);
- assertTrue(l.equals(l2));
- assertTrue(l2.equals(l));
+ assertEquals(l2, l);
+ assertEquals(l, l2);
assertEquals(l.hashCode(), l2.hashCode());
}
final Edit e1 = new Edit(1, 2, 3, 4);
final Edit e2 = new Edit(1, 2, 3, 4);
- assertTrue(e1.equals(e1));
- assertTrue(e1.equals(e2));
- assertTrue(e2.equals(e1));
+ assertEquals(e1, e1);
+ assertEquals(e2, e1);
+ assertEquals(e1, e2);
assertEquals(e1.hashCode(), e2.hashCode());
assertFalse(e1.equals(""));
}
final AbbreviatedObjectId b = AbbreviatedObjectId.fromString(s);
assertNotSame(a, b);
assertTrue(a.hashCode() == b.hashCode());
- assertTrue(a.equals(b));
- assertTrue(b.equals(a));
+ assertEquals(b, a);
+ assertEquals(a, b);
}
@Test
final AbbreviatedObjectId b = AbbreviatedObjectId.fromString(s);
assertNotSame(a, b);
assertTrue(a.hashCode() == b.hashCode());
- assertTrue(a.equals(b));
- assertTrue(b.equals(a));
+ assertEquals(b, a);
+ assertEquals(a, b);
}
@Test
} catch (CheckoutConflictException e) {
assertIndex(mk("foo"));
assertWorkDir(mkmap("foo", "different"));
- assertTrue(getConflicts().equals(Arrays.asList("foo")));
+ assertEquals(Arrays.asList("foo"), getConflicts());
assertTrue(new File(trash, "foo").isFile());
}
}
final ObjectId a = ObjectId.fromString(x);
final ObjectId b = ObjectId.fromString(x);
assertEquals(a.hashCode(), b.hashCode());
- assertTrue("a and b are same", a.equals(b));
+ assertEquals("a and b are same", b, a);
}
@Test
git.rm().addFilepattern("d/1").call();
git.rm().addFilepattern("d").call();
MergeResult mergeRes = git.merge().include(masterCommit).call();
- assertTrue(MergeStatus.CONFLICTING.equals(mergeRes.getMergeStatus()));
+ assertEquals(MergeStatus.CONFLICTING, mergeRes.getMergeStatus());
assertEquals(
"[d/1, mode:100644, stage:1, content:orig][d/1, mode:100644, stage:2, content:side][d/1, mode:100644, stage:3, content:master]",
indexState(CONTENT));
git.rm().addFilepattern("d/1").call();
git.rm().addFilepattern("d").call();
MergeResult mergeRes = git.merge().include(masterCommit).call();
- assertTrue(MergeStatus.MERGED.equals(mergeRes.getMergeStatus()));
+ assertEquals(MergeStatus.MERGED, mergeRes.getMergeStatus());
assertEquals("[d/1, mode:100644, content:1master\n2\n3side\n]",
indexState(CONTENT));
}
git.rm().addFilepattern("d/1").call();
git.rm().addFilepattern("d").call();
MergeResult mergeRes = git.merge().include(masterCommit).call();
- assertTrue(MergeStatus.MERGED.equals(mergeRes.getMergeStatus()));
+ assertEquals(MergeStatus.MERGED, mergeRes.getMergeStatus());
assertEquals("[d/1, mode:100644, content:modified]",
indexState(CONTENT));
}
git.rm().addFilepattern("d/1").call();
git.rm().addFilepattern("d").call();
MergeResult mergeRes = git.merge().include(masterCommit).call();
- assertTrue(MergeStatus.MERGED.equals(mergeRes.getMergeStatus()));
+ assertEquals(MergeStatus.MERGED, mergeRes.getMergeStatus());
assertEquals(
"[2, mode:100644, content:orig][d/1, mode:100644, content:orig]",
indexState(CONTENT));
git.rm().addFilepattern("d/1").call();
git.rm().addFilepattern("d").call();
MergeResult mergeRes = git.merge().include(masterCommit).call();
- assertTrue(MergeStatus.CONFLICTING.equals(mergeRes.getMergeStatus()));
+ assertEquals(MergeStatus.CONFLICTING, mergeRes.getMergeStatus());
assertEquals(
"[2, mode:100644, content:orig][d/1, mode:100644, stage:2, content:side][d/1, mode:100644, stage:3, content:master]",
indexState(CONTENT));
assertTrue(set.add(flag1));
assertTrue(set.add(flag2));
- assertTrue(new RevFlagSet(set).equals(set));
+ assertEquals(set, new RevFlagSet(set));
assertTrue(new RevFlagSet(Arrays.asList(new RevFlag[] { flag1, flag2 }))
.equals(set));
}
ObjectId rb = db.resolve("refs/heads/b");
writeSymref(Constants.HEAD, "refs/heads/b");
ObjectId oldHead = db.resolve(Constants.HEAD);
- assertTrue("internal test condition, b == HEAD", rb.equals(oldHead));
+ assertEquals("internal test condition, b == HEAD", oldHead, rb);
writeReflog(db, rb, "Just a message", "refs/heads/b");
assertTrue("log on old branch", new File(db.getDirectory(),
"logs/refs/heads/b").exists());
updateRef.setRefLogMessage("Setup", false);
assertEquals(Result.FAST_FORWARD, updateRef.update());
ObjectId oldHead = db.resolve(Constants.HEAD);
- assertTrue(rb.equals(oldHead)); // assumption for this test
+ assertEquals(oldHead, rb); // assumption for this test
writeReflog(db, rb, "Just a message", "refs/heads/a");
assertTrue("internal check, we have a log", new File(db.getDirectory(),
"logs/refs/heads/a").exists());
updateRef.setForceUpdate(true);
assertEquals(Result.FORCED, updateRef.update());
ObjectId oldHead = db.resolve(Constants.HEAD);
- assertTrue(rb.equals(oldHead)); // assumption for this test
+ assertEquals(oldHead, rb); // assumption for this test
writeReflog(db, rb, "Just a message", "refs/heads/prefix/a");
assertTrue("internal check, we have a log", new File(db.getDirectory(),
"logs/refs/heads/prefix/a").exists());
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
init("0008NAK\n");
assertSame(PacketLineIn.AckNackResult.NAK, in.readACK(actid));
- assertTrue(actid.equals(expid));
+ assertEquals(expid, actid);
assertEOF();
}
init("0031ACK fcfcfb1fd94829c1a1704f894fc111d14770d34e\n");
assertSame(PacketLineIn.AckNackResult.ACK, in.readACK(actid));
- assertTrue(actid.equals(expid));
+ assertEquals(expid, actid);
assertEOF();
}
init("003aACK fcfcfb1fd94829c1a1704f894fc111d14770d34e continue\n");
assertSame(PacketLineIn.AckNackResult.ACK_CONTINUE, in.readACK(actid));
- assertTrue(actid.equals(expid));
+ assertEquals(expid, actid);
assertEOF();
}
init("0038ACK fcfcfb1fd94829c1a1704f894fc111d14770d34e common\n");
assertSame(PacketLineIn.AckNackResult.ACK_COMMON, in.readACK(actid));
- assertTrue(actid.equals(expid));
+ assertEquals(expid, actid);
assertEOF();
}
init("0037ACK fcfcfb1fd94829c1a1704f894fc111d14770d34e ready\n");
assertSame(PacketLineIn.AckNackResult.ACK_READY, in.readACK(actid));
- assertTrue(actid.equals(expid));
+ assertEquals(expid, actid);
assertEOF();
}
Map.Entry<String, Ref> ent_b = itr.next();
assertEquals(ent_a.hashCode(), "A".hashCode());
- assertTrue(ent_a.equals(ent_a));
+ assertEquals(ent_a, ent_a);
assertFalse(ent_a.equals(ent_b));
assertEquals(a.toString(), ent_a.toString());