From 91979f93fab46c3a5fada6ad384b5b94c1ab3d10 Mon Sep 17 00:00:00 2001 From: Jonathan Tan Date: Mon, 21 Oct 2019 17:26:22 -0700 Subject: 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 --- .../eclipse/jgit/revwalk/TreeRevFilterTest.java | 24 +++++++--------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'org.eclipse.jgit.test') 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); -- cgit v1.2.3