Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
272,600
void (boolean rootVisible, Consumer<? super JTree> consumer) { test(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION, rootVisible, consumer); test(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION, rootVisible, consumer); }
test
272,601
void (int selectionMode, boolean rootVisible, Consumer<? super JTree> consumer) { @SuppressWarnings("UndesirableClassUsage") JTree tree = new JTree(new DefaultTreeModel(root())); TreeTestUtil.assertTreeUI(tree); tree.getSelectionModel().setSelectionMode(selectionMode); tree.setRootVisible(rootVisible); expandAll(tree); waitForTestOnEDT(() -> { tree.collapseRow(normalize(tree, 5)); tree.clearSelection(); assertTree(tree, """ -Root -Color Red Green Blue +Digit -Letter -Greek Alpha Beta Gamma Delta Epsilon """); consumer.accept(tree); }); }
test
272,602
void (JTree tree) { Assert.assertFalse("unexpected thread", isDispatchThread()); try { // the following method expands nodes on EDT, // so in this case we should pause the main thread promiseExpandAll(tree).blockingGet(10000); } catch (Exception exception) { throw new AssertionError(exception); } }
expandAll
272,603
void () { Object root = new Object(); TreePath parent = TreePathUtil.createTreePath(null, root); Assert.assertNotNull(parent); Assert.assertNull(parent.getParentPath()); Assert.assertSame(root, parent.getLastPathComponent()); Object node = new Object(); TreePath path = TreePathUtil.createTreePath(parent, node); Assert.assertNotNull(path); Assert.assertNotNull(path.getParentPath()); Assert.assertNotSame(path, parent); Assert.assertSame(parent, path.getParentPath()); Assert.assertSame(node, path.getLastPathComponent()); }
createTreePath
272,604
void () { String[] strings = TreePathUtil.convertTreePathToStrings(new TreePath(new Object[]{2, 1, 0})); Assert.assertNotNull(strings); Assert.assertEquals(3, strings.length); Assert.assertEquals("2", strings[0]); Assert.assertEquals("1", strings[1]); Assert.assertEquals("0", strings[2]); }
convertTreePathToStrings
272,605
void () { Assert.assertNull(TreePathUtil.convertTreePathToArray(new TreePath(new Object[]{2, 1, 0}), component -> null)); }
convertTreePathToArrayWrongConverter
272,606
void () { Assert.assertNull(TreePathUtil.convertTreePathToArray(new TreePath() { })); }
convertTreePathToArrayWrongPathCount
272,607
void () { Assert.assertNull(TreePathUtil.convertTreePathToArray(new TreePath(new Object[]{2, 1, 0}) { @Override public Object getLastPathComponent() { return null; } })); }
convertTreePathToArrayWrongPathComponent
272,608
Object () { return null; }
getLastPathComponent
272,609
void () { convertTreePathToArrayDeep(1); convertTreePathToArrayDeep(10); convertTreePathToArrayDeep(100); convertTreePathToArrayDeep(1000); convertTreePathToArrayDeep(10000); convertTreePathToArrayDeep(100000); convertTreePathToArrayDeep(1000000); }
convertTreePathToArrayDeep
272,610
void (int count) { TreePath path = null; for (int i = 0; i < count; i++) path = TreePathUtil.createTreePath(path, i); Assert.assertEquals(count, path.getPathCount()); Assert.assertEquals(count - 1, path.getLastPathComponent()); Object[] array = TreePathUtil.convertTreePathToArray(path); Assert.assertEquals(count, array.length); try { Assert.assertArrayEquals(array, path.getPath()); } catch (StackOverflowError error) { System.out.println("StackOverflow - getPath: " + count); } }
convertTreePathToArrayDeep
272,611
void () { assertTreePath210(TreePathUtil.convertCollectionToTreePath(asList("2", "1", "0"))); }
convertCollectionToTreePath
272,612
void () { assertTreePath210(TreePathUtil.convertCollectionToTreePath(asList(2, 1, 0), Object::toString)); }
convertCollectionToTreePathConverter
272,613
void () { assertTreePath210(TreePathUtil.convertArrayToTreePath("2", "1", "0")); }
convertArrayToTreePath
272,614
void () { assertTreePath210(TreePathUtil.convertArrayToTreePath(new Object[]{2, 1, 0}, Object::toString)); }
convertArrayToTreePathConverter
272,615
void (TreePath path) { Assert.assertNotNull(path); Assert.assertEquals("0", path.getLastPathComponent()); Assert.assertNotNull(path.getParentPath()); Assert.assertEquals("1", path.getParentPath().getLastPathComponent()); Assert.assertNotNull(path.getParentPath().getParentPath()); Assert.assertEquals("2", path.getParentPath().getParentPath().getLastPathComponent()); Assert.assertNull(path.getParentPath().getParentPath().getParentPath()); }
assertTreePath210
272,616
void () { Assert.assertNull(TreePathUtil.convertArrayToTreePath()); }
convertArrayToTreePathEmptyArray
272,617
void () { Assert.assertNull(TreePathUtil.convertArrayToTreePath("2", null, "0")); }
convertArrayToTreePathWrongComponent
272,618
void () { Assert.assertNull(TreePathUtil.convertArrayToTreePath(new String[]{"2", "1", "0"}, component -> null)); }
convertArrayToTreePathWrongConverter
272,619
void () { convertArrayToTreePathDeep(1); convertArrayToTreePathDeep(10); convertArrayToTreePathDeep(100); convertArrayToTreePathDeep(1000); convertArrayToTreePathDeep(10000); convertArrayToTreePathDeep(100000); convertArrayToTreePathDeep(1000000); }
convertArrayToTreePathDeep
272,620
void (int count) { Object[] array = new Object[count]; for (int i = 0; i < count; i++) array[i] = i; TreePath path = TreePathUtil.convertArrayToTreePath(array); Assert.assertEquals(count, path.getPathCount()); Assert.assertEquals(count - 1, path.getLastPathComponent()); try { Assert.assertEquals(path, new TreePath(array)); } catch (StackOverflowError error) { System.out.println("StackOverflow - new TreePath: " + count); } }
convertArrayToTreePathDeep
272,621
void () { pathToCustomNodeDeep(1); pathToCustomNodeDeep(10); pathToCustomNodeDeep(100); pathToCustomNodeDeep(1000); pathToCustomNodeDeep(10000); pathToCustomNodeDeep(100000); pathToCustomNodeDeep(1000000); }
pathToCustomNodeDeep
272,622
void (int count) { TreePath path = TreePathUtil.pathToCustomNode(count, value -> value > 1 ? value - 1 : null); Object[] array = TreePathUtil.convertTreePathToArray(path); assertUserObjectPath(count, array); }
pathToCustomNodeDeep
272,623
void (int count, Object... array) { Assert.assertEquals(count, array.length); int expected = 0; for (Object value : array) { Assert.assertEquals(Integer.valueOf(++expected), value); } }
assertUserObjectPath
272,624
void () { pathToTreeNodeDeep(1); pathToTreeNodeDeep(10); pathToTreeNodeDeep(100); pathToTreeNodeDeep(1000); pathToTreeNodeDeep(10000); pathToTreeNodeDeep(100000); pathToTreeNodeDeep(1000000); }
pathToTreeNodeDeep
272,625
void (int count) { DefaultMutableTreeNode node = node(count); makeDeepTreeFromNode(node, count); TreePath path = TreePathUtil.pathToTreeNode(node, TreeUtil::getUserObject); Object[] array = TreePathUtil.convertTreePathToArray(path); assertUserObjectPath(count, array); try { Assert.assertArrayEquals(array, node.getUserObjectPath()); } catch (StackOverflowError error) { System.out.println("StackOverflow - DefaultMutableTreeNode.getUserObjectPath: " + count); } }
pathToTreeNodeDeep
272,626
void (TreeNode node, int count) { while (1 < count) node = node(--count, node); }
makeDeepTreeFromNode
272,627
void () { TreePath path = TreePathUtil.convertArrayToTreePath("one", "two", "three", "four", "five"); Assert.assertEquals( TreePathUtil.convertArrayToTreePath("one", "two"), TreePathUtil.findAncestor(path, ancestor -> ancestor.getPathCount() == 2)); }
findAncestorFound
272,628
void () { TreePath path = TreePathUtil.convertArrayToTreePath("one", "two", "three", "four", "five"); Assert.assertNull(TreePathUtil.findAncestor(path, ancestor -> ancestor.getPathCount() == 10)); }
findAncestorNotFound
272,629
void () { Assert.assertNull(TreePathUtil.findAncestor(null, ancestor -> { Assert.fail(); return true; })); }
findAncestorNull
272,630
void () { TreePath path = TreePathUtil.convertArrayToTreePath("one", "two", "three", "four", "five"); Assert.assertSame(path, TreePathUtil.findAncestor(path, ancestor -> ancestor.getPathCount() == 5)); }
findAncestorSame
272,631
void () { TreePath path = TreePathUtil.convertArrayToTreePath("root", "parent"); Assert.assertEquals(path, TreePathUtil.findCommonAncestor( TreePathUtil.convertArrayToTreePath("root", "parent", "one", "child", "one"), TreePathUtil.convertArrayToTreePath("root", "parent", "one", "child", "two"), TreePathUtil.convertArrayToTreePath("root", "parent", "two", "child", "one"), TreePathUtil.convertArrayToTreePath("root", "parent", "two", "child", "two"))); }
findCommonAncestor
272,632
void () { TreePath path = TreePathUtil.convertArrayToTreePath("root", "parent", "child"); Assert.assertEquals(path, TreePathUtil.findCommonAncestor( TreePathUtil.convertArrayToTreePath("root", "parent", "child", "one"), TreePathUtil.convertArrayToTreePath("root", "parent", "child", "two"), path)); }
findCommonAncestorWithParent
272,633
void () { TreePath path = TreePathUtil.convertArrayToTreePath("root", "parent", "child"); Assert.assertEquals(path, TreePathUtil.findCommonAncestor(path)); }
findCommonAncestorSingle
272,634
void () { Assert.assertNull(TreePathUtil.findCommonAncestor()); Assert.assertNull(TreePathUtil.findCommonAncestor((TreePath)null)); }
findCommonAncestorEmpty
272,635
void () { Assert.assertNull(TreePathUtil.findCommonAncestor( TreePathUtil.convertArrayToTreePath("one", "root"), TreePathUtil.convertArrayToTreePath("two", "root"))); }
findCommonAncestorWrong
272,636
void () { TestApplicationManager.getInstance(); }
setUp
272,637
void () { testFind(() -> new DepthVisitor(1), 1); }
testAcceptDepth1
272,638
void () { testFind(() -> new DepthVisitor(2), 4); }
testAcceptDepth2
272,639
void () { testFind(() -> new DepthVisitor(3), 21); }
testAcceptDepth3
272,640
void () { testFind(() -> new Visitor(), 21); }
testAcceptAll
272,641
void () { testFind(() -> new StringFinder("Root"), 1, "Root"); }
testFindRoot
272,642
void () { testFind(() -> new StringFinder("ROOT"), 1); }
testFindWrongRoot
272,643
void () { testFind(() -> new StringFinder("RootColor"), 2, "RootColor"); }
testFindColor
272,644
void () { testFind(() -> new StringFinder("RootCOLOR"), 4); }
testFindWrongColor
272,645
void () { testFind(() -> new StringFinder("RootDigit"), 3, "RootDigit"); }
testFindDigit
272,646
void () { testFind(() -> new StringFinder("RootDIGIT"), 4); }
testFindWrongDigit
272,647
void () { testFind(() -> new StringFinder("RootGreek"), 4, "RootGreek"); }
testFindGreek
272,648
void () { testFind(() -> new StringFinder("RootGREEK"), 4); }
testFindWrongGreek
272,649
void () { testFind(() -> new StringFinder("RootColorGreen"), 4, "RootColorGreen"); }
testFindGreen
272,650
void () { testFind(() -> new StringFinder("RootColorGREEN"), 7); }
testFindWrongGreen
272,651
void () { testFind(() -> new StringFinder("RootDigitFive"), 8, "RootDigitFive"); }
testFindFive
272,652
void () { testFind(() -> new StringFinder("RootDigitFIVE"), 13); }
testFindWrongFive
272,653
void () { testFind(() -> new StringFinder("RootGreekGamma"), 7, "RootGreekGamma"); }
testFindGamma
272,654
void () { testFind(() -> new StringFinder("RootGreekGAMMA"), 9); }
testFindWrongGamma
272,655
void (@NotNull Supplier<Visitor> supplier, long count) { testFind(supplier, count, null); }
testFind
272,656
void (@NotNull Supplier<Visitor> supplier, long count, String value) { TreeTest.test(TreeUtilVisitTest::root, test -> test.assertTree("+Root\n", () -> { @NotNull Visitor visitor = supplier.get(); TreeUtil.visit(test.getTree(), visitor, path -> test.invokeSafely(() -> { Assert.assertEquals(count, visitor.counter.get()); Assert.assertEquals(value, value(path)); test.done(); })); })); }
testFind
272,657
void () { testShow(() -> new StringFinder("Root"), "+[Root]\n"); }
testShowRoot
272,658
void () { testShow(() -> new StringFinder("RootColor"), """ -Root +[RootColor] +RootDigit +RootGreek """); }
testShowColor
272,659
void () { testShow(() -> new StringFinder("RootDigit"), """ -Root +RootColor +[RootDigit] +RootGreek """); }
testShowDigit
272,660
void () { testShow(() -> new StringFinder("RootGreek"), """ -Root +RootColor +RootDigit +[RootGreek] """); }
testShowGreek
272,661
void () { testShow(() -> new StringFinder("RootColorGreen"), """ -Root -RootColor RootColorRed [RootColorGreen] RootColorBlue +RootDigit +RootGreek """); }
testShowGreen
272,662
void () { testShow(() -> new StringFinder("RootDigitFive"), """ -Root +RootColor -RootDigit RootDigitOne RootDigitTwo RootDigitThree RootDigitFour [RootDigitFive] RootDigitSix RootDigitSeven RootDigitEight RootDigitNine +RootGreek """); }
testShowFive
272,663
void () { testShow(() -> new StringFinder("RootGreekGamma"), """ -Root +RootColor +RootDigit -RootGreek RootGreekAlpha RootGreekBeta [RootGreekGamma] RootGreekDelta RootGreekEpsilon """); }
testShowGamma
272,664
void (@NotNull Supplier<Visitor> supplier, @NotNull String expected) { TreeTest.test(TreeUtilVisitTest::root, test -> test.assertTree("+Root\n", () -> { @NotNull Visitor visitor = supplier.get(); TreeUtil.visit(test.getTree(), visitor, path -> { test.getTree().makeVisible(path); test.addSelection(path, () -> test.assertTree(expected, true, test::done)); }); })); }
testShow
272,665
void () { TreeTest.test(TreeUtilVisitTest::root, test -> test.assertTree("+Root\n", () -> TreeUtil.expand(test.getTree(), 1, () -> test.assertTree(""" -Root +RootColor +RootDigit +RootGreek """, test::done)))); }
testExpandOne
272,666
void () { TreeTest.test(TreeUtilVisitTest::rootDeep, test -> test.assertTree("+Root\n", () -> TreeUtil.expand(test.getTree(), 2, () -> test.assertTree(""" -Root -1 +11 +12 +13 -2 +21 +22 +23 -3 +31 +32 +33 """, test::done)))); }
testExpandTwo
272,667
void () { TreeTest.test(TreeUtilVisitTest::root, test -> test.assertTree("+Root\n", () -> TreeUtil.expandAll(test.getTree(), () -> test.assertTree(""" -Root -RootColor RootColorRed RootColorGreen RootColorBlue -RootDigit RootDigitOne RootDigitTwo RootDigitThree RootDigitFour RootDigitFive RootDigitSix RootDigitSeven RootDigitEight RootDigitNine -RootGreek RootGreekAlpha RootGreekBeta RootGreekGamma RootGreekDelta RootGreekEpsilon """, test::done)) )); }
testExpandAll
272,668
void () { testCollapseAll(true, true, false, 0, """ -Root +1 +[2] +3 """); }
testCollapseAll
272,669
void () { testCollapseAll(true, true, true, 0, "+[Root]\n"); }
testCollapseAllStrict
272,670
void () { testCollapseAll(false, true, false, 0, """ +1 +[2] +3 """); }
testCollapseAllWithoutRoot
272,671
void () { testCollapseAll(true, false, false, 0, """ -Root +1 +[2] +3 """); }
testCollapseAllWithoutRootHandles
272,672
void () { testCollapseAll(false, false, false, 0, """ -1 +11 +12 +13 -2 +21 +[22] +23 -3 +31 +32 +33 """); }
testCollapseAllWithoutRootAndHandles
272,673
void () { testCollapseAll(true, true, false, -1, """ -Root +1 -2 +21 -22 +221 -222 2221 [2222] 2223 +223 +23 +3 """); }
testCollapseAllExceptSelectedNode
272,674
void () { testCollapseAll(true, true, false, 4, """ -Root +1 -2 +21 -22 +221 +[222] +223 +23 +3 """); }
testCollapseAllExceptParentOfSelectedNode
272,675
void () { testCollapseAll(true, true, false, 3, """ -Root +1 -2 +21 +[22] +23 +3 """); }
testCollapseAllExceptGrandParentOfSelectedNode
272,676
void (boolean visible, boolean showHandles, boolean strict, int keepSelectionLevel, String expected) { TreeTest.test(TreeTest.FAST, 1, TreeUtilVisitTest::rootDeep, test -> configureRoot(test, visible, showHandles, () -> TreeUtil.expandAll(test.getTree(), () -> select(test, convertArrayToVisitor("2", "22", "222", "2222"), path -> collapseAll(test, strict, keepSelectionLevel, () -> test.assertTree(expected, true, test::done)))))); }
testCollapseAll
272,677
void (@NotNull TreeTest test, boolean strict, int keepSelectionLevel, @NotNull Runnable onDone) { test.getTree().addTreeExpansionListener(new TreeExpansionListener() { @Override public void treeCollapsed(TreeExpansionEvent event) { } @Override public void treeExpanded(TreeExpansionEvent event) { throw new UnsupportedOperationException("do not expand while collapse"); } }); TreeUtil.collapseAll(test.getTree(), strict, keepSelectionLevel); onDone.run(); }
collapseAll
272,678
void (TreeExpansionEvent event) { }
treeCollapsed
272,679
void (TreeExpansionEvent event) { throw new UnsupportedOperationException("do not expand while collapse"); }
treeExpanded
272,680
void (@NotNull TreeTest test, boolean visible, boolean showHandles, @NotNull Runnable onDone) { test.getTree().setRootVisible(visible); test.getTree().setShowsRootHandles(showHandles); onDone.run(); }
configureRoot
272,681
void () { testMakeVisible(""" -Root +[1] +2 +3 """, "1"); }
testMakeVisible1
272,682
void () { testMakeVisible(""" -Root -1 +[11] +12 +13 +2 +3 """, "1", "11"); }
testMakeVisible11
272,683
void () { testMakeVisible(""" -Root -1 -11 +[111] +112 +113 +12 +13 +2 +3 """, "1", "11", "111"); }
testMakeVisible111
272,684
void () { testMakeVisible(""" -Root -1 -11 -111 [1111] 1112 1113 +112 +113 +12 +13 +2 +3 """, "1", "11", "111", "1111"); }
testMakeVisible1111
272,685
void () { testMakeVisible(""" -Root +1 +[2] +3 """, "2"); }
testMakeVisible2
272,686
void () { testMakeVisible(""" -Root +1 -2 +21 +[22] +23 +3 """, "2", "22"); }
testMakeVisible22
272,687
void () { testMakeVisible(""" -Root +1 -2 +21 -22 +221 +[222] +223 +23 +3 """, "2", "22", "222"); }
testMakeVisible222
272,688
void () { testMakeVisible(""" -Root +1 -2 +21 -22 +221 -222 2221 [2222] 2223 +223 +23 +3 """, "2", "22", "222", "2222"); }
testMakeVisible2222
272,689
void () { testMakeVisible(""" -Root +1 +2 +[3] """, "3"); }
testMakeVisible3
272,690
void () { testMakeVisible(""" -Root +1 +2 -3 +31 +32 +[33] """, "3", "33"); }
testMakeVisible33
272,691
void () { testMakeVisible(""" -Root +1 +2 -3 +31 +32 -33 +331 +332 +[333] """, "3", "33", "333"); }
testMakeVisible333
272,692
void () { testMakeVisible(""" -Root +1 +2 -3 +31 +32 -33 +331 +332 -333 3331 3332 [3333] """, "3", "33", "333", "3333"); }
testMakeVisible3333
272,693
void (String expected, String... array) { TreeTest.test(TreeUtilVisitTest::rootDeep, test -> TreeUtil.makeVisible(test.getTree(), convertArrayToVisitor(array), path -> test.addSelection(path, () -> test.assertTree(expected, true, test::done)))); }
testMakeVisible
272,694
void () { testSelect(convertArrayToVisitor("1", "11"), """ -Root -1 +[11] +12 +13 +2 +3 """); }
testSelect11
272,695
void () { testSelect(convertArrayToVisitor("2", "22", "222"), """ -Root +1 -2 +21 -22 +221 +[222] +223 +23 +3 """); }
testSelect222
272,696
void () { testSelect(convertArrayToVisitor("3", "33", "333", "3333"), """ -Root +1 +2 -3 +31 +32 -33 +331 +332 -333 3331 3332 [3333] """); }
testSelect3333
272,697
void (TreeVisitor visitor, String expected) { TreeTest.test(TreeUtilVisitTest::rootDeep, test -> select(test, visitor, path -> test.assertTree(expected, true, test::done))); }
testSelect
272,698
void (@NotNull TreeTest test, @NotNull TreeVisitor visitor, @NotNull Consumer<? super TreePath> consumer) { TreeUtil.promiseSelect(test.getTree(), visitor).onSuccess(consumer); }
select
272,699
void () { TreeVisitor[] array = { convertArrayToVisitor("3", "33", "333", "3333"), convertArrayToVisitor("2", "22", "222"), convertArrayToVisitor("1", "11"), path -> TreeVisitor.Action.INTERRUPT, }; testMultiSelect(array, array.length, """ -[Root] -1 +[11] +12 +13 -2 +21 -22 +221 +[222] +223 +23 -3 +31 +32 -33 +331 +332 -333 3331 3332 [3333] """); }
testMultiSelect3333and222and11andRoot