diff options
author | Terry Parker <tparker@google.com> | 2016-08-02 09:30:40 -0700 |
---|---|---|
committer | Terry Parker <tparker@google.com> | 2016-08-04 14:59:05 -0700 |
commit | 9843489cb88d7c7cee09ced484c2fbc84ec1e3ef (patch) | |
tree | 9c5656ca95cbcc388fa66631ce1d65d5ab021068 /org.eclipse.jgit.test | |
parent | 23b1405484eb8dea10d1a6870b28e865d04d9f63 (diff) | |
download | jgit-9843489cb88d7c7cee09ced484c2fbc84ec1e3ef.tar.gz jgit-9843489cb88d7c7cee09ced484c2fbc84ec1e3ef.zip |
PackWriterTest: Improve readability
Add wants() and haves() static utility functions to improve readability.
Change-Id: I4d44e17a9af97c0203e2ebe112eabb1f67d272a6
Signed-off-by: Terry Parker <tparker@google.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java index 63a3072859..5afb3eac0d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java @@ -75,6 +75,7 @@ import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectIdSet; import org.eclipse.jgit.lib.ObjectInserter; +import org.eclipse.jgit.lib.Sets; import org.eclipse.jgit.revwalk.RevBlob; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevObject; @@ -92,6 +93,9 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { private static final List<RevObject> EMPTY_LIST_REVS = Collections .<RevObject> emptyList(); + private static final Set<ObjectIdSet> EMPTY_ID_SET = Collections + .<ObjectIdSet> emptySet(); + private PackConfig config; private PackWriter writer; @@ -202,8 +206,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { final ObjectId nonExisting = ObjectId .fromString("0000000000000000000000000000000000000001"); try { - createVerifyOpenPack(NONE, Collections.singleton(nonExisting), - false, false); + createVerifyOpenPack(NONE, haves(nonExisting), false, false); fail("Should have thrown MissingObjectException"); } catch (MissingObjectException x) { // expected @@ -219,8 +222,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { public void testIgnoreNonExistingObjects() throws IOException { final ObjectId nonExisting = ObjectId .fromString("0000000000000000000000000000000000000001"); - createVerifyOpenPack(NONE, Collections.singleton(nonExisting), - false, true); + createVerifyOpenPack(NONE, haves(nonExisting), false, true); // shouldn't throw anything } @@ -238,8 +240,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { final ObjectId nonExisting = ObjectId .fromString("0000000000000000000000000000000000000001"); new GC(db).gc(); - createVerifyOpenPack(NONE, Collections.singleton(nonExisting), false, - true, true); + createVerifyOpenPack(NONE, haves(nonExisting), false, true, true); // shouldn't throw anything } @@ -516,8 +517,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { RevBlob contentA = testRepo.blob("A"); RevCommit c1 = bb.commit().add("f", contentA).create(); testRepo.getRevWalk().parseHeaders(c1); - PackIndex pf1 = writePack(repo, Collections.singleton(c1), - Collections.<ObjectIdSet> emptySet()); + PackIndex pf1 = writePack(repo, wants(c1), EMPTY_ID_SET); assertContent( pf1, Arrays.asList(c1.getId(), c1.getTree().getId(), @@ -525,8 +525,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { RevBlob contentB = testRepo.blob("B"); RevCommit c2 = bb.commit().add("f", contentB).create(); testRepo.getRevWalk().parseHeaders(c2); - PackIndex pf2 = writePack(repo, Collections.singleton(c2), - Collections.<ObjectIdSet> singleton(pf1)); + PackIndex pf2 = writePack(repo, wants(c2), Sets.of((ObjectIdSet) pf1)); assertContent( pf2, Arrays.asList(c2.getId(), c2.getTree().getId(), @@ -730,4 +729,12 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { assertEquals(objectsOrder[i++].toObjectId(), me.toObjectId()); } } + + private static Set<ObjectId> haves(ObjectId... objects) { + return Sets.of(objects); + } + + private static Set<ObjectId> wants(ObjectId... objects) { + return Sets.of(objects); + } } |