method2testcases
stringlengths
118
3.08k
### Question: AbstractTreeTableModel implements TreeTableModel { public AbstractTreeTableModel(Object root) { this.root = root; } AbstractTreeTableModel(Object root); Object getRoot(); boolean isLeaf(Object node); void valueForPathChanged(TreePath path, Object newValue); int getIndexOfChild(Object parent, Object child); void addTreeModelListener(TreeModelListener l); void removeTreeModelListener(TreeModelListener l); Class<?> getColumnClass(int column); boolean isCellEditable(Object node, int column); void setValueAt(Object aValue, Object node, int column); }### Answer: @Test public void testAbstractTreeTableModel() { assertNotNull(model); }
### Question: AbstractTreeTableModel implements TreeTableModel { public Object getRoot() { return root; } AbstractTreeTableModel(Object root); Object getRoot(); boolean isLeaf(Object node); void valueForPathChanged(TreePath path, Object newValue); int getIndexOfChild(Object parent, Object child); void addTreeModelListener(TreeModelListener l); void removeTreeModelListener(TreeModelListener l); Class<?> getColumnClass(int column); boolean isCellEditable(Object node, int column); void setValueAt(Object aValue, Object node, int column); }### Answer: @Test public void testGetRoot() { assertEquals(root, model.getRoot()); }
### Question: AbstractTreeTableModel implements TreeTableModel { public boolean isLeaf(Object node) { return getChildCount(node) == 0; } AbstractTreeTableModel(Object root); Object getRoot(); boolean isLeaf(Object node); void valueForPathChanged(TreePath path, Object newValue); int getIndexOfChild(Object parent, Object child); void addTreeModelListener(TreeModelListener l); void removeTreeModelListener(TreeModelListener l); Class<?> getColumnClass(int column); boolean isCellEditable(Object node, int column); void setValueAt(Object aValue, Object node, int column); }### Answer: @Test public void testIsLeaf() { assertTrue(model.isLeaf(root)); }
### Question: VisualPropertyDependency { public Set<VisualProperty<?>> getVisualProperties() { return Collections.<VisualProperty<?>>unmodifiableSet(vpSet); } VisualPropertyDependency(final String id, final String displayName, final Set<VisualProperty<T>> vpSet, final VisualLexicon lexicon); String getDisplayName(); String getIdString(); Set<VisualProperty<?>> getVisualProperties(); void setDependency(boolean enable); boolean isDependencyEnabled(); VisualProperty<T> getParentVisualProperty(); void setEventHelper(CyEventHelper eventHelper); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer: @Test public void testGetVisualProperties() { assertEquals(vpSet, dependency.getVisualProperties()); }
### Question: AbstractTreeTableModel implements TreeTableModel { public void valueForPathChanged(TreePath path, Object newValue) { } AbstractTreeTableModel(Object root); Object getRoot(); boolean isLeaf(Object node); void valueForPathChanged(TreePath path, Object newValue); int getIndexOfChild(Object parent, Object child); void addTreeModelListener(TreeModelListener l); void removeTreeModelListener(TreeModelListener l); Class<?> getColumnClass(int column); boolean isCellEditable(Object node, int column); void setValueAt(Object aValue, Object node, int column); }### Answer: @Test public void testValueForPathChanged() { model.valueForPathChanged(path, child1); }
### Question: AbstractTreeTableModel implements TreeTableModel { public int getIndexOfChild(Object parent, Object child) { for (int i = 0; i < getChildCount(parent); i++) { if (getChild(parent, i).equals(child)) { return i; } } return -1; } AbstractTreeTableModel(Object root); Object getRoot(); boolean isLeaf(Object node); void valueForPathChanged(TreePath path, Object newValue); int getIndexOfChild(Object parent, Object child); void addTreeModelListener(TreeModelListener l); void removeTreeModelListener(TreeModelListener l); Class<?> getColumnClass(int column); boolean isCellEditable(Object node, int column); void setValueAt(Object aValue, Object node, int column); }### Answer: @Test public void testGetIndexOfChild() { assertEquals(-1, model.getIndexOfChild(root, child1)); }
### Question: AbstractTreeTableModel implements TreeTableModel { public void addTreeModelListener(TreeModelListener l) { listenerList.add(TreeModelListener.class, l); } AbstractTreeTableModel(Object root); Object getRoot(); boolean isLeaf(Object node); void valueForPathChanged(TreePath path, Object newValue); int getIndexOfChild(Object parent, Object child); void addTreeModelListener(TreeModelListener l); void removeTreeModelListener(TreeModelListener l); Class<?> getColumnClass(int column); boolean isCellEditable(Object node, int column); void setValueAt(Object aValue, Object node, int column); }### Answer: @Test public void testAddTreeModelListener() { model.addTreeModelListener(tListener); assertEquals(1, model.listenerList.getListenerCount()); model.removeTreeModelListener(tListener); assertEquals(0, model.listenerList.getListenerCount()); }
### Question: AbstractTreeTableModel implements TreeTableModel { protected void fireTreeNodesChanged(Object source, Object[] path, int[] childIndices, Object[] children) { Object[] listeners = listenerList.getListenerList(); TreeModelEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == TreeModelListener.class) { if (e == null) e = new TreeModelEvent(source, path, childIndices, children); ((TreeModelListener) listeners[i + 1]).treeNodesChanged(e); } } } AbstractTreeTableModel(Object root); Object getRoot(); boolean isLeaf(Object node); void valueForPathChanged(TreePath path, Object newValue); int getIndexOfChild(Object parent, Object child); void addTreeModelListener(TreeModelListener l); void removeTreeModelListener(TreeModelListener l); Class<?> getColumnClass(int column); boolean isCellEditable(Object node, int column); void setValueAt(Object aValue, Object node, int column); }### Answer: @Test public void testFireTreeNodesChanged() { model.addTreeModelListener(tListener); model.fireTreeNodesChanged(source, pathList, childIndices, children); verify(tListener, times(1)).treeNodesChanged(any(TreeModelEvent.class)); }
### Question: AbstractTreeTableModel implements TreeTableModel { protected void fireTreeNodesInserted(Object source, Object[] path, int[] childIndices, Object[] children) { Object[] listeners = listenerList.getListenerList(); TreeModelEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == TreeModelListener.class) { if (e == null) e = new TreeModelEvent(source, path, childIndices, children); ((TreeModelListener) listeners[i + 1]).treeNodesInserted(e); } } } AbstractTreeTableModel(Object root); Object getRoot(); boolean isLeaf(Object node); void valueForPathChanged(TreePath path, Object newValue); int getIndexOfChild(Object parent, Object child); void addTreeModelListener(TreeModelListener l); void removeTreeModelListener(TreeModelListener l); Class<?> getColumnClass(int column); boolean isCellEditable(Object node, int column); void setValueAt(Object aValue, Object node, int column); }### Answer: @Test public void testFireTreeNodesInserted() { model.addTreeModelListener(tListener); model.fireTreeNodesInserted(source, pathList, childIndices, children); verify(tListener, times(1)).treeNodesInserted(any(TreeModelEvent.class)); }
### Question: AbstractTreeTableModel implements TreeTableModel { protected void fireTreeNodesRemoved(Object source, Object[] path, int[] childIndices, Object[] children) { Object[] listeners = listenerList.getListenerList(); TreeModelEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == TreeModelListener.class) { if (e == null) e = new TreeModelEvent(source, path, childIndices, children); ((TreeModelListener) listeners[i + 1]).treeNodesRemoved(e); } } } AbstractTreeTableModel(Object root); Object getRoot(); boolean isLeaf(Object node); void valueForPathChanged(TreePath path, Object newValue); int getIndexOfChild(Object parent, Object child); void addTreeModelListener(TreeModelListener l); void removeTreeModelListener(TreeModelListener l); Class<?> getColumnClass(int column); boolean isCellEditable(Object node, int column); void setValueAt(Object aValue, Object node, int column); }### Answer: @Test public void testFireTreeNodesRemoved() { model.addTreeModelListener(tListener); model.fireTreeNodesRemoved(source, pathList, childIndices, children); verify(tListener, times(1)).treeNodesRemoved(any(TreeModelEvent.class)); }
### Question: AbstractTreeTableModel implements TreeTableModel { protected void fireTreeStructureChanged(Object source, Object[] path, int[] childIndices, Object[] children) { Object[] listeners = listenerList.getListenerList(); TreeModelEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == TreeModelListener.class) { if (e == null) e = new TreeModelEvent(source, path, childIndices, children); ((TreeModelListener) listeners[i + 1]).treeStructureChanged(e); } } } AbstractTreeTableModel(Object root); Object getRoot(); boolean isLeaf(Object node); void valueForPathChanged(TreePath path, Object newValue); int getIndexOfChild(Object parent, Object child); void addTreeModelListener(TreeModelListener l); void removeTreeModelListener(TreeModelListener l); Class<?> getColumnClass(int column); boolean isCellEditable(Object node, int column); void setValueAt(Object aValue, Object node, int column); }### Answer: @Test public void testFireTreeStructureChanged() { model.addTreeModelListener(tListener); model.fireTreeStructureChanged(source, pathList, childIndices, children); verify(tListener, times(1)).treeStructureChanged(any(TreeModelEvent.class)); }
### Question: AbstractTreeTableModel implements TreeTableModel { public Class<?> getColumnClass(int column) { return Object.class; } AbstractTreeTableModel(Object root); Object getRoot(); boolean isLeaf(Object node); void valueForPathChanged(TreePath path, Object newValue); int getIndexOfChild(Object parent, Object child); void addTreeModelListener(TreeModelListener l); void removeTreeModelListener(TreeModelListener l); Class<?> getColumnClass(int column); boolean isCellEditable(Object node, int column); void setValueAt(Object aValue, Object node, int column); }### Answer: @Test public void testGetColumnClass() { assertEquals(Object.class, model.getColumnClass(0)); }
### Question: AbstractTreeTableModel implements TreeTableModel { public boolean isCellEditable(Object node, int column) { return getColumnClass(column) == TreeTableModel.class; } AbstractTreeTableModel(Object root); Object getRoot(); boolean isLeaf(Object node); void valueForPathChanged(TreePath path, Object newValue); int getIndexOfChild(Object parent, Object child); void addTreeModelListener(TreeModelListener l); void removeTreeModelListener(TreeModelListener l); Class<?> getColumnClass(int column); boolean isCellEditable(Object node, int column); void setValueAt(Object aValue, Object node, int column); }### Answer: @Test public void testIsCellEditable() { assertFalse(model.isCellEditable(root, 0)); }
### Question: AbstractTreeTableModel implements TreeTableModel { public void setValueAt(Object aValue, Object node, int column) { } AbstractTreeTableModel(Object root); Object getRoot(); boolean isLeaf(Object node); void valueForPathChanged(TreePath path, Object newValue); int getIndexOfChild(Object parent, Object child); void addTreeModelListener(TreeModelListener l); void removeTreeModelListener(TreeModelListener l); Class<?> getColumnClass(int column); boolean isCellEditable(Object node, int column); void setValueAt(Object aValue, Object node, int column); }### Answer: @Test public void testSetValueAt() { Object aValue = null; model.setValueAt(aValue, root, 0); }
### Question: VisualPropertyDependency { public void setDependency(boolean enable) { if (enable != this.enabled) { this.enabled = enable; if (eventHelper != null) eventHelper.fireEvent(new VisualPropertyDependencyChangedEvent(this)); } } VisualPropertyDependency(final String id, final String displayName, final Set<VisualProperty<T>> vpSet, final VisualLexicon lexicon); String getDisplayName(); String getIdString(); Set<VisualProperty<?>> getVisualProperties(); void setDependency(boolean enable); boolean isDependencyEnabled(); VisualProperty<T> getParentVisualProperty(); void setEventHelper(CyEventHelper eventHelper); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer: @Test public void testSetDependency() { dependency.setDependency(true); assertTrue(dependency.isDependencyEnabled()); }
### Question: FileChooserFilter extends FileFilter { @Override public boolean accept(final File file) { if (file.isDirectory()) return true; final String fileName = file.getName().toLowerCase(); if (extensions != null) { for (int i = 0; i < extensions.length; i++) { if (fileName.endsWith(extensions[i])) return true; } } else throw new IllegalArgumentException("No fileType specified"); return false; } FileChooserFilter(final String description, final String extension); FileChooserFilter(final String description, final String[] extensions); @Override boolean accept(final File file); @Override String getDescription(); String[] getExtensions(); @Override boolean equals(final Object other); }### Answer: @Test public void testAcceptFile() { File rdfFile = new File("test.rdf"); File xmlFile = new File("test.xml"); File textFile = new File("test.txt"); assertTrue(filter.accept(rdfFile)); assertTrue(filter.accept(xmlFile)); assertFalse(filter.accept(textFile)); }
### Question: FileChooserFilter extends FileFilter { @Override public String getDescription() { return description; } FileChooserFilter(final String description, final String extension); FileChooserFilter(final String description, final String[] extensions); @Override boolean accept(final File file); @Override String getDescription(); String[] getExtensions(); @Override boolean equals(final Object other); }### Answer: @Test public void testGetDescription() { assertEquals(description, filter.getDescription()); }
### Question: FileChooserFilter extends FileFilter { public String[] getExtensions() { return extensions; } FileChooserFilter(final String description, final String extension); FileChooserFilter(final String description, final String[] extensions); @Override boolean accept(final File file); @Override String getDescription(); String[] getExtensions(); @Override boolean equals(final Object other); }### Answer: @Test public void testGetExtensions() { final String[] exts = filter.getExtensions(); assertEquals(2, exts.length); }
### Question: FileChooserFilter extends FileFilter { @Override public boolean equals(final Object other) { if (!(other instanceof FileChooserFilter)) return false; final FileChooserFilter otherFilter = (FileChooserFilter) other; if (!otherFilter.description.equals(description)) return false; if (otherFilter.extensions.length != extensions.length) return false; Arrays.sort(otherFilter.extensions); Arrays.sort(extensions); for (int i = 0; i < extensions.length; ++i) { if (!extensions[i].equals(otherFilter.extensions[i])) return false; } return true; } FileChooserFilter(final String description, final String extension); FileChooserFilter(final String description, final String[] extensions); @Override boolean accept(final File file); @Override String getDescription(); String[] getExtensions(); @Override boolean equals(final Object other); }### Answer: @Test public void testEqualsObject() { FileChooserFilter filter2 = new FileChooserFilter(description, extension); assertFalse(filter.equals(filter2)); }
### Question: VisualPropertyDependency { public boolean isDependencyEnabled() { return enabled; } VisualPropertyDependency(final String id, final String displayName, final Set<VisualProperty<T>> vpSet, final VisualLexicon lexicon); String getDisplayName(); String getIdString(); Set<VisualProperty<?>> getVisualProperties(); void setDependency(boolean enable); boolean isDependencyEnabled(); VisualProperty<T> getParentVisualProperty(); void setEventHelper(CyEventHelper eventHelper); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer: @Test public void testIsDependencyEnabled() { assertFalse(dependency.isDependencyEnabled()); dependency.setDependency(true); assertTrue(dependency.isDependencyEnabled()); }
### Question: JStatusBar extends JPanel { public JStatusBar() { initComponents(); } JStatusBar(); void setLeftLabel(final String text); void setCenterLabel(final String text); void setRightLabel(final String text); }### Answer: @Test public void testJStatusBar() { assertNotNull(statusBar); }
### Question: JStatusBar extends JPanel { public void setLeftLabel(final String text) { leftLabel.setText(text); } JStatusBar(); void setLeftLabel(final String text); void setCenterLabel(final String text); void setRightLabel(final String text); }### Answer: @Test public void testSetLeftLabel() { String text = "left label"; statusBar.setLeftLabel(text); }
### Question: JStatusBar extends JPanel { public void setCenterLabel(final String text) { centerLabel.setText(text); } JStatusBar(); void setLeftLabel(final String text); void setCenterLabel(final String text); void setRightLabel(final String text); }### Answer: @Test public void testSetCenterLabel() { String text = "center label"; statusBar.setLeftLabel(text); }
### Question: VisualPropertyDependency { public VisualProperty<T> getParentVisualProperty() { return parentVisualProperty; } VisualPropertyDependency(final String id, final String displayName, final Set<VisualProperty<T>> vpSet, final VisualLexicon lexicon); String getDisplayName(); String getIdString(); Set<VisualProperty<?>> getVisualProperties(); void setDependency(boolean enable); boolean isDependencyEnabled(); VisualProperty<T> getParentVisualProperty(); void setEventHelper(CyEventHelper eventHelper); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer: @Test public void testGetParentVisualProperty() { VisualProperty<Paint> parent = dependency.getParentVisualProperty(); assertNotNull(parent); assertEquals(BasicVisualLexicon.NODE_PAINT, parent); }
### Question: JStatusBar extends JPanel { public void setRightLabel(final String text) { rightLabel.setText(text); } JStatusBar(); void setLeftLabel(final String text); void setCenterLabel(final String text); void setRightLabel(final String text); }### Answer: @Test public void testSetRightLabel() { String text = "right label"; statusBar.setLeftLabel(text); }
### Question: BasicCollapsiblePanel extends JPanel { public void setTitleComponentText(String text) { if (titleComponent instanceof JButton) { titleComponent.setText(text); } } BasicCollapsiblePanel(JRadioButton component); BasicCollapsiblePanel(String text); private BasicCollapsiblePanel(final AbstractButton titleComponent, final boolean collapsed); void setTitleComponentText(String text); JPanel getContentPane(); @Override Component add(Component comp); @Override Component add(Component comp, int index); @Override void add(Component comp, Object constraints); @Override void add(Component comp, Object constraints, int index); @Override Component add(String name, Component comp); void setCollapsed(boolean collapse); boolean isCollapsed(); @Override void setToolTipText(final String text); void addCollapseListener(CollapseListener listener); boolean removeCollapeListener(CollapseListener listener); }### Answer: @Test public void testSetTitleComponentText() { final String title ="Title text"; final String original = "original title"; panel = new BasicCollapsiblePanel(original); assertEquals(original, panel.titleComponent.getText()); panel.setTitleComponentText(title); assertEquals(title, panel.titleComponent.getText()); }
### Question: BasicCollapsiblePanel extends JPanel { public JPanel getContentPane() { if (contentPane == null) { contentPane = new JPanel(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); contentPane.setBorder(border); if (isAquaLAF()) contentPane.setOpaque(false); } return contentPane; } BasicCollapsiblePanel(JRadioButton component); BasicCollapsiblePanel(String text); private BasicCollapsiblePanel(final AbstractButton titleComponent, final boolean collapsed); void setTitleComponentText(String text); JPanel getContentPane(); @Override Component add(Component comp); @Override Component add(Component comp, int index); @Override void add(Component comp, Object constraints); @Override void add(Component comp, Object constraints, int index); @Override Component add(String name, Component comp); void setCollapsed(boolean collapse); boolean isCollapsed(); @Override void setToolTipText(final String text); void addCollapseListener(CollapseListener listener); boolean removeCollapeListener(CollapseListener listener); }### Answer: @Test public void testGetContentPane() { assertNotNull(panel.getContentPane()); }
### Question: BasicCollapsiblePanel extends JPanel { @Override public Component add(Component comp) { adjust(comp); return contentPane.add(comp); } BasicCollapsiblePanel(JRadioButton component); BasicCollapsiblePanel(String text); private BasicCollapsiblePanel(final AbstractButton titleComponent, final boolean collapsed); void setTitleComponentText(String text); JPanel getContentPane(); @Override Component add(Component comp); @Override Component add(Component comp, int index); @Override void add(Component comp, Object constraints); @Override void add(Component comp, Object constraints, int index); @Override Component add(String name, Component comp); void setCollapsed(boolean collapse); boolean isCollapsed(); @Override void setToolTipText(final String text); void addCollapseListener(CollapseListener listener); boolean removeCollapeListener(CollapseListener listener); }### Answer: @Test public void testAddComponent() { JPanel testPanel = new JPanel(); assertNotNull(panel.add(testPanel)); }
### Question: BasicCollapsiblePanel extends JPanel { public void setCollapsed(boolean collapse) { if (collapse) { getContentPane().setVisible(false); getArrowBtn().setIcon(UIManager.getIcon("Tree.collapsedIcon")); } else { getContentPane().setVisible(true); getArrowBtn().setIcon(UIManager.getIcon("Tree.expandedIcon")); } collapsed = collapse; updateUI(); if (collapseListeners != null) { for (CollapseListener listener : collapseListeners) { if (collapse) listener.collapsed(); else listener.expanded(); } } } BasicCollapsiblePanel(JRadioButton component); BasicCollapsiblePanel(String text); private BasicCollapsiblePanel(final AbstractButton titleComponent, final boolean collapsed); void setTitleComponentText(String text); JPanel getContentPane(); @Override Component add(Component comp); @Override Component add(Component comp, int index); @Override void add(Component comp, Object constraints); @Override void add(Component comp, Object constraints, int index); @Override Component add(String name, Component comp); void setCollapsed(boolean collapse); boolean isCollapsed(); @Override void setToolTipText(final String text); void addCollapseListener(CollapseListener listener); boolean removeCollapeListener(CollapseListener listener); }### Answer: @Test public void testSetCollapsed() { panel.setCollapsed(true); assertTrue(panel.isCollapsed()); panel.setCollapsed(false); assertFalse(panel.isCollapsed()); }
### Question: BasicCollapsiblePanel extends JPanel { @Override public void setToolTipText(final String text) { super.setToolTipText(text); titleComponent.setToolTipText(text); } BasicCollapsiblePanel(JRadioButton component); BasicCollapsiblePanel(String text); private BasicCollapsiblePanel(final AbstractButton titleComponent, final boolean collapsed); void setTitleComponentText(String text); JPanel getContentPane(); @Override Component add(Component comp); @Override Component add(Component comp, int index); @Override void add(Component comp, Object constraints); @Override void add(Component comp, Object constraints, int index); @Override Component add(String name, Component comp); void setCollapsed(boolean collapse); boolean isCollapsed(); @Override void setToolTipText(final String text); void addCollapseListener(CollapseListener listener); boolean removeCollapeListener(CollapseListener listener); }### Answer: @Test public void testSetToolTipTextString() { String text = "tooltip"; panel.setToolTipText(text); assertEquals(text, panel.getToolTipText()); }
### Question: AbstractCellEditor implements CellEditor { @Override public Object getCellEditorValue() { return null; } @Override Object getCellEditorValue(); @Override boolean isCellEditable(EventObject e); @Override boolean shouldSelectCell(EventObject anEvent); @Override boolean stopCellEditing(); @Override void addCellEditorListener(CellEditorListener l); @Override void removeCellEditorListener(CellEditorListener l); }### Answer: @Test public void testGetCellEditorValue() { assertNull(editor.getCellEditorValue()); }
### Question: AbstractCellEditor implements CellEditor { @Override public boolean isCellEditable(EventObject e) { return true; } @Override Object getCellEditorValue(); @Override boolean isCellEditable(EventObject e); @Override boolean shouldSelectCell(EventObject anEvent); @Override boolean stopCellEditing(); @Override void addCellEditorListener(CellEditorListener l); @Override void removeCellEditorListener(CellEditorListener l); }### Answer: @Test public void testIsCellEditable() { assertTrue(editor.isCellEditable(null)); }
### Question: AbstractCellEditor implements CellEditor { @Override public boolean shouldSelectCell(EventObject anEvent) { return false; } @Override Object getCellEditorValue(); @Override boolean isCellEditable(EventObject e); @Override boolean shouldSelectCell(EventObject anEvent); @Override boolean stopCellEditing(); @Override void addCellEditorListener(CellEditorListener l); @Override void removeCellEditorListener(CellEditorListener l); }### Answer: @Test public void testShouldSelectCell() { assertFalse(editor.shouldSelectCell(null)); }
### Question: AbstractCellEditor implements CellEditor { @Override public boolean stopCellEditing() { return true; } @Override Object getCellEditorValue(); @Override boolean isCellEditable(EventObject e); @Override boolean shouldSelectCell(EventObject anEvent); @Override boolean stopCellEditing(); @Override void addCellEditorListener(CellEditorListener l); @Override void removeCellEditorListener(CellEditorListener l); }### Answer: @Test public void testStopCellEditing() { assertTrue(editor.stopCellEditing()); }
### Question: VisualPropertyDependency { @Override public String toString() { return displayName; } VisualPropertyDependency(final String id, final String displayName, final Set<VisualProperty<T>> vpSet, final VisualLexicon lexicon); String getDisplayName(); String getIdString(); Set<VisualProperty<?>> getVisualProperties(); void setDependency(boolean enable); boolean isDependencyEnabled(); VisualProperty<T> getParentVisualProperty(); void setEventHelper(CyEventHelper eventHelper); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer: @Test public void testToString() { assertEquals(displayName, dependency.toString()); }
### Question: AbstractCellEditor implements CellEditor { @Override public void addCellEditorListener(CellEditorListener l) { listenerList.add(CellEditorListener.class, l); } @Override Object getCellEditorValue(); @Override boolean isCellEditable(EventObject e); @Override boolean shouldSelectCell(EventObject anEvent); @Override boolean stopCellEditing(); @Override void addCellEditorListener(CellEditorListener l); @Override void removeCellEditorListener(CellEditorListener l); }### Answer: @Test public void testAddCellEditorListener() { CellEditorListener l = mock(CellEditorListener.class); editor.addCellEditorListener(l); assertEquals(1, editor.listenerList.getListenerCount()); editor.removeCellEditorListener(l); assertEquals(0, editor.listenerList.getListenerCount()); }
### Question: AbstractCellEditor implements CellEditor { protected void fireEditingStopped() { Object[] listeners = listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == CellEditorListener.class) { ((CellEditorListener) listeners[i + 1]).editingStopped(new ChangeEvent(this)); } } } @Override Object getCellEditorValue(); @Override boolean isCellEditable(EventObject e); @Override boolean shouldSelectCell(EventObject anEvent); @Override boolean stopCellEditing(); @Override void addCellEditorListener(CellEditorListener l); @Override void removeCellEditorListener(CellEditorListener l); }### Answer: @Test public void testFireEditingStopped() { CellEditorListener l = mock(CellEditorListener.class); editor.addCellEditorListener(l); editor.fireEditingStopped(); verify(l, times(1)).editingStopped((ChangeEvent) any()); }
### Question: AbstractCellEditor implements CellEditor { protected void fireEditingCanceled() { Object[] listeners = listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == CellEditorListener.class) { ((CellEditorListener) listeners[i + 1]).editingCanceled(new ChangeEvent(this)); } } } @Override Object getCellEditorValue(); @Override boolean isCellEditable(EventObject e); @Override boolean shouldSelectCell(EventObject anEvent); @Override boolean stopCellEditing(); @Override void addCellEditorListener(CellEditorListener l); @Override void removeCellEditorListener(CellEditorListener l); }### Answer: @Test public void testFireEditingCanceled() { CellEditorListener l = mock(CellEditorListener.class); editor.addCellEditorListener(l); editor.fireEditingCanceled(); verify(l, times(1)).editingCanceled((ChangeEvent) any()); }
### Question: CheckBoxJList extends JList implements ListSelectionListener { @SuppressWarnings("unchecked") public CheckBoxJList() { super(); selectionCache = new HashSet<Integer>(); setCellRenderer(new CheckBoxListCellRenderer()); addListSelectionListener(this); this.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { processClick(); } }); } @SuppressWarnings("unchecked") CheckBoxJList(); void setSelectedItems(final List<String> selected); @Override void valueChanged(ListSelectionEvent lse); static final String LIST_UPDATED; }### Answer: @Test public void testCheckBoxJList() { assertNotNull(list); }
### Question: CheckBoxJList extends JList implements ListSelectionListener { public void setSelectedItems(final List<String> selected) { final ListSelectionListener[] listeners = this.getListSelectionListeners(); for(ListSelectionListener l :listeners) removeListSelectionListener(l); getSelectionModel().clearSelection(); selectionCache.clear(); final int size = this.getModel().getSize(); for(int i=0; i<size; i++) { if(selected.contains(getModel().getElementAt(i))) { getSelectionModel().addSelectionInterval(i, i); selectionCache.add(i); } } for(ListSelectionListener l :listeners) addListSelectionListener(l); } @SuppressWarnings("unchecked") CheckBoxJList(); void setSelectedItems(final List<String> selected); @Override void valueChanged(ListSelectionEvent lse); static final String LIST_UPDATED; }### Answer: @Test public void testSetSelectedItems() { final List<String> selected = new ArrayList<String>(); DefaultListModel model = new DefaultListModel(); final String[] listItemStrings = new String[] {"test1", "test2", "test3"}; for(String item: listItemStrings) model.addElement(item); list.setModel(model); selected.add("test2"); list.setSelectedItems(selected); Object[] selectedVals = list.getSelectedValues(); assertEquals(1, selectedVals.length); selected.clear(); for(String item: listItemStrings) selected.add(item); list.setSelectedItems(selected); selectedVals = list.getSelectedValues(); assertEquals(3, selectedVals.length); selected.clear(); selected.add("invalid"); list.setSelectedItems(selected); selectedVals = list.getSelectedValues(); assertEquals(0, selectedVals.length); }
### Question: CheckBoxJList extends JList implements ListSelectionListener { @Override public void valueChanged(ListSelectionEvent lse) { if (!lse.getValueIsAdjusting()) { firstIndex = lse.getFirstIndex(); lastIndex = lse.getLastIndex(); removeListSelectionListener(this); final HashSet<Integer> newSelections = new HashSet<Integer>(); final int size = getModel().getSize(); final ListSelectionModel select = getSelectionModel(); for (int i = 0; i < size; i++) { if (select.isSelectedIndex(i)) newSelections.add(i); } for (Integer index : selectionCache) { select.addSelectionInterval(index, index); } for (Integer index : newSelections) { if (selectionCache.contains(index)) select.removeSelectionInterval(index, index); else select.addSelectionInterval(index, index); } selectionCache.clear(); for (int i = 0; i < size; i++) { if (select.isSelectedIndex(i)) selectionCache.add(i); } addListSelectionListener(this); firePropertyChange(LIST_UPDATED, null, null); } } @SuppressWarnings("unchecked") CheckBoxJList(); void setSelectedItems(final List<String> selected); @Override void valueChanged(ListSelectionEvent lse); static final String LIST_UPDATED; }### Answer: @Test public void testValueChanged() { final List<String> selected = new ArrayList<String>(); DefaultListModel model = new DefaultListModel(); final String[] listItemStrings = new String[] {"test1", "test2", "test3"}; for(String item: listItemStrings) model.addElement(item); list.setModel(model); for(String item: listItemStrings) selected.add(item); list.setSelectedItems(selected); ListSelectionEvent lse = mock(ListSelectionEvent.class); when(lse.getValueIsAdjusting()).thenReturn(false); list.valueChanged(lse); verify(lse, times(1)).getValueIsAdjusting(); }
### Question: DiscreteRange implements Range<T> { public DiscreteRange(final Class<T> type, final Set<T> values) { this.type = type; this.values = values; } DiscreteRange(final Class<T> type, final Set<T> values); @Override Class<T> getType(); @Override boolean isDiscrete(); Set<T> values(); void addRangeValue(final T newValue); @Override boolean inRange(T value); }### Answer: @Test public void testDiscreteRange() { final Set<String> rangeValues = new HashSet<String>(); rangeValues.add("a"); rangeValues.add("b"); rangeValues.add("c"); rangeValues.add("d"); rangeValues.add("e"); rangeValues.add("foo"); final DiscreteRange<String> range1 = new DiscreteRange<String>(String.class, rangeValues); assertEquals(6, range1.values().size()); assertTrue(range1.inRange("a")); assertTrue(range1.inRange("b")); assertTrue(range1.inRange("c")); assertTrue(range1.inRange("d")); assertTrue(range1.inRange("e")); assertFalse(range1.inRange("f")); assertTrue(range1.inRange("foo")); range1.addRangeValue("f"); assertEquals(7, range1.values().size()); assertTrue(range1.inRange("f")); }
### Question: BoundaryRangeValues { @Override public String toString() { return "{" + lesserValue + "," + equalValue + "," + greaterValue + "}"; } BoundaryRangeValues(T lesser, T equal, T greater); BoundaryRangeValues(final BoundaryRangeValues<T> original); @Override int hashCode(); @Override @SuppressWarnings("rawtypes") boolean equals(Object obj); @Override String toString(); final T lesserValue; final T equalValue; final T greaterValue; }### Answer: @Test public void testToString() { assertEquals("{-10.0,0.0,10.0}", brv1.toString()); assertEquals("{" + Color.red.toString() + "," + Color.WHITE.toString() + "," + Color.GREEN.toString() + "}", brv2.toString()); }
### Question: AbstractVisualProperty implements VisualProperty<T> { public AbstractVisualProperty(final T defaultValue, final Range<T> range, final String id, final String displayName, final Class<? extends CyIdentifiable> targetObjectDataType) { if (defaultValue == null) throw new NullPointerException("defaultValue should not be null."); if (id == null) throw new NullPointerException("id should not be null."); if (displayName == null) throw new NullPointerException("displayName should not be null."); this.range = range; this.defaultValue = defaultValue; this.id = id; this.name = displayName; this.shouldIgnoreDefault = false; this.targetObjectDataType = targetObjectDataType; } AbstractVisualProperty(final T defaultValue, final Range<T> range, final String id, final String displayName, final Class<? extends CyIdentifiable> targetObjectDataType); @Override Range<T> getRange(); @Override T getDefault(); @Override String getIdString(); @Override String getDisplayName(); @Override boolean shouldIgnoreDefault(); @Override Class<? extends CyIdentifiable> getTargetDataType(); @Override String toString(); }### Answer: @Test public void testAbstractVisualProperty() { assertNotNull(vp); }
### Question: AbstractVisualProperty implements VisualProperty<T> { @Override public Range<T> getRange() { return range; } AbstractVisualProperty(final T defaultValue, final Range<T> range, final String id, final String displayName, final Class<? extends CyIdentifiable> targetObjectDataType); @Override Range<T> getRange(); @Override T getDefault(); @Override String getIdString(); @Override String getDisplayName(); @Override boolean shouldIgnoreDefault(); @Override Class<? extends CyIdentifiable> getTargetDataType(); @Override String toString(); }### Answer: @Test public void testGetType() { assertEquals(range, vp.getRange()); }
### Question: FunctionUtil { public static double calcSampleVariance(final double[] x) { final int n = x.length; if (n < 2) throw new IllegalArgumentException("can't calculate a variance with fewer than 2 values."); final double[] xSquared = new double[n]; for (int i = 0; i < n; ++i) xSquared[i] = x[i] * x[i]; final double sumOfX = numericallySafeSum(x); final double sumOfXSquared = numericallySafeSum(xSquared); return (sumOfXSquared - (sumOfX * sumOfX) / (double)n) / (double)(n - 1); } private FunctionUtil(); static double getArgAsDouble(final Object arg); static String getArgAsString(final Object arg); static long getArgAsLong(final Object arg); static boolean getArgAsBoolean(final Object arg); static double numericallySafeSum(final double a[]); static String getOrdinal(final int i); static double calcSampleVariance(final double[] x); static double[] listToArray(final List<Double> a); static boolean isScalarArgType(final Class type); static boolean isTypeOfList(final Class listClassCandidate); static void addScalarArgumentTypes(final List<Class> argTypes); static double[] getDoubles(final Object[] args); static long[] getLongs(final Object[] args); static String[] getStrings(final Object[] args); static boolean[] getBooleans(final Object[] args); static Object translateObjectType(final Object input); }### Answer: @Test public void testCalcSampleVariance() { final double[] x = { 2.2, 2.2 }; assertEquals("calcSampleVariance() failed!", 0.0, FunctionUtil.calcSampleVariance(x), 0.0001); } @Test(expected=IllegalArgumentException.class) public void testCalcSampleVarianceWithIllegalArgument() { final double[] x = { 1.0 }; FunctionUtil.calcSampleVariance(x); }
### Question: FunctionUtil { public static double[] listToArray(final List<Double> a) { final double[] x = new double[a.size()]; int i = 0; for (double d : a) x[i++] = d; return x; } private FunctionUtil(); static double getArgAsDouble(final Object arg); static String getArgAsString(final Object arg); static long getArgAsLong(final Object arg); static boolean getArgAsBoolean(final Object arg); static double numericallySafeSum(final double a[]); static String getOrdinal(final int i); static double calcSampleVariance(final double[] x); static double[] listToArray(final List<Double> a); static boolean isScalarArgType(final Class type); static boolean isTypeOfList(final Class listClassCandidate); static void addScalarArgumentTypes(final List<Class> argTypes); static double[] getDoubles(final Object[] args); static long[] getLongs(final Object[] args); static String[] getStrings(final Object[] args); static boolean[] getBooleans(final Object[] args); static Object translateObjectType(final Object input); }### Answer: @Test public void testListToArray() { final List<Double> dl = new ArrayList<Double>(); dl.add(-1.0); dl.add(2.0); final double[] expectedArray = { -1.0, 2.0 }; assertArrayEquals("listToArray() failed!", expectedArray, FunctionUtil.listToArray(dl), 0.0001); }
### Question: FunctionUtil { public static boolean isScalarArgType(final Class type) { return type == Double.class || type == Long.class || type == String.class || type == Boolean.class; } private FunctionUtil(); static double getArgAsDouble(final Object arg); static String getArgAsString(final Object arg); static long getArgAsLong(final Object arg); static boolean getArgAsBoolean(final Object arg); static double numericallySafeSum(final double a[]); static String getOrdinal(final int i); static double calcSampleVariance(final double[] x); static double[] listToArray(final List<Double> a); static boolean isScalarArgType(final Class type); static boolean isTypeOfList(final Class listClassCandidate); static void addScalarArgumentTypes(final List<Class> argTypes); static double[] getDoubles(final Object[] args); static long[] getLongs(final Object[] args); static String[] getStrings(final Object[] args); static boolean[] getBooleans(final Object[] args); static Object translateObjectType(final Object input); }### Answer: @Test public void testIsScalarArgTypeWithADoubleArgument() { assertTrue("isScalarArgType() failed!", FunctionUtil.isScalarArgType(Double.class)); } @Test public void testIsScalarArgTypeWithALongArgument() { assertTrue("isScalarArgType() failed!", FunctionUtil.isScalarArgType(Long.class)); } @Test public void testIsScalarArgTypeWithAStringArgument() { assertTrue("isScalarArgType() failed!", FunctionUtil.isScalarArgType(String.class)); } @Test public void testIsScalarArgTypeWithABooleanArgument() { assertTrue("isScalarArgType() failed!", FunctionUtil.isScalarArgType(Boolean.class)); } @Test public void testIsScalarArgTypeWithAnIntegerArgument() { assertFalse("isScalarArgType() failed!", FunctionUtil.isScalarArgType(Integer.class)); } @Test public void testIsScalarArgTypeWithAListArgument() { assertFalse("isScalarArgType() failed!", FunctionUtil.isScalarArgType(ArrayList.class)); }
### Question: AbstractVisualProperty implements VisualProperty<T> { @Override public T getDefault() { return defaultValue; } AbstractVisualProperty(final T defaultValue, final Range<T> range, final String id, final String displayName, final Class<? extends CyIdentifiable> targetObjectDataType); @Override Range<T> getRange(); @Override T getDefault(); @Override String getIdString(); @Override String getDisplayName(); @Override boolean shouldIgnoreDefault(); @Override Class<? extends CyIdentifiable> getTargetDataType(); @Override String toString(); }### Answer: @Test public void testGetDefault() { assertEquals(defaultVal, vp.getDefault()); }
### Question: AbstractVisualProperty implements VisualProperty<T> { @Override public String getIdString() { return id; } AbstractVisualProperty(final T defaultValue, final Range<T> range, final String id, final String displayName, final Class<? extends CyIdentifiable> targetObjectDataType); @Override Range<T> getRange(); @Override T getDefault(); @Override String getIdString(); @Override String getDisplayName(); @Override boolean shouldIgnoreDefault(); @Override Class<? extends CyIdentifiable> getTargetDataType(); @Override String toString(); }### Answer: @Test public void testGetIdString() { assertEquals(id, vp.getIdString()); }
### Question: FunctionUtil { public static void addScalarArgumentTypes(final List<Class> argTypes) { argTypes.add(Double.class); argTypes.add(Long.class); argTypes.add(String.class); argTypes.add(Boolean.class); } private FunctionUtil(); static double getArgAsDouble(final Object arg); static String getArgAsString(final Object arg); static long getArgAsLong(final Object arg); static boolean getArgAsBoolean(final Object arg); static double numericallySafeSum(final double a[]); static String getOrdinal(final int i); static double calcSampleVariance(final double[] x); static double[] listToArray(final List<Double> a); static boolean isScalarArgType(final Class type); static boolean isTypeOfList(final Class listClassCandidate); static void addScalarArgumentTypes(final List<Class> argTypes); static double[] getDoubles(final Object[] args); static long[] getLongs(final Object[] args); static String[] getStrings(final Object[] args); static boolean[] getBooleans(final Object[] args); static Object translateObjectType(final Object input); }### Answer: @Test public void testAddScalarArgumentTypes() { final List<Class> argTypes = new ArrayList<Class>(); argTypes.add(Integer.class); FunctionUtil.addScalarArgumentTypes(argTypes); assertTrue("addScalarArgumentTypes() failed!", argTypes.contains(Double.class)); assertTrue("addScalarArgumentTypes() failed!", argTypes.contains(Long.class)); assertTrue("addScalarArgumentTypes() failed!", argTypes.contains(String.class)); assertTrue("addScalarArgumentTypes() failed!", argTypes.contains(Boolean.class)); }
### Question: FunctionUtil { public static String[] getStrings(final Object[] args) { final List<String> strings = new ArrayList<String>(); for (final Object arg : args) { if (arg instanceof List) { final List list = (List)arg; for (final Object listElement : list) strings.add(getArgAsString(listElement)); } else strings.add(getArgAsString(arg)); } final String[] retVal = new String[strings.size()]; return strings.toArray(retVal); } private FunctionUtil(); static double getArgAsDouble(final Object arg); static String getArgAsString(final Object arg); static long getArgAsLong(final Object arg); static boolean getArgAsBoolean(final Object arg); static double numericallySafeSum(final double a[]); static String getOrdinal(final int i); static double calcSampleVariance(final double[] x); static double[] listToArray(final List<Double> a); static boolean isScalarArgType(final Class type); static boolean isTypeOfList(final Class listClassCandidate); static void addScalarArgumentTypes(final List<Class> argTypes); static double[] getDoubles(final Object[] args); static long[] getLongs(final Object[] args); static String[] getStrings(final Object[] args); static boolean[] getBooleans(final Object[] args); static Object translateObjectType(final Object input); }### Answer: @Test public void testGetStrings() { final List<Object> misc = new ArrayList<Object>(); misc.add(Long.valueOf(1L)); misc.add(-0.3); final Object[] args = { misc, Boolean.valueOf(false) }; final String[] expectedValues = { "1", "-0.3", "FALSE" }; try { assertArrayEquals("getStrings() failed!", expectedValues, FunctionUtil.getStrings(args)); } catch (final Exception e) { fail("getStrings() failed!"); } }
### Question: AbstractVisualProperty implements VisualProperty<T> { @Override public String getDisplayName() { return name; } AbstractVisualProperty(final T defaultValue, final Range<T> range, final String id, final String displayName, final Class<? extends CyIdentifiable> targetObjectDataType); @Override Range<T> getRange(); @Override T getDefault(); @Override String getIdString(); @Override String getDisplayName(); @Override boolean shouldIgnoreDefault(); @Override Class<? extends CyIdentifiable> getTargetDataType(); @Override String toString(); }### Answer: @Test public void testGetDisplayName() { assertNotNull(vp.getDisplayName()); assertEquals(displayName, vp.getDisplayName()); }
### Question: AbstractFunction implements Function { public final String getUsageDescription() { final StringBuilder usage = new StringBuilder("Call with "); usage.append(getName()); usage.append('('); int optArgCount = 0; boolean isFirst = true; for (final ArgDescriptor argDescriptor : argDescriptors) { if (argDescriptor.isOptional()) { usage.append(isFirst ? "[" : " [,"); ++optArgCount; } else usage.append(isFirst ? "" : " ,"); usage.append(argDescriptor.getArgName()); isFirst = false; } for (int i = 0; i < optArgCount; ++i) usage.append(']'); usage.append(")."); return usage.toString(); } protected AbstractFunction(final ArgDescriptor[] argDescriptors); abstract String getName(); abstract String getFunctionSummary(); final String getUsageDescription(); abstract Class getReturnType(); Class validateArgTypes(final Class[] argTypes); abstract Object evaluateFunction(final Object[] args); final List<Class<?>> getPossibleArgTypes(final Class[] leadingArgs); }### Answer: @Test public void testGetUsageDescription() { final String usage = sf.getUsageDescription(); assertTrue("The usage description was either null or the empty string.", usage != null && !usage.isEmpty()); }
### Question: AbstractFunction implements Function { public Class validateArgTypes(final Class[] argTypes) { return argTypesAreValid(argTypes) ? getReturnType() : null; } protected AbstractFunction(final ArgDescriptor[] argDescriptors); abstract String getName(); abstract String getFunctionSummary(); final String getUsageDescription(); abstract Class getReturnType(); Class validateArgTypes(final Class[] argTypes); abstract Object evaluateFunction(final Object[] args); final List<Class<?>> getPossibleArgTypes(final Class[] leadingArgs); }### Answer: @Test public void testValidateArgTypes() { final Class<?>[] argTypes = { Double.class, Double.class }; assertEquals("The validateArgTypes() method is buggy.", sf.getReturnType(), sf.validateArgTypes(argTypes)); } @Test public void testValidateArgTypesWithBadArgs() { final Class<?>[] argTypes = { List.class, List.class }; assertNull("The validateArgTypes() method is buggy.", sf.validateArgTypes(argTypes)); } @Test public void testValidateArgTypesWithTooManyArgs() { final Class<?>[] argTypes = { Double.class, Double.class, List.class }; assertNull("The validateArgTypes() method is buggy.", sf.validateArgTypes(argTypes)); }
### Question: AbstractVisualProperty implements VisualProperty<T> { @Override public boolean shouldIgnoreDefault() { return this.shouldIgnoreDefault; } AbstractVisualProperty(final T defaultValue, final Range<T> range, final String id, final String displayName, final Class<? extends CyIdentifiable> targetObjectDataType); @Override Range<T> getRange(); @Override T getDefault(); @Override String getIdString(); @Override String getDisplayName(); @Override boolean shouldIgnoreDefault(); @Override Class<? extends CyIdentifiable> getTargetDataType(); @Override String toString(); }### Answer: @Test public void testIsIgnoreDefault() { assertEquals(ignore, vp.shouldIgnoreDefault()); }
### Question: CodeAndSourceLocation { public Object getCode() { return code; } CodeAndSourceLocation(final Object code, final int sourceLocation); Object getCode(); int getSourceLocation(); }### Answer: @Test public void testGetCode() { assertEquals("getCode() is broken.", code, casl.getCode()); }
### Question: CodeAndSourceLocation { public int getSourceLocation() { return sourceLocation; } CodeAndSourceLocation(final Object code, final int sourceLocation); Object getCode(); int getSourceLocation(); }### Answer: @Test public void testGetSourceLocation() { assertEquals("getSourceLocation() is broken.", 25, casl.getSourceLocation()); }
### Question: ArgDescriptor { public ArgType getArgType() { return argType; } ArgDescriptor(final ArgType argType, final String argName, final String description); ArgType getArgType(); String getArgName(); String getDescription(); boolean isOptional(); boolean isCompatibleWith(final Class type); boolean isCompatibleList(final Class listElementType); Class[] getCompatibleTypes(); boolean acceptsMultipleArgs(); }### Answer: @Test public void testGetArgType() { assertEquals("getArgType() is broken.", ArgType.INT, argDesc.getArgType()); }
### Question: ArgDescriptor { public String getDescription() { return description; } ArgDescriptor(final ArgType argType, final String argName, final String description); ArgType getArgType(); String getArgName(); String getDescription(); boolean isOptional(); boolean isCompatibleWith(final Class type); boolean isCompatibleList(final Class listElementType); Class[] getCompatibleTypes(); boolean acceptsMultipleArgs(); }### Answer: @Test public void testGetDescription() { assertEquals("getDescription() is broken.", "A fine int.", argDesc.getDescription()); }
### Question: ArgDescriptor { public boolean isCompatibleWith(final Class type) { for (final Class compatibleType : argType.getCompatibleTypes()) { if (type == compatibleType) return true; if (List.class.equals(compatibleType) && List.class.isAssignableFrom(type)) return true; } return false; } ArgDescriptor(final ArgType argType, final String argName, final String description); ArgType getArgType(); String getArgName(); String getDescription(); boolean isOptional(); boolean isCompatibleWith(final Class type); boolean isCompatibleList(final Class listElementType); Class[] getCompatibleTypes(); boolean acceptsMultipleArgs(); }### Answer: @Test public void testIsCompatibleWithWithACompatibleType() { assertTrue("isCompatibleWith() is broken.", argDesc.isCompatibleWith(Long.class)); } @Test public void testIsCompatibleWithWithAnIncompatibleType() { assertFalse("isCompatibleWith() is broken.", argDesc.isCompatibleWith(List.class)); } @Test public void testIsCompatibleWithWithAnIncompatibleListType() { assertFalse("isCompatibleWith() is broken.", argDesc.isCompatibleWith(List.class)); }
### Question: VisualLexiconNode implements Comparable<VisualLexiconNode> { public VisualProperty<?> getVisualProperty() { return vp; } VisualLexiconNode(final VisualProperty<?> vp, final VisualLexiconNode parent); VisualProperty<?> getVisualProperty(); VisualLexiconNode getParent(); Collection<VisualLexiconNode> getChildren(); @Override int compareTo(VisualLexiconNode other); void visitDescendants(Consumer<VisualLexiconNode> visitor); }### Answer: @Test public void testGetVisualProperty() { assertEquals(vp1, node1.getVisualProperty()); assertEquals(vp2, node2.getVisualProperty()); assertEquals(vp3, node3.getVisualProperty()); }
### Question: ArgDescriptor { public boolean isCompatibleList(final Class listElementType) { if (listElementType != null) { for (final Class compatibleType : argType.getCompatibleTypes()) { if (compatibleType == listElementType) return true; } return false; } for (final Class compatibleType : argType.getCompatibleTypes()) { if (FunctionUtil.isTypeOfList(compatibleType)) return true; } return false; } ArgDescriptor(final ArgType argType, final String argName, final String description); ArgType getArgType(); String getArgName(); String getDescription(); boolean isOptional(); boolean isCompatibleWith(final Class type); boolean isCompatibleList(final Class listElementType); Class[] getCompatibleTypes(); boolean acceptsMultipleArgs(); }### Answer: @Test public void testAnArgDescriptorThatTakesAList() { final ArgDescriptor listArgDesc = new ArgDescriptor(ArgType.STRINGS, "strings", "A list of strings."); assertTrue("isCompatibleList() is broken.", listArgDesc.isCompatibleList(String.class)); assertFalse("isCompatibleList() is broken.", listArgDesc.isCompatibleList(Object.class)); }
### Question: Equation { @Override public String toString() { return equation; } Equation(final String equation, final Set<String> variableReferences, final Map<String, Object> defaultVariableValues, final Object[] code, final int[] sourceLocations, final Class<?> type); @Override String toString(); @Override boolean equals(final Object other); @Override int hashCode(); Set<String> getVariableReferences(); Map<String, Object> getDefaultVariableValues(); Object[] getCode(); int[] getSourceLocations(); Class<?> getType(); }### Answer: @Test public void testToString() { assertEquals("toString() failed.", "=$A+$B", eqn.toString()); }
### Question: Equation { public Set<String> getVariableReferences() { return variableReferences; } Equation(final String equation, final Set<String> variableReferences, final Map<String, Object> defaultVariableValues, final Object[] code, final int[] sourceLocations, final Class<?> type); @Override String toString(); @Override boolean equals(final Object other); @Override int hashCode(); Set<String> getVariableReferences(); Map<String, Object> getDefaultVariableValues(); Object[] getCode(); int[] getSourceLocations(); Class<?> getType(); }### Answer: @Test public void testGetVariableReferences() { assertEquals("getVariableReferences() failed.", variableReferences, eqn.getVariableReferences()); }
### Question: Equation { public Object[] getCode() { return code; } Equation(final String equation, final Set<String> variableReferences, final Map<String, Object> defaultVariableValues, final Object[] code, final int[] sourceLocations, final Class<?> type); @Override String toString(); @Override boolean equals(final Object other); @Override int hashCode(); Set<String> getVariableReferences(); Map<String, Object> getDefaultVariableValues(); Object[] getCode(); int[] getSourceLocations(); Class<?> getType(); }### Answer: @Test public void testGetCode() { assertArrayEquals("getCode() failed.", code, eqn.getCode()); }
### Question: Equation { public int[] getSourceLocations() { return sourceLocations; } Equation(final String equation, final Set<String> variableReferences, final Map<String, Object> defaultVariableValues, final Object[] code, final int[] sourceLocations, final Class<?> type); @Override String toString(); @Override boolean equals(final Object other); @Override int hashCode(); Set<String> getVariableReferences(); Map<String, Object> getDefaultVariableValues(); Object[] getCode(); int[] getSourceLocations(); Class<?> getType(); }### Answer: @Test public void testGetSourceLocations() { assertArrayEquals("getSourceLocations() failed.", sourceLocations, eqn.getSourceLocations()); }
### Question: Equation { public Class<?> getType() { return type; } Equation(final String equation, final Set<String> variableReferences, final Map<String, Object> defaultVariableValues, final Object[] code, final int[] sourceLocations, final Class<?> type); @Override String toString(); @Override boolean equals(final Object other); @Override int hashCode(); Set<String> getVariableReferences(); Map<String, Object> getDefaultVariableValues(); Object[] getCode(); int[] getSourceLocations(); Class<?> getType(); }### Answer: @Test public void testGetType() { assertEquals("getType() failed.", Long.class, eqn.getType()); }
### Question: Equation { @Override public boolean equals(final Object other) { if (other == null || other.getClass() != Equation.class) return false; final Equation otherEquation = (Equation)other; return equation.equals(otherEquation.equation); } Equation(final String equation, final Set<String> variableReferences, final Map<String, Object> defaultVariableValues, final Object[] code, final int[] sourceLocations, final Class<?> type); @Override String toString(); @Override boolean equals(final Object other); @Override int hashCode(); Set<String> getVariableReferences(); Map<String, Object> getDefaultVariableValues(); Object[] getCode(); int[] getSourceLocations(); Class<?> getType(); }### Answer: @Test public void testEqualsWithExpectedSuccess() { final Equation other = new Equation("=$A+$B", variableReferences, new TreeMap<String, Object>(), code, sourceLocations, Long.class); assertTrue("equals() failed.", eqn.equals(other)); } @Test public void testEqualsWithExpectedFailure() { final Object other = new Integer(12); assertFalse("equals() failed.", eqn.equals(other)); }
### Question: FunctionError extends Exception { public int getArgNumber() { return argNumber; } FunctionError(final String message, final int argNumber); int getArgNumber(); }### Answer: @Test public void testGetArgNumber() { final FunctionError fe = new FunctionError("some message", 17); assertEquals("getArgNumber() failed!", 17, fe.getArgNumber()); }
### Question: VisualLexiconNode implements Comparable<VisualLexiconNode> { public VisualLexiconNode getParent() { return parent; } VisualLexiconNode(final VisualProperty<?> vp, final VisualLexiconNode parent); VisualProperty<?> getVisualProperty(); VisualLexiconNode getParent(); Collection<VisualLexiconNode> getChildren(); @Override int compareTo(VisualLexiconNode other); void visitDescendants(Consumer<VisualLexiconNode> visitor); }### Answer: @Test public void testGetParent() { assertNull(node1.getParent()); assertEquals(node1, node2.getParent()); assertEquals(node2, node3.getParent()); }
### Question: EquationUtil { public static String attribNameAsReference(final String attribName) { if (isSimpleAttribName(attribName)) return "$" + attribName; else return "${" + escapeAttribName(attribName) + "}"; } private EquationUtil(); static String attribNameAsReference(final String attribName); static long doubleToLong(final double d); static void refreshEquations(CyTable table, EquationCompiler compiler); static boolean eqnTypeIsCompatible(final Class<?> columnType, final Class<?> listElementType, final Class<?> eqnType); static String getUnqualifiedName(final Class<?> type); }### Answer: @Test public void testAttribNameAsReferenceWithSimpleName() { assertEquals("attribNameAsReference failed!", "$simple", EquationUtil.attribNameAsReference("simple")); } @Test public void testAttribNameAsReferenceWithComplexName() { assertEquals("attribNameAsReference failed!", "${not\\ so\\ simple}", EquationUtil.attribNameAsReference("not so simple")); } @Test(expected=Exception.class) public void testAttribNameAsReferenceWithEmptyName() { EquationUtil.attribNameAsReference(""); }
### Question: EquationUtil { public static long doubleToLong(final double d) { if (d > Long.MAX_VALUE || d < Long.MIN_VALUE) throw new IllegalArgumentException("floating point value is too large to be converted to a Long."); double x = ((Double)d).longValue(); if (x != d && d < 0.0) --x; return (long)x; } private EquationUtil(); static String attribNameAsReference(final String attribName); static long doubleToLong(final double d); static void refreshEquations(CyTable table, EquationCompiler compiler); static boolean eqnTypeIsCompatible(final Class<?> columnType, final Class<?> listElementType, final Class<?> eqnType); static String getUnqualifiedName(final Class<?> type); }### Answer: @Test public void testDoubleToLongWithValidArgument() { assertEquals("doubleToLong() failed!", 12L, EquationUtil.doubleToLong(12.3)); } @Test public void testDoubleToLongWithNegativeValidArgument() { assertEquals("doubleToLong() failed!", -13L, EquationUtil.doubleToLong(-12.3)); } @Test(expected=IllegalArgumentException.class) public void testDoubleToLongWithInvalidArgument() { EquationUtil.doubleToLong(Double.MAX_VALUE); }
### Question: IdentDescriptor { public Object getValue() { return value; } IdentDescriptor(final Object o); Class getType(); Object getValue(); }### Answer: @Test public void testIntegerToLongMapping() { final IdentDescriptor id = new IdentDescriptor(Integer.valueOf(-108)); assertEquals("Integer to Long translation is broken!", -108L, id.getValue()); } @Test public void testConstructionWithLong() { final IdentDescriptor id = new IdentDescriptor(Long.valueOf(8L)); assertEquals("Construction with Long is broken!", 8L, id.getValue()); } @Test public void testConstructionWithBoolean() { final IdentDescriptor id = new IdentDescriptor(Boolean.valueOf(false)); assertEquals("Construction with Boolean is broken!", false, id.getValue()); } @Test public void testConstructionWithDouble() { final IdentDescriptor id = new IdentDescriptor(Double.valueOf(2e-13)); assertEquals("Construction with Double is broken!", 2e-13, id.getValue()); } @Test public void testConstructionWithString() { final IdentDescriptor id = new IdentDescriptor("abc"); assertEquals("Construction with Long is broken!", "abc", id.getValue()); }
### Question: VisualLexiconNode implements Comparable<VisualLexiconNode> { public Collection<VisualLexiconNode> getChildren() { return children; } VisualLexiconNode(final VisualProperty<?> vp, final VisualLexiconNode parent); VisualProperty<?> getVisualProperty(); VisualLexiconNode getParent(); Collection<VisualLexiconNode> getChildren(); @Override int compareTo(VisualLexiconNode other); void visitDescendants(Consumer<VisualLexiconNode> visitor); }### Answer: @Test public void testGetChildren() { assertEquals(1, node1.getChildren().size()); assertEquals(1, node2.getChildren().size()); assertEquals(0, node3.getChildren().size()); }
### Question: IdentDescriptor { public Class getType() { return type; } IdentDescriptor(final Object o); Class getType(); Object getValue(); }### Answer: @Test public void testConstructionWithAListTypeAndGetType() { final IdentDescriptor id = new IdentDescriptor(new ArrayList<String>()); assertEquals("Construction with a List type is broken!", List.class, id.getType()); }
### Question: SimpleGUITunableHandlerFactory extends BasicTunableHandlerFactory<T> implements GUITunableHandlerFactory<T> { public SimpleGUITunableHandlerFactory(Class<T> specificHandlerType, Class<?>... classesToMatch ) { super(specificHandlerType, classesToMatch); } SimpleGUITunableHandlerFactory(Class<T> specificHandlerType, Class<?>... classesToMatch ); }### Answer: @Test public void testSimpleGUITunableHandlerFactory() { assertNotNull(factory); }
### Question: UserAction { public void setActionListener(final ActionListener actionListener) { this.actionListener = actionListener; enabled = actionListener != null; } UserAction(final ActionListener actionListener); ActionListener getActionListener(); void setActionListener(final ActionListener actionListener); boolean getEnabled(); void setEnabled(boolean enabled); }### Answer: @Test public void testSetActionListener() { UserAction ua = new UserAction(null); ActionListener listener = (e -> {}); ua.setActionListener(listener); assertEquals(listener, ua.getActionListener()); assertTrue(ua.getEnabled()); }
### Question: AbstractGUITunableHandler extends AbstractTunableHandler implements GUITunableHandler { @Override public String getState() { try { final Object value = getValue(); return value == null ? "" : value.toString(); } catch (final Exception e) { logger.warn("Could not get state.", e); return ""; } } protected AbstractGUITunableHandler(final Field field, final Object instance, final Tunable tunable); protected AbstractGUITunableHandler(final Method getter, final Method setter, final Object instance, final Tunable tunable); @Override void setValue(final Object newValue); @Override void notifyDependents(); @Override void notifyChangeListeners(); @Override void addChangeListener(GUITunableHandler gh); @Override void addDependent(GUITunableHandler gh); @Override String getDependency(); @Override String[] getChangeSources(); @Override final void changeOccurred(final String name, final String state); @Override final void checkDependency(final String depName, final String depState); @Override JPanel getJPanel(); @Override abstract void handle(); @Override void update(); @Override String getState(); boolean isHorizontal(); }### Answer: @Test public void testFieldConstructor() throws Exception { assertEquals("Unexpected return value from getState()!", "42", fieldHandler.getState()); } @Test public void testMethodConstructor() throws Exception { assertEquals("Unexpected return value from getState()!", "47", methodHandler.getState()); } @Test public void testGetState() { assertEquals("42", fieldHandler.getState()); }
### Question: AbstractGUITunableHandler extends AbstractTunableHandler implements GUITunableHandler { @Override public JPanel getJPanel() { return panel; } protected AbstractGUITunableHandler(final Field field, final Object instance, final Tunable tunable); protected AbstractGUITunableHandler(final Method getter, final Method setter, final Object instance, final Tunable tunable); @Override void setValue(final Object newValue); @Override void notifyDependents(); @Override void notifyChangeListeners(); @Override void addChangeListener(GUITunableHandler gh); @Override void addDependent(GUITunableHandler gh); @Override String getDependency(); @Override String[] getChangeSources(); @Override final void changeOccurred(final String name, final String state); @Override final void checkDependency(final String depName, final String depState); @Override JPanel getJPanel(); @Override abstract void handle(); @Override void update(); @Override String getState(); boolean isHorizontal(); }### Answer: @Test public void testFieldGetJPanel() throws Exception { assertNotNull("getJPanel() must *not* return null!", fieldHandler.getJPanel()); } @Test public void testMethodGetJPanel() throws Exception { assertNotNull("getJPanel() must *not* return null!", methodHandler.getJPanel()); } @Test public void testGetJPanel() { assertNotNull(fieldHandler.getJPanel()); }
### Question: AbstractGUITunableHandler extends AbstractTunableHandler implements GUITunableHandler { @Override public void notifyChangeListeners() { String state = getState(); String name = getName(); for (GUITunableHandler gh : listeners) { notifyingListeners = true; gh.changeOccurred(name, state); notifyingListeners = false; } } protected AbstractGUITunableHandler(final Field field, final Object instance, final Tunable tunable); protected AbstractGUITunableHandler(final Method getter, final Method setter, final Object instance, final Tunable tunable); @Override void setValue(final Object newValue); @Override void notifyDependents(); @Override void notifyChangeListeners(); @Override void addChangeListener(GUITunableHandler gh); @Override void addDependent(GUITunableHandler gh); @Override String getDependency(); @Override String[] getChangeSources(); @Override final void changeOccurred(final String name, final String state); @Override final void checkDependency(final String depName, final String depState); @Override JPanel getJPanel(); @Override abstract void handle(); @Override void update(); @Override String getState(); boolean isHorizontal(); }### Answer: @Test public void testNotifyChangeListeners() throws Exception { methodHandler.addChangeListener(methodHandlerS); methodHandler.notifyChangeListeners(); assertTrue(methodHandlerS.testUpdateCalled); }
### Question: AbstractGUITunableHandler extends AbstractTunableHandler implements GUITunableHandler { @Override public String[] getChangeSources() { return listenForChange(); } protected AbstractGUITunableHandler(final Field field, final Object instance, final Tunable tunable); protected AbstractGUITunableHandler(final Method getter, final Method setter, final Object instance, final Tunable tunable); @Override void setValue(final Object newValue); @Override void notifyDependents(); @Override void notifyChangeListeners(); @Override void addChangeListener(GUITunableHandler gh); @Override void addDependent(GUITunableHandler gh); @Override String getDependency(); @Override String[] getChangeSources(); @Override final void changeOccurred(final String name, final String state); @Override final void checkDependency(final String depName, final String depState); @Override JPanel getJPanel(); @Override abstract void handle(); @Override void update(); @Override String getState(); boolean isHorizontal(); }### Answer: @Test public void testGetChangeSources() throws Exception { assertEquals("AnnotatedInt", methodHandlerS.getChangeSources()[0]); } @Test public void testEmptyGetChangeSources() throws Exception { assertEquals(0, methodHandler.getChangeSources().length); }
### Question: AddedEdgeViewsEvent extends AbstractCyPayloadEvent<CyNetworkView,View<CyEdge>> { public Collection<View<CyEdge>> getEdgeViews() { return getPayloadCollection(); } AddedEdgeViewsEvent(final CyNetworkView source, final Collection<View<CyEdge>> edgeViews); Collection<View<CyEdge>> getEdgeViews(); }### Answer: @Test public void testEvents() { AddedEdgeViewsEvent ev1 = new AddedEdgeViewsEvent(networkView, views); for ( View<CyEdge> ev : ev1.getEdgeViews()) assertTrue(views.contains(ev)); assertEquals(ev1.getSource(),networkView); } @Test public void testEmptyPayload() { Collection<View<CyEdge>> vs = new ArrayList<View<CyEdge>>(); AddedEdgeViewsEvent ev1 = new AddedEdgeViewsEvent(networkView, vs); assertEquals(0, ev1.getEdgeViews().size()); }
### Question: AbstractVisualMappingFunction implements VisualMappingFunction<K, V> { public AbstractVisualMappingFunction(final String columnName, final Class<K> columnType, final VisualProperty<V> vp, final CyEventHelper eventHelper) { this.columnType = columnType; this.columnName = columnName; this.vp = vp; this.eventHelper = eventHelper; } AbstractVisualMappingFunction(final String columnName, final Class<K> columnType, final VisualProperty<V> vp, final CyEventHelper eventHelper); @Override String getMappingColumnName(); @Override Class<K> getMappingColumnType(); @Override VisualProperty<V> getVisualProperty(); @Override void apply(final CyRow row, final View<? extends CyIdentifiable> view); }### Answer: @Test public void testAbstractVisualMappingFunction() { assertNotNull(function); }
### Question: AbstractGUITunableHandler extends AbstractTunableHandler implements GUITunableHandler { @Override public void setValue(final Object newValue) throws IllegalAccessException, InvocationTargetException{ super.setValue(newValue); notifyDependents(); notifyChangeListeners(); } protected AbstractGUITunableHandler(final Field field, final Object instance, final Tunable tunable); protected AbstractGUITunableHandler(final Method getter, final Method setter, final Object instance, final Tunable tunable); @Override void setValue(final Object newValue); @Override void notifyDependents(); @Override void notifyChangeListeners(); @Override void addChangeListener(GUITunableHandler gh); @Override void addDependent(GUITunableHandler gh); @Override String getDependency(); @Override String[] getChangeSources(); @Override final void changeOccurred(final String name, final String state); @Override final void checkDependency(final String depName, final String depState); @Override JPanel getJPanel(); @Override abstract void handle(); @Override void update(); @Override String getState(); boolean isHorizontal(); }### Answer: @Test(expected=IllegalArgumentException.class) public void testSetValue() throws Exception { fieldHandler.setValue(null); }
### Question: AbstractGUITunableHandler extends AbstractTunableHandler implements GUITunableHandler { @Override public void notifyDependents() { String state = getState(); String name = getName(); for (GUITunableHandler gh : dependents) gh.checkDependency(name, state); } protected AbstractGUITunableHandler(final Field field, final Object instance, final Tunable tunable); protected AbstractGUITunableHandler(final Method getter, final Method setter, final Object instance, final Tunable tunable); @Override void setValue(final Object newValue); @Override void notifyDependents(); @Override void notifyChangeListeners(); @Override void addChangeListener(GUITunableHandler gh); @Override void addDependent(GUITunableHandler gh); @Override String getDependency(); @Override String[] getChangeSources(); @Override final void changeOccurred(final String name, final String state); @Override final void checkDependency(final String depName, final String depState); @Override JPanel getJPanel(); @Override abstract void handle(); @Override void update(); @Override String getState(); boolean isHorizontal(); }### Answer: @Test public void testNotifyDependents() { GUITunableHandler gh = mock(GUITunableHandler.class); fieldHandler.addDependent(gh); fieldHandler.notifyDependents(); verify(gh, times(1)).checkDependency(anyString(), anyString()); }
### Question: AbstractGUITunableHandler extends AbstractTunableHandler implements GUITunableHandler { @Override public void addChangeListener(GUITunableHandler gh) { if (!listeners.contains(gh)) { if (notifyingListeners) { GUITunableHandler old = getListenerFor(gh.getQualifiedName()); if (old != null) { listeners = new LinkedList<>(listeners); listeners.remove(old); } } listeners.add(gh); } } protected AbstractGUITunableHandler(final Field field, final Object instance, final Tunable tunable); protected AbstractGUITunableHandler(final Method getter, final Method setter, final Object instance, final Tunable tunable); @Override void setValue(final Object newValue); @Override void notifyDependents(); @Override void notifyChangeListeners(); @Override void addChangeListener(GUITunableHandler gh); @Override void addDependent(GUITunableHandler gh); @Override String getDependency(); @Override String[] getChangeSources(); @Override final void changeOccurred(final String name, final String state); @Override final void checkDependency(final String depName, final String depState); @Override JPanel getJPanel(); @Override abstract void handle(); @Override void update(); @Override String getState(); boolean isHorizontal(); }### Answer: @Test public void testAddChangeListener() { GUITunableHandler gh = mock(GUITunableHandler.class); fieldHandler.addChangeListener(gh); fieldHandler.notifyChangeListeners(); verify(gh, times(1)).changeOccurred(anyString(), anyString()); }
### Question: AbstractGUITunableHandler extends AbstractTunableHandler implements GUITunableHandler { @Override public String getDependency() { return dependencyName; } protected AbstractGUITunableHandler(final Field field, final Object instance, final Tunable tunable); protected AbstractGUITunableHandler(final Method getter, final Method setter, final Object instance, final Tunable tunable); @Override void setValue(final Object newValue); @Override void notifyDependents(); @Override void notifyChangeListeners(); @Override void addChangeListener(GUITunableHandler gh); @Override void addDependent(GUITunableHandler gh); @Override String getDependency(); @Override String[] getChangeSources(); @Override final void changeOccurred(final String name, final String state); @Override final void checkDependency(final String depName, final String depState); @Override JPanel getJPanel(); @Override abstract void handle(); @Override void update(); @Override String getState(); boolean isHorizontal(); }### Answer: @Test public void testGetDependency() { assertNotNull(fieldHandler.getDependency()); }
### Question: AbstractGUITunableHandler extends AbstractTunableHandler implements GUITunableHandler { @Override public final void changeOccurred(final String name, final String state) { update(); } protected AbstractGUITunableHandler(final Field field, final Object instance, final Tunable tunable); protected AbstractGUITunableHandler(final Method getter, final Method setter, final Object instance, final Tunable tunable); @Override void setValue(final Object newValue); @Override void notifyDependents(); @Override void notifyChangeListeners(); @Override void addChangeListener(GUITunableHandler gh); @Override void addDependent(GUITunableHandler gh); @Override String getDependency(); @Override String[] getChangeSources(); @Override final void changeOccurred(final String name, final String state); @Override final void checkDependency(final String depName, final String depState); @Override JPanel getJPanel(); @Override abstract void handle(); @Override void update(); @Override String getState(); boolean isHorizontal(); }### Answer: @Test public void testChangeOccurred() { String name = "test name"; String state = "test state"; fieldHandler.changeOccurred(name, state); }
### Question: AbstractGUITunableHandler extends AbstractTunableHandler implements GUITunableHandler { @Override public final void checkDependency(final String depName, final String depState) { if (dependencyName == null || mustMatch == null) { setEnabledContainer(true, panel); return; } if (dependencyName.equals(depName)) { if (!mustMatch.isEmpty()) { if (mustMatch.equals(depState)) setEnabledContainer(true, panel); else setEnabledContainer(false, panel); } else { if (!mustNotMatch.equals(depState)) setEnabledContainer(true, panel); else setEnabledContainer(false, panel); } } return; } protected AbstractGUITunableHandler(final Field field, final Object instance, final Tunable tunable); protected AbstractGUITunableHandler(final Method getter, final Method setter, final Object instance, final Tunable tunable); @Override void setValue(final Object newValue); @Override void notifyDependents(); @Override void notifyChangeListeners(); @Override void addChangeListener(GUITunableHandler gh); @Override void addDependent(GUITunableHandler gh); @Override String getDependency(); @Override String[] getChangeSources(); @Override final void changeOccurred(final String name, final String state); @Override final void checkDependency(final String depName, final String depState); @Override JPanel getJPanel(); @Override abstract void handle(); @Override void update(); @Override String getState(); boolean isHorizontal(); }### Answer: @Test public void testCheckDependency() { String depName = "depName"; String depState = "dep state"; fieldHandler.checkDependency(depName, depState); fieldHandler.checkDependency(null, depState); }
### Question: AbstractGUITunableHandler extends AbstractTunableHandler implements GUITunableHandler { @Override public abstract void handle(); protected AbstractGUITunableHandler(final Field field, final Object instance, final Tunable tunable); protected AbstractGUITunableHandler(final Method getter, final Method setter, final Object instance, final Tunable tunable); @Override void setValue(final Object newValue); @Override void notifyDependents(); @Override void notifyChangeListeners(); @Override void addChangeListener(GUITunableHandler gh); @Override void addDependent(GUITunableHandler gh); @Override String getDependency(); @Override String[] getChangeSources(); @Override final void changeOccurred(final String name, final String state); @Override final void checkDependency(final String depName, final String depState); @Override JPanel getJPanel(); @Override abstract void handle(); @Override void update(); @Override String getState(); boolean isHorizontal(); }### Answer: @Test public void testHandle() { fieldHandler.handle(); }
### Question: AbstractGUITunableHandler extends AbstractTunableHandler implements GUITunableHandler { @Override public void update() { } protected AbstractGUITunableHandler(final Field field, final Object instance, final Tunable tunable); protected AbstractGUITunableHandler(final Method getter, final Method setter, final Object instance, final Tunable tunable); @Override void setValue(final Object newValue); @Override void notifyDependents(); @Override void notifyChangeListeners(); @Override void addChangeListener(GUITunableHandler gh); @Override void addDependent(GUITunableHandler gh); @Override String getDependency(); @Override String[] getChangeSources(); @Override final void changeOccurred(final String name, final String state); @Override final void checkDependency(final String depName, final String depState); @Override JPanel getJPanel(); @Override abstract void handle(); @Override void update(); @Override String getState(); boolean isHorizontal(); }### Answer: @Test public void testUpdate() { fieldHandler.update(); }
### Question: PropertySheetUtil { @Deprecated public static final boolean isBasic(final VisualProperty<?> vp) { if (BASIC_PROPS.contains(vp)) return true; else return false; } @Deprecated static final boolean isBasic(final VisualProperty<?> vp); @Deprecated static final boolean isAdvancedMode(); @Deprecated static final void setMode(boolean advanced); @Deprecated static final void addBasicVisualProperty(final VisualProperty<?> vp); static final Boolean isCompatible(final VisualProperty<?> vp); static final void removeIncompatibleVisualProperty(final VisualProperty<?> vp); }### Answer: @Test public void testPreset (){ assertTrue(PropertySheetUtil.isBasic(BasicVisualLexicon.NODE_FILL_COLOR)); assertTrue(PropertySheetUtil.isBasic(BasicVisualLexicon.NODE_SHAPE)); assertTrue(PropertySheetUtil.isBasic(BasicVisualLexicon.NODE_WIDTH)); assertTrue(PropertySheetUtil.isBasic(BasicVisualLexicon.NODE_HEIGHT)); assertTrue(PropertySheetUtil.isBasic(BasicVisualLexicon.NODE_LABEL)); assertTrue(PropertySheetUtil.isBasic(BasicVisualLexicon.NODE_BORDER_PAINT)); assertTrue(PropertySheetUtil.isBasic(BasicVisualLexicon.NODE_BORDER_WIDTH)); assertTrue(PropertySheetUtil.isBasic(BasicVisualLexicon.EDGE_STROKE_UNSELECTED_PAINT)); assertTrue(PropertySheetUtil.isBasic(BasicVisualLexicon.EDGE_WIDTH)); assertTrue(PropertySheetUtil.isBasic(BasicVisualLexicon.EDGE_LABEL)); assertTrue(PropertySheetUtil.isBasic(BasicVisualLexicon.EDGE_LINE_TYPE)); assertTrue(PropertySheetUtil.isBasic(BasicVisualLexicon.NETWORK_BACKGROUND_PAINT)); } @Test public void testIsBasicFalse(){ assertFalse(PropertySheetUtil.isBasic( mock (VisualProperty.class))); }
### Question: PropertySheetUtil { @Deprecated public static final void addBasicVisualProperty(final VisualProperty<?> vp) { if (vp == null) return; BASIC_PROPS.add(vp); } @Deprecated static final boolean isBasic(final VisualProperty<?> vp); @Deprecated static final boolean isAdvancedMode(); @Deprecated static final void setMode(boolean advanced); @Deprecated static final void addBasicVisualProperty(final VisualProperty<?> vp); static final Boolean isCompatible(final VisualProperty<?> vp); static final void removeIncompatibleVisualProperty(final VisualProperty<?> vp); }### Answer: @Test public void testAddBasicVisualProperty(){ VisualProperty<?> vp = null; PropertySheetUtil.addBasicVisualProperty(vp); assertFalse(PropertySheetUtil.isBasic(vp)); vp = mock(VisualProperty.class); PropertySheetUtil.addBasicVisualProperty(vp); assertTrue(PropertySheetUtil.isBasic(vp)); }
### Question: AbstractVisualPropertyEditor implements VisualPropertyEditor<T> { @Override public Class<T> getType() { return this.type; } AbstractVisualPropertyEditor(final Class<T> type, final PropertyEditor propertyEditor, ContinuousEditorType continuousEditorType, ContinuousMappingCellRendererFactory cellRendererFactory); @Override Class<T> getType(); @Override PropertyEditor getPropertyEditor(); @Override TableCellRenderer getDiscreteTableCellRenderer(); @Override TableCellRenderer getContinuousTableCellRenderer(final ContinuousMappingEditor<? extends Number, T> continuousMappingEditor); @Override ContinuousEditorType getContinuousEditorType(); @Override Icon getDefaultIcon(int width, int height); }### Answer: @Test public void testGetClass(){ assertEquals(Object.class, editor.getType()); }
### Question: AbstractVisualPropertyEditor implements VisualPropertyEditor<T> { @Override public PropertyEditor getPropertyEditor() { return propertyEditor; } AbstractVisualPropertyEditor(final Class<T> type, final PropertyEditor propertyEditor, ContinuousEditorType continuousEditorType, ContinuousMappingCellRendererFactory cellRendererFactory); @Override Class<T> getType(); @Override PropertyEditor getPropertyEditor(); @Override TableCellRenderer getDiscreteTableCellRenderer(); @Override TableCellRenderer getContinuousTableCellRenderer(final ContinuousMappingEditor<? extends Number, T> continuousMappingEditor); @Override ContinuousEditorType getContinuousEditorType(); @Override Icon getDefaultIcon(int width, int height); }### Answer: @Test public void testGetPropertyEditor(){ assertEquals(propertyEditor, editor.getPropertyEditor()); }
### Question: AbstractVisualPropertyEditor implements VisualPropertyEditor<T> { @Override public TableCellRenderer getContinuousTableCellRenderer(final ContinuousMappingEditor<? extends Number, T> continuousMappingEditor) { return cellRendererFactory.createTableCellRenderer(continuousMappingEditor); } AbstractVisualPropertyEditor(final Class<T> type, final PropertyEditor propertyEditor, ContinuousEditorType continuousEditorType, ContinuousMappingCellRendererFactory cellRendererFactory); @Override Class<T> getType(); @Override PropertyEditor getPropertyEditor(); @Override TableCellRenderer getDiscreteTableCellRenderer(); @Override TableCellRenderer getContinuousTableCellRenderer(final ContinuousMappingEditor<? extends Number, T> continuousMappingEditor); @Override ContinuousEditorType getContinuousEditorType(); @Override Icon getDefaultIcon(int width, int height); }### Answer: @Test public void testGetContinuousTableCellRenderer(){ ContinuousMappingEditor<?,?> continuousEditor = mock(ContinuousMappingEditor.class); assertNotNull(editor.getContinuousTableCellRenderer((ContinuousMappingEditor<? extends Number, Object>) continuousEditor)); }
### Question: AbstractVisualPropertyEditor implements VisualPropertyEditor<T> { @Override public ContinuousEditorType getContinuousEditorType() { return continuousEditorType; } AbstractVisualPropertyEditor(final Class<T> type, final PropertyEditor propertyEditor, ContinuousEditorType continuousEditorType, ContinuousMappingCellRendererFactory cellRendererFactory); @Override Class<T> getType(); @Override PropertyEditor getPropertyEditor(); @Override TableCellRenderer getDiscreteTableCellRenderer(); @Override TableCellRenderer getContinuousTableCellRenderer(final ContinuousMappingEditor<? extends Number, T> continuousMappingEditor); @Override ContinuousEditorType getContinuousEditorType(); @Override Icon getDefaultIcon(int width, int height); }### Answer: @Test public void testGetContinuousEditorType(){ assertEquals(continuousEditorType, editor.getContinuousEditorType()); }
### Question: AbstractVisualPropertyEditor implements VisualPropertyEditor<T> { @Override public TableCellRenderer getDiscreteTableCellRenderer() { return discreteTableCellRenderer; } AbstractVisualPropertyEditor(final Class<T> type, final PropertyEditor propertyEditor, ContinuousEditorType continuousEditorType, ContinuousMappingCellRendererFactory cellRendererFactory); @Override Class<T> getType(); @Override PropertyEditor getPropertyEditor(); @Override TableCellRenderer getDiscreteTableCellRenderer(); @Override TableCellRenderer getContinuousTableCellRenderer(final ContinuousMappingEditor<? extends Number, T> continuousMappingEditor); @Override ContinuousEditorType getContinuousEditorType(); @Override Icon getDefaultIcon(int width, int height); }### Answer: @Test public void testGetDiscreteTableCellRenderer (){ TableCellRenderer discreteTableCellRenderer = mock(TableCellRenderer.class); editor.discreteTableCellRenderer = discreteTableCellRenderer; assertEquals(discreteTableCellRenderer, editor.getDiscreteTableCellRenderer()); }
### Question: AbstractVisualPropertyEditor implements VisualPropertyEditor<T> { @Override public Icon getDefaultIcon(int width, int height) { return null; } AbstractVisualPropertyEditor(final Class<T> type, final PropertyEditor propertyEditor, ContinuousEditorType continuousEditorType, ContinuousMappingCellRendererFactory cellRendererFactory); @Override Class<T> getType(); @Override PropertyEditor getPropertyEditor(); @Override TableCellRenderer getDiscreteTableCellRenderer(); @Override TableCellRenderer getContinuousTableCellRenderer(final ContinuousMappingEditor<? extends Number, T> continuousMappingEditor); @Override ContinuousEditorType getContinuousEditorType(); @Override Icon getDefaultIcon(int width, int height); }### Answer: @Test public void testGetDefaultIcon(){ assertEquals(null, editor.getDefaultIcon(0, 0)); }