diff options
author | Jonathan Tan <jonathantanmy@google.com> | 2019-10-21 17:26:22 -0700 |
---|---|---|
committer | Jonathan Tan <jonathantanmy@google.com> | 2019-10-22 10:13:54 -0700 |
commit | 91979f93fab46c3a5fada6ad384b5b94c1ab3d10 (patch) | |
tree | e84633a48823b2b81c21c18929b94ef30cf2f119 /org.eclipse.jgit.test | |
parent | b138f169458e254cd5d8cb768b447e24273741b5 (diff) | |
download | jgit-91979f93fab46c3a5fada6ad384b5b94c1ab3d10.tar.gz jgit-91979f93fab46c3a5fada6ad384b5b94c1ab3d10.zip |
TreeRevFilterTest: Simplify filter used
TreeRevFilterTest uses an unncessarily complicated TreeFilter - an
AndTreeFilter - when it should be as simple as possible because this
class tests TreeRevFilter, not AndTreeFilter. Replace the filter with a
simpler one.
Change-Id: I3256a65f6e0042d32fd76a9224b79a835674ff3a
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/TreeRevFilterTest.java | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/TreeRevFilterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/TreeRevFilterTest.java index 9548992a2b..a345459b3b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/TreeRevFilterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/TreeRevFilterTest.java @@ -46,25 +46,15 @@ package org.eclipse.jgit.revwalk; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import java.util.Collections; - import org.eclipse.jgit.revwalk.filter.OrRevFilter; import org.eclipse.jgit.revwalk.filter.RevFilter; import org.eclipse.jgit.revwalk.filter.SkipRevFilter; -import org.eclipse.jgit.treewalk.filter.AndTreeFilter; -import org.eclipse.jgit.treewalk.filter.PathFilterGroup; import org.eclipse.jgit.treewalk.filter.TreeFilter; import org.junit.Test; public class TreeRevFilterTest extends RevWalkTestCase { - private RevFilter treeRevFilter(String path) { - return new TreeRevFilter(rw, treeFilter(path)); - } - - private static TreeFilter treeFilter(String path) { - return AndTreeFilter.create( - PathFilterGroup.createFromStrings(Collections.singleton(path)), - TreeFilter.ANY_DIFF); + private RevFilter treeRevFilter() { + return new TreeRevFilter(rw, TreeFilter.ANY_DIFF); } @Test @@ -73,7 +63,7 @@ public class TreeRevFilterTest extends RevWalkTestCase { RevCommit a = commit(tree(file("d/f", blob("a")))); RevCommit b = commit(tree(file("d/f", blob("a"))), a); RevCommit c = commit(tree(file("d/f", blob("b"))), b); - rw.setRevFilter(treeRevFilter("d/f")); + rw.setRevFilter(treeRevFilter()); markStart(c); assertCommit(c, rw.next()); @@ -91,7 +81,7 @@ public class TreeRevFilterTest extends RevWalkTestCase { RevCommit b = commit(tree(file("d/f", blob("a"))), a); RevCommit c = commit(tree(file("d/f", blob("b"))), b); RevCommit d = commit(tree(file("d/f", blob("b"))), c); - rw.setRevFilter(treeRevFilter("d/f")); + rw.setRevFilter(treeRevFilter()); markStart(d); // d was skipped @@ -111,7 +101,7 @@ public class TreeRevFilterTest extends RevWalkTestCase { RevCommit b = commit(tree(file("d/f", blob("a"))), a); RevCommit c = commit(tree(file("d/f", blob("b"))), b); RevCommit d = commit(tree(file("d/f", blob("b"))), c); - rw.setRevFilter(treeRevFilter("d")); + rw.setRevFilter(treeRevFilter()); markStart(d); // d was skipped @@ -136,7 +126,7 @@ public class TreeRevFilterTest extends RevWalkTestCase { RevCommit g = commit(tree(file("d/f", blob("b"))), f); RevCommit h = commit(tree(file("d/f", blob("b"))), g); RevCommit i = commit(tree(file("d/f", blob("c"))), h); - rw.setRevFilter(treeRevFilter("d/f")); + rw.setRevFilter(treeRevFilter()); markStart(i); assertCommit(i, rw.next()); @@ -156,7 +146,7 @@ public class TreeRevFilterTest extends RevWalkTestCase { @Test public void testPathFilterOrOtherFilter() throws Exception { - RevFilter pathFilter = treeRevFilter("d/f"); + RevFilter pathFilter = treeRevFilter(); RevFilter skipFilter = SkipRevFilter.create(1); RevFilter orFilter = OrRevFilter.create(skipFilter, pathFilter); |