use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class DeselectAllTaskTest method testRun.
@Test
public void testRun() throws Exception {
UndoSupport undoSupport = mock(UndoSupport.class);
Set<Long> selectedEdges = new HashSet<>();
selectedEdges.add(r1.get(CyNetwork.SUID, Long.class));
selectedEdges.add(r2.get(CyNetwork.SUID, Long.class));
when(edgeTable.getMatchingKeys(CyNetwork.SELECTED, true, Long.class)).thenReturn(selectedEdges);
Set<Long> selectedNodes = new HashSet<>();
selectedNodes.add(r3.get(CyNetwork.SUID, Long.class));
selectedNodes.add(r4.get(CyNetwork.SUID, Long.class));
when(nodeTable.getMatchingKeys(CyNetwork.SELECTED, true, Long.class)).thenReturn(selectedNodes);
// run the task
Task t = new DeselectAllTask(undoSupport, net, networkViewManager, eventHelper);
t.run(tm);
// check that the expected rows were set
verify(r1, times(1)).set("selected", false);
verify(r2, times(1)).set("selected", false);
verify(r3, times(1)).set("selected", false);
verify(r4, times(1)).set("selected", false);
}
use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class InvertSelectedNodesTaskTest method testRun.
@Test
public void testRun() throws Exception {
final CyTable nodeTable = mock(CyTable.class);
when(net.getDefaultNodeTable()).thenReturn(nodeTable);
UndoSupport undoSupport = mock(UndoSupport.class);
// more setup
when(r3.get("selected", Boolean.class)).thenReturn(false);
when(r4.get("selected", Boolean.class)).thenReturn(true);
final CyEventHelper eventHelper = mock(CyEventHelper.class);
// run the task
Task t = new InvertSelectedNodesTask(undoSupport, net, networkViewManager, eventHelper);
t.run(tm);
// check that the expected rows were set
verify(r3, times(1)).set("selected", true);
verify(r4, times(1)).set("selected", false);
}
use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class SelectAllEdgesTaskTest method testRun.
@Test
public void testRun() throws Exception {
UndoSupport undoSupport = mock(UndoSupport.class);
Set<CyRow> deselectedEdges = new HashSet<CyRow>();
deselectedEdges.add(r1);
deselectedEdges.add(r2);
when(edgeTable.getMatchingRows(CyNetwork.SELECTED, false)).thenReturn(deselectedEdges);
// run the task
Task t = new SelectAllEdgesTask(undoSupport, net, networkViewManager, eventHelper);
t.run(tm);
// check that the expected rows were set
verify(r1, times(1)).set("selected", true);
verify(r2, times(1)).set("selected", true);
}
use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class NewNetworkSelectedNodesOnlyTaskTest method testNewNetworkSelectedNodesOnlyTask.
@Test
public void testNewNetworkSelectedNodesOnlyTask() throws Exception {
final UndoSupport undoSupport = mock(UndoSupport.class);
netmgr.addNetwork(net);
final CyNode node1 = net.addNode();
final CyNode node2 = net.addNode();
final CyNode node3 = net.addNode();
final CyEdge edge1 = net.addEdge(node1, node2, true);
// final CyEdge edge2 = net.addEdge(node2, node3, true);
net.getRow(node1).set(CyNetwork.SELECTED, true);
// net.getRow(node2).set(CyNetwork.SELECTED, true);
net.getRow(edge1).set(CyNetwork.SELECTED, true);
int numberOfNetsBeforeTask = netmgr.getNetworkSet().size();
List<CyNetwork> netListbeforeTask = new ArrayList<CyNetwork>(netmgr.getNetworkSet());
final NewNetworkSelectedNodesOnlyTask task = new NewNetworkSelectedNodesOnlyTask(undoSupport, net, cyroot, cnvf, netmgr, networkViewManager, cyNetworkNaming, vmm, appManager, eventHelper, groupMgr, renderingEngineManager, serviceRegistrar);
assertNotNull("task is null!", task);
task.setTaskIterator(new TaskIterator(task));
task.run(mock(TaskMonitor.class));
int numberOfNetsAfterTask = netmgr.getNetworkSet().size();
assertEquals(1, numberOfNetsAfterTask - numberOfNetsBeforeTask);
List<CyNetwork> networkList = new ArrayList<CyNetwork>(netmgr.getNetworkSet());
networkList.removeAll(netListbeforeTask);
assertEquals(1, networkList.get(0).getNodeList().size());
assertEquals(0, networkList.get(0).getEdgeList().size());
}
use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class SelectAllTaskTest method testRun.
@Test
public void testRun() throws Exception {
UndoSupport undoSupport = mock(UndoSupport.class);
Set<CyRow> deselectedNodes = new HashSet<CyRow>();
deselectedNodes.add(r3);
deselectedNodes.add(r4);
when(nodeTable.getMatchingRows(CyNetwork.SELECTED, false)).thenReturn(deselectedNodes);
Set<CyRow> deselectedEdges = new HashSet<CyRow>();
deselectedEdges.add(r1);
deselectedEdges.add(r2);
when(edgeTable.getMatchingRows(CyNetwork.SELECTED, false)).thenReturn(deselectedEdges);
// run the task
Task t = new SelectAllTask(undoSupport, net, networkViewManager, eventHelper);
t.run(tm);
// check that the expected rows were set
verify(r1, times(1)).set("selected", true);
verify(r2, times(1)).set("selected", true);
verify(r3, times(1)).set("selected", true);
verify(r4, times(1)).set("selected", true);
}
Aggregations