use of javax.swing.tree.TreePath in project zaproxy by zaproxy.
the class JCheckBoxTreeUnitTest method shouldCollapseAllNodes.
@Test
public void shouldCollapseAllNodes() {
// Given
TreeModelTest treeModel = TreeModelTest.create("A", "A/B", "A/B/C", "A/B/D", "A/E");
TreePath rootNodePath = treeModel.createPath("A");
TreePath childNodeBPath = treeModel.createPath("A/B");
TreePath childCChildNodeBPath = treeModel.createPath("A/B/C");
TreePath childDChildNodeBPath = treeModel.createPath("A/B/D");
TreePath childNodeEPath = treeModel.createPath("A/E");
JCheckBoxTree checkBoxTree = new JCheckBoxTree();
checkBoxTree.setModel(treeModel);
checkBoxTree.expandAll();
// When
checkBoxTree.collapseAll();
// Then
assertThat(checkBoxTree.isExpanded(rootNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isCollapsed(rootNodePath), is(equalTo(true)));
assertThat(checkBoxTree.isExpanded(childNodeBPath), is(equalTo(false)));
assertThat(checkBoxTree.isCollapsed(childNodeBPath), is(equalTo(true)));
assertThat(checkBoxTree.isExpanded(childCChildNodeBPath), is(equalTo(false)));
assertThat(checkBoxTree.isCollapsed(childCChildNodeBPath), is(equalTo(true)));
assertThat(checkBoxTree.isExpanded(childDChildNodeBPath), is(equalTo(false)));
assertThat(checkBoxTree.isCollapsed(childDChildNodeBPath), is(equalTo(true)));
assertThat(checkBoxTree.isExpanded(childNodeEPath), is(equalTo(false)));
assertThat(checkBoxTree.isCollapsed(childNodeEPath), is(equalTo(true)));
}
use of javax.swing.tree.TreePath in project zaproxy by zaproxy.
the class JCheckBoxTreeUnitTest method shouldCheckRootNodeSubTreeWithChildNodes.
@Test
public void shouldCheckRootNodeSubTreeWithChildNodes() {
// Given
TreeModelTest treeModel = TreeModelTest.create("A", "A/B", "A/B/C", "A/B/D");
TreePath rootNodePath = treeModel.createPath("A");
TreePath childNodePath = treeModel.createPath("A/B");
TreePath childNodeCPath = treeModel.createPath("A/B/C");
TreePath childNodeDPath = treeModel.createPath("A/B/D");
JCheckBoxTree checkBoxTree = new JCheckBoxTree();
checkBoxTree.setModel(treeModel);
// When
checkBoxTree.checkSubTree(rootNodePath, true);
// Then
assertThat(checkBoxTree.isChecked(rootNodePath), is(equalTo(true)));
assertThat(checkBoxTree.isSelectedPartially(rootNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(rootNodePath), is(equalTo(true)));
assertThat(checkBoxTree.isChecked(childNodePath), is(equalTo(true)));
assertThat(checkBoxTree.isSelectedPartially(childNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(childNodePath), is(equalTo(true)));
assertThat(checkBoxTree.isChecked(childNodeCPath), is(equalTo(true)));
assertThat(checkBoxTree.isSelectedPartially(childNodeCPath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(childNodeCPath), is(equalTo(true)));
assertThat(checkBoxTree.isChecked(childNodeDPath), is(equalTo(true)));
assertThat(checkBoxTree.isSelectedPartially(childNodeDPath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(childNodeDPath), is(equalTo(true)));
assertThat(checkBoxTree.getCheckedPaths(), is(arrayContainingInAnyOrder(rootNodePath, childNodePath, childNodeCPath, childNodeDPath)));
}
use of javax.swing.tree.TreePath in project zaproxy by zaproxy.
the class JCheckBoxTreeUnitTest method shouldHaveAllNodesUncheckedByDefault.
@Test
public void shouldHaveAllNodesUncheckedByDefault() {
// Given
TreeModelTest treeModel = TreeModelTest.create("A", "A/B", "A/B/C", "A/B/D", "A/E");
TreePath rootNodePath = treeModel.createPath("A");
TreePath childNodeBPath = treeModel.createPath("A/B");
TreePath childCChildNodeBPath = treeModel.createPath("A/B/C");
TreePath childDChildNodeBPath = treeModel.createPath("A/B/D");
TreePath childNodeEPath = treeModel.createPath("A/E");
JCheckBoxTree checkBoxTree = new JCheckBoxTree();
// When
checkBoxTree.setModel(treeModel);
// Then
assertThat(checkBoxTree.isChecked(rootNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedPartially(rootNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(rootNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isChecked(childNodeBPath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedPartially(childNodeBPath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(childNodeBPath), is(equalTo(false)));
assertThat(checkBoxTree.isChecked(childCChildNodeBPath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedPartially(childCChildNodeBPath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(childCChildNodeBPath), is(equalTo(false)));
assertThat(checkBoxTree.isChecked(childDChildNodeBPath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedPartially(childDChildNodeBPath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(childDChildNodeBPath), is(equalTo(false)));
assertThat(checkBoxTree.isChecked(childNodeEPath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedPartially(childNodeEPath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(childNodeEPath), is(equalTo(false)));
assertThat(checkBoxTree.getCheckedPaths(), is(emptyArray()));
}
use of javax.swing.tree.TreePath in project zaproxy by zaproxy.
the class JCheckBoxTreeUnitTest method shouldCheckSubTreeChildNodeWithoutChildNodes.
@Test
public void shouldCheckSubTreeChildNodeWithoutChildNodes() {
// Given
TreeModelTest treeModel = TreeModelTest.create("A", "A/B");
TreePath rootNodePath = treeModel.createPath("A");
TreePath childNodePath = treeModel.createPath("A/B");
JCheckBoxTree checkBoxTree = new JCheckBoxTree();
checkBoxTree.setModel(treeModel);
// When
checkBoxTree.checkSubTree(childNodePath, true);
// Then
assertThat(checkBoxTree.isChecked(childNodePath), is(equalTo(true)));
assertThat(checkBoxTree.isSelectedPartially(childNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(childNodePath), is(equalTo(true)));
assertThat(checkBoxTree.isChecked(rootNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedPartially(rootNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(rootNodePath), is(equalTo(false)));
assertThat(checkBoxTree.getCheckedPaths(), is(arrayContaining(childNodePath)));
}
use of javax.swing.tree.TreePath in project zaproxy by zaproxy.
the class JCheckBoxTreeUnitTest method shouldUncheckRootNodeWithChildNodes.
@Test
public void shouldUncheckRootNodeWithChildNodes() {
// Given
TreeModelTest treeModel = TreeModelTest.create("A", "A/B1");
TreePath rootNodePath = treeModel.createPath("A");
TreePath childNodePath = treeModel.createPath("A/B1");
JCheckBoxTree checkBoxTree = new JCheckBoxTree();
checkBoxTree.setModel(treeModel);
checkBoxTree.checkSubTree(rootNodePath, true);
// When
checkBoxTree.check(rootNodePath, false);
// Then
assertThat(checkBoxTree.isChecked(rootNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedPartially(rootNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(rootNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isChecked(childNodePath), is(equalTo(true)));
assertThat(checkBoxTree.isSelectedPartially(childNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(childNodePath), is(equalTo(true)));
assertThat(checkBoxTree.getCheckedPaths(), is(arrayContaining(childNodePath)));
}
Aggregations