Search in sources :

Example 41 with UndoSupport

use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.

the class UnHideAllNodesTaskFactoryTest 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);
    UnHideAllNodesTaskFactoryImpl factory = new UnHideAllNodesTaskFactoryImpl(serviceRegistrar);
    CyNetworkView view = mock(CyNetworkView.class);
    TaskIterator ti = factory.createTaskIterator(view);
    assertNotNull(ti);
    assertTrue(ti.hasNext());
    Task t = ti.next();
    assertNotNull(t);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) Task(org.cytoscape.work.Task) TaskIterator(org.cytoscape.work.TaskIterator) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) Test(org.junit.Test)

Example 42 with UndoSupport

use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.

the class HideSelectedEdgesTaskFactoryTest 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);
    HideSelectedEdgesTaskFactoryImpl factory = new HideSelectedEdgesTaskFactoryImpl(serviceRegistrar);
    CyNetworkView view = mock(CyNetworkView.class);
    TaskIterator ti = factory.createTaskIterator(view);
    assertNotNull(ti);
    assertTrue(ti.hasNext());
    Task t = ti.next();
    assertNotNull(t);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) Task(org.cytoscape.work.Task) TaskIterator(org.cytoscape.work.TaskIterator) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) Test(org.junit.Test)

Example 43 with UndoSupport

use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.

the class HideSelectedTaskFactoryTest 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);
    HideSelectedTaskFactoryImpl factory = new HideSelectedTaskFactoryImpl(serviceRegistrar);
    CyNetworkView view = mock(CyNetworkView.class);
    TaskIterator ti = factory.createTaskIterator(view);
    assertNotNull(ti);
    assertTrue(ti.hasNext());
    Task t = ti.next();
    assertNotNull(t);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) Task(org.cytoscape.work.Task) TaskIterator(org.cytoscape.work.TaskIterator) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) Test(org.junit.Test)

Example 44 with UndoSupport

use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.

the class UnHideAllTaskFactoryTest 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);
    UnHideAllTaskFactoryImpl factory = new UnHideAllTaskFactoryImpl(serviceRegistrar);
    CyNetworkView view = mock(CyNetworkView.class);
    TaskIterator ti = factory.createTaskIterator(view);
    assertNotNull(ti);
    assertTrue(ti.hasNext());
    Task t = ti.next();
    assertNotNull(t);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) Task(org.cytoscape.work.Task) TaskIterator(org.cytoscape.work.TaskIterator) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) Test(org.junit.Test)

Example 45 with UndoSupport

use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.

the class NewNetworkSelectedNodesEdgesTaskTest method testNewNetworkSelectedNodesEdgesTask.

@Test
public void testNewNetworkSelectedNodesEdgesTask() 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 NewNetworkSelectedNodesEdgesTask task = new NewNetworkSelectedNodesEdgesTask(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(2, networkList.get(0).getNodeList().size());
    assertEquals(1, networkList.get(0).getEdgeList().size());
}
Also used : TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyEdge(org.cytoscape.model.CyEdge) Test(org.junit.Test)

Aggregations

UndoSupport (org.cytoscape.work.undo.UndoSupport)50 Test (org.junit.Test)21 Task (org.cytoscape.work.Task)19 CyEventHelper (org.cytoscape.event.CyEventHelper)15 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)15 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)12 HashSet (java.util.HashSet)10 TaskIterator (org.cytoscape.work.TaskIterator)10 CyNode (org.cytoscape.model.CyNode)9 ArrayList (java.util.ArrayList)8 CyEdge (org.cytoscape.model.CyEdge)7 CyNetwork (org.cytoscape.model.CyNetwork)7 CyNetworkView (org.cytoscape.view.model.CyNetworkView)7 CyRow (org.cytoscape.model.CyRow)6 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)6 Properties (java.util.Properties)5 CyNetworkManager (org.cytoscape.model.CyNetworkManager)5 CyApplicationManager (org.cytoscape.application.CyApplicationManager)4 CyGroupManager (org.cytoscape.group.CyGroupManager)4 CyNetworkFactory (org.cytoscape.model.CyNetworkFactory)4