]> source.dussan.org Git - jgit.git/commitdiff
cleanup: Prefer assertEquals over assertTrue(....equals(...)) 66/7566/4
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Mon, 3 Sep 2012 20:29:44 +0000 (22:29 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 3 Sep 2012 20:37:57 +0000 (22:37 +0200)
That is the common style and yields better diagnostics on failure.

Change-Id: I831a55615a812734af0912a5d6bbfd1edc75308e

13 files changed:
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashCreateCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/EditListTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/EditTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/AbbreviatedObjectIdTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectIdTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevFlagSetTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RefUpdateTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PacketLineInTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefMapTest.java

index 1686ce1fa4ae8da9e0b52a2b3ec54124b531d292..2c1eb768bd7d326e80b91efe1cb9494ed39b86d9 100644 (file)
@@ -149,7 +149,7 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase {
                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");
 
@@ -172,7 +172,7 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase {
                                                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";
index c55775c9fe1103651c77fc2ef3db955b29d33ded..8f2e54388bd2235a4cc599724ea6cca87d4830ff 100644 (file)
@@ -141,7 +141,7 @@ public class ResetCommandTest extends RepositoryTestCase {
                                .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());
@@ -178,7 +178,7 @@ public class ResetCommandTest extends RepositoryTestCase {
                                .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());
@@ -199,7 +199,7 @@ public class ResetCommandTest extends RepositoryTestCase {
                                .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());
@@ -277,7 +277,7 @@ public class ResetCommandTest extends RepositoryTestCase {
 
                // 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());
@@ -306,7 +306,7 @@ public class ResetCommandTest extends RepositoryTestCase {
 
                // 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"));
@@ -332,7 +332,7 @@ public class ResetCommandTest extends RepositoryTestCase {
 
                // 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());
@@ -357,7 +357,7 @@ public class ResetCommandTest extends RepositoryTestCase {
                git.reset().setRef(tagName).setMode(HARD).call();
 
                ObjectId head = db.resolve(Constants.HEAD);
-               assertTrue(head.equals(secondCommit));
+               assertEquals(secondCommit, head);
        }
 
        @Test
index 16fadef153a4aa376743cce0cbc257fed64b4cc9..2b01b60cb2647beb979f62863ebe5aaf27cbfb0d 100644 (file)
@@ -291,7 +291,7 @@ public class StashCreateCommandTest extends RepositoryTestCase {
                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());
@@ -326,7 +326,7 @@ public class StashCreateCommandTest extends RepositoryTestCase {
 
                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());
index 30f32098a4550f4743f17557145f6c0b15ef4a5c..d6a5dcde2bfd6b5697ed3eea30fc14a3f7dff294 100644 (file)
@@ -60,8 +60,8 @@ public class EditListTest {
                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());
        }
@@ -76,13 +76,13 @@ public class EditListTest {
                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());
        }
 
@@ -101,14 +101,14 @@ public class EditListTest {
                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());
        }
 
index a9cb2fbdd81ddab9840c1a7110dacd08d6ed2267..1a0c39ebfe5aefa58991084aa60c4f4124418816 100644 (file)
@@ -130,9 +130,9 @@ public class EditTest {
                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(""));
        }
index fc53f95b9cc7feafa0564002a0202c0e0d22236e..6529d9ed574432328bd7dd83ea02ed836d8a59b0 100644 (file)
@@ -221,8 +221,8 @@ public class AbbreviatedObjectIdTest {
                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
@@ -232,8 +232,8 @@ public class AbbreviatedObjectIdTest {
                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
index 23647f06d745968c374303fd24b4f0ff360d4599..3142995f29896bfe35fa28fb79d38bfc52b8df14 100644 (file)
@@ -935,7 +935,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase {
                } 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());
                }
        }
index cdcb4332252124c1352281d093dec485a55a377d..abf57d6cd3e8c375fa8fa7aba71ea48a1cb4dee8 100644 (file)
@@ -72,7 +72,7 @@ public class ObjectIdTest {
                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
index 9876100ec02db55b4017b73f31c8578e8a9ee158..30e046ea5109f5922f2402c9de4952c2910a913a 100644 (file)
@@ -131,7 +131,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
                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));
@@ -163,7 +163,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
                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));
        }
@@ -194,7 +194,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
                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));
        }
@@ -260,7 +260,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
                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));
@@ -294,7 +294,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
                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));
index 021795eef48f388a7e7c9424b0a3758561957beb..95860d63f6c0de1ab0a78848b666e2d1befe1b9e 100644 (file)
@@ -120,7 +120,7 @@ public class RevFlagSetTest extends RevWalkTestCase {
                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));
        }
index cbdf23641ec67cae219113025921b036ca3347d4..e92bca6d5df826638874166a56840dff49f759d2 100644 (file)
@@ -639,7 +639,7 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase {
                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());
@@ -804,7 +804,7 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase {
                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());
@@ -838,7 +838,7 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase {
                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());
index 6f930d737dd2d0256bd8af0e16ecaa63aad53e68..13fc68d8c874684a97de1c470d2760010909bf78 100644 (file)
@@ -46,7 +46,6 @@ package org.eclipse.jgit.transport;
 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;
@@ -221,7 +220,7 @@ public class PacketLineInTest {
 
                init("0008NAK\n");
                assertSame(PacketLineIn.AckNackResult.NAK, in.readACK(actid));
-               assertTrue(actid.equals(expid));
+               assertEquals(expid, actid);
                assertEOF();
        }
 
@@ -233,7 +232,7 @@ public class PacketLineInTest {
 
                init("0031ACK fcfcfb1fd94829c1a1704f894fc111d14770d34e\n");
                assertSame(PacketLineIn.AckNackResult.ACK, in.readACK(actid));
-               assertTrue(actid.equals(expid));
+               assertEquals(expid, actid);
                assertEOF();
        }
 
@@ -245,7 +244,7 @@ public class PacketLineInTest {
 
                init("003aACK fcfcfb1fd94829c1a1704f894fc111d14770d34e continue\n");
                assertSame(PacketLineIn.AckNackResult.ACK_CONTINUE, in.readACK(actid));
-               assertTrue(actid.equals(expid));
+               assertEquals(expid, actid);
                assertEOF();
        }
 
@@ -257,7 +256,7 @@ public class PacketLineInTest {
 
                init("0038ACK fcfcfb1fd94829c1a1704f894fc111d14770d34e common\n");
                assertSame(PacketLineIn.AckNackResult.ACK_COMMON, in.readACK(actid));
-               assertTrue(actid.equals(expid));
+               assertEquals(expid, actid);
                assertEOF();
        }
 
@@ -269,7 +268,7 @@ public class PacketLineInTest {
 
                init("0037ACK fcfcfb1fd94829c1a1704f894fc111d14770d34e ready\n");
                assertSame(PacketLineIn.AckNackResult.ACK_READY, in.readACK(actid));
-               assertTrue(actid.equals(expid));
+               assertEquals(expid, actid);
                assertEOF();
        }
 
index 40790a5b465c3b1e909c41fbbbfc07c08bdf4224..b43fe48be56791010edd4d75f8944eb863f7ff49 100644 (file)
@@ -454,7 +454,7 @@ public class RefMapTest {
                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());