use of javax.swing.tree.TreePath in project zaproxy by zaproxy.
the class JCheckBoxTreeUnitTest method shouldCheckRootNodeWithoutChildNodes.
@Test
public void shouldCheckRootNodeWithoutChildNodes() {
// Given
TreeModelTest treeModel = TreeModelTest.create("A");
TreePath rootNodePath = treeModel.createPath("A");
JCheckBoxTree checkBoxTree = new JCheckBoxTree();
checkBoxTree.setModel(treeModel);
// When
checkBoxTree.check(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.getCheckedPaths(), is(arrayContaining(rootNodePath)));
}
use of javax.swing.tree.TreePath in project zaproxy by zaproxy.
the class JCheckBoxTreeUnitTest method shouldUncheckRootNodeSubTreeWithChildNodes.
@Test
public void shouldUncheckRootNodeSubTreeWithChildNodes() {
// 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);
checkBoxTree.checkSubTree(rootNodePath, true);
// When
checkBoxTree.checkSubTree(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(false)));
assertThat(checkBoxTree.isSelectedPartially(childNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(childNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isChecked(childNodeCPath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedPartially(childNodeCPath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(childNodeCPath), is(equalTo(false)));
assertThat(checkBoxTree.isChecked(childNodeDPath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedPartially(childNodeDPath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(childNodeDPath), is(equalTo(false)));
assertThat(checkBoxTree.getCheckedPaths(), is(emptyArray()));
}
use of javax.swing.tree.TreePath in project zaproxy by zaproxy.
the class JCheckBoxTreeUnitTest method shouldCheckRootNodeWithChildNodes.
@Test
public void shouldCheckRootNodeWithChildNodes() {
// 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);
// When
checkBoxTree.check(rootNodePath, true);
// Then
assertThat(checkBoxTree.isChecked(rootNodePath), is(equalTo(true)));
assertThat(checkBoxTree.isSelectedPartially(rootNodePath), is(equalTo(true)));
assertThat(checkBoxTree.isSelectedFully(rootNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isChecked(childNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedPartially(childNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(childNodePath), is(equalTo(false)));
assertThat(checkBoxTree.getCheckedPaths(), is(arrayContaining(rootNodePath)));
}
use of javax.swing.tree.TreePath in project zaproxy by zaproxy.
the class JCheckBoxTreeUnitTest method shouldUncheckChildNodeWithoutChildNodes.
@Test
public void shouldUncheckChildNodeWithoutChildNodes() {
// 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);
checkBoxTree.checkSubTree(rootNodePath, true);
// When
checkBoxTree.check(childNodePath, false);
// Then
assertThat(checkBoxTree.isChecked(childNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedPartially(childNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isSelectedFully(childNodePath), is(equalTo(false)));
assertThat(checkBoxTree.isChecked(rootNodePath), is(equalTo(true)));
assertThat(checkBoxTree.isSelectedPartially(rootNodePath), is(equalTo(true)));
assertThat(checkBoxTree.isSelectedFully(rootNodePath), is(equalTo(false)));
assertThat(checkBoxTree.getCheckedPaths(), is(arrayContaining(rootNodePath)));
}
use of javax.swing.tree.TreePath in project zaproxy by zaproxy.
the class JCheckBoxTreeUnitTest method shouldCheckRootNodeSubTreeWithoutChildNodes.
@Test
public void shouldCheckRootNodeSubTreeWithoutChildNodes() {
// Given
TreeModelTest treeModel = TreeModelTest.create("A");
TreePath rootNodePath = treeModel.createPath("A");
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.getCheckedPaths(), is(arrayContaining(rootNodePath)));
}
Aggregations