use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class NewNetworkSelectedNodesEdgesTaskFactoryTest method testObserver.
@Test
public void testObserver() throws Exception {
NetworkViewTestSupport viewSupport = new NetworkViewTestSupport();
NetworkTestSupport networkSupport = new NetworkTestSupport();
CyNetworkFactory networkFactory = networkSupport.getNetworkFactory();
UndoSupport undoSupport = mock(UndoSupport.class);
CyRootNetworkManager crnf = new CyRootNetworkManagerImpl();
CyNetworkViewFactory cnvf = viewSupport.getNetworkViewFactory();
CyNetworkManager netmgr = mock(CyNetworkManager.class);
CyNetworkViewManager networkViewManager = mock(CyNetworkViewManager.class);
CyNetworkNaming naming = mock(CyNetworkNaming.class);
VisualMappingManager vmm = mock(VisualMappingManager.class);
CyApplicationManager appManager = mock(CyApplicationManager.class);
CyEventHelper eventHelper = mock(CyEventHelper.class);
CyGroupManager groupMgr = mock(CyGroupManager.class);
RenderingEngineManager renderingEngineMgr = mock(RenderingEngineManager.class);
CyLayoutAlgorithm defLayout = mock(CyLayoutAlgorithm.class);
CyLayoutAlgorithmManager layoutMgr = mock(CyLayoutAlgorithmManager.class);
when(layoutMgr.getDefaultLayout()).thenReturn(defLayout);
CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
when(serviceRegistrar.getService(CyLayoutAlgorithmManager.class)).thenReturn(layoutMgr);
NewNetworkSelectedNodesEdgesTaskFactoryImpl factory = new NewNetworkSelectedNodesEdgesTaskFactoryImpl(undoSupport, crnf, cnvf, netmgr, networkViewManager, naming, vmm, appManager, eventHelper, groupMgr, renderingEngineMgr, serviceRegistrar);
CyNetwork network = networkFactory.createNetwork();
CyNode node = network.addNode();
network.getRow(node).set(CyNetwork.SELECTED, true);
TaskObserver observer = mock(TaskObserver.class);
TaskMonitor taskMonitor = mock(TaskMonitor.class);
TaskIterator iterator = factory.createTaskIterator(network);
while (iterator.hasNext()) {
Task t = iterator.next();
t.run(taskMonitor);
if (t instanceof ObservableTask)
observer.taskFinished((ObservableTask) t);
}
verify(observer, times(1)).taskFinished(any(ObservableTask.class));
}
use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class UnHideAllEdgesTaskFactoryTest method testRun.
@Test
public void testRun() throws Exception {
UndoSupport undoSupport = mock(UndoSupport.class);
CyEventHelper eventHelper = mock(CyEventHelper.class);
VisualMappingManager vmMgr = mock(VisualMappingManager.class);
CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
when(serviceRegistrar.getService(UndoSupport.class)).thenReturn(undoSupport);
when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
when(serviceRegistrar.getService(VisualMappingManager.class)).thenReturn(vmMgr);
UnHideAllEdgesTaskFactoryImpl factory = new UnHideAllEdgesTaskFactoryImpl(serviceRegistrar);
CyNetworkView view = mock(CyNetworkView.class);
TaskIterator ti = factory.createTaskIterator(view);
assertNotNull(ti);
assertTrue(ti.hasNext());
Task t = ti.next();
assertNotNull(t);
}
use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class AllFactoryTest method setUp.
@Before
public void setUp() throws Exception {
net = mock(CyNetwork.class);
netmgr = mock(CyNetworkManager.class);
networkViewManager = mock(CyNetworkViewManager.class);
eventHelper = mock(CyEventHelper.class);
UndoSupport undoSupport = mock(UndoSupport.class);
}
use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class DeselectAllNodesTaskTest method testRun.
@Test
public void testRun() throws Exception {
UndoSupport undoSupport = mock(UndoSupport.class);
Set<CyRow> selectedNodes = new HashSet<CyRow>();
selectedNodes.add(r3);
selectedNodes.add(r4);
when(nodeTable.getMatchingRows(CyNetwork.SELECTED, true)).thenReturn(selectedNodes);
// run the task
Task t = new DeselectAllNodesTask(undoSupport, net, networkViewManager, eventHelper);
t.run(tm);
// check that the expected rows were set
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 InvertSelectedEdgesTaskTest method testRun.
@Test
public void testRun() throws Exception {
final CyTable edgeTable = mock(CyTable.class);
when(net.getDefaultEdgeTable()).thenReturn(edgeTable);
UndoSupport undoSupport = mock(UndoSupport.class);
// more setup
when(r1.get("selected", Boolean.class)).thenReturn(false);
when(r2.get("selected", Boolean.class)).thenReturn(true);
// run the task
Task t = new InvertSelectedEdgesTask(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", false);
}
Aggregations