Search in sources :

Example 1 with CyRootNetworkManagerImpl

use of org.cytoscape.model.internal.CyRootNetworkManagerImpl in project cytoscape-impl by cytoscape.

the class CloneNetworkTaskFactoryTest method testObserver.

@Test
public void testObserver() throws Exception {
    NetworkViewTestSupport viewSupport = new NetworkViewTestSupport();
    NetworkTestSupport networkSupport = new NetworkTestSupport();
    CyNetworkManager networkMgr = Mockito.mock(CyNetworkManager.class);
    CyNetworkViewManager networkViewMgr = Mockito.mock(CyNetworkViewManager.class);
    VisualMappingManager vmm = Mockito.mock(VisualMappingManager.class);
    CyNetworkFactory netFactory = networkSupport.getNetworkFactory();
    CyNetworkViewFactory netViewFactory = viewSupport.getNetworkViewFactory();
    CyNetworkNaming naming = Mockito.mock(CyNetworkNaming.class);
    CyApplicationManager appMgr = Mockito.mock(CyApplicationManager.class);
    CyNetworkTableManager netTableMgr = Mockito.mock(CyNetworkTableManager.class);
    CyRootNetworkManager rootNetMgr = new CyRootNetworkManagerImpl();
    CyGroupManager groupMgr = Mockito.mock(CyGroupManager.class);
    CyGroupFactory groupFactory = Mockito.mock(CyGroupFactory.class);
    RenderingEngineManager renderingEngineMgr = Mockito.mock(RenderingEngineManager.class);
    CyNetworkViewFactory nullNetworkViewFactory = new NullCyNetworkViewFactory();
    CyServiceRegistrar serviceRegistrar = Mockito.mock(CyServiceRegistrar.class);
    CloneNetworkTaskFactoryImpl factory = new CloneNetworkTaskFactoryImpl(networkMgr, networkViewMgr, vmm, netFactory, netViewFactory, naming, appMgr, netTableMgr, rootNetMgr, groupMgr, groupFactory, renderingEngineMgr, nullNetworkViewFactory, serviceRegistrar);
    CyNetwork network = netFactory.createNetwork();
    TaskObserver observer = Mockito.mock(TaskObserver.class);
    TaskIterator iterator = factory.createTaskIterator(network);
    TaskMonitor taskMonitor = Mockito.mock(TaskMonitor.class);
    while (iterator.hasNext()) {
        Task t = iterator.next();
        t.run(taskMonitor);
        if (t instanceof ObservableTask)
            observer.taskFinished((ObservableTask) t);
    }
    Mockito.verify(observer, Mockito.times(1)).taskFinished(Mockito.any(ObservableTask.class));
}
Also used : CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) Task(org.cytoscape.work.Task) ObservableTask(org.cytoscape.work.ObservableTask) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) CyRootNetworkManagerImpl(org.cytoscape.model.internal.CyRootNetworkManagerImpl) NetworkTestSupport(org.cytoscape.model.NetworkTestSupport) CyNetwork(org.cytoscape.model.CyNetwork) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) CyApplicationManager(org.cytoscape.application.CyApplicationManager) TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) CyNetworkManager(org.cytoscape.model.CyNetworkManager) TaskIterator(org.cytoscape.work.TaskIterator) NullCyNetworkViewFactory(org.cytoscape.view.model.internal.NullCyNetworkViewFactory) CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) TaskMonitor(org.cytoscape.work.TaskMonitor) CyNetworkNaming(org.cytoscape.session.CyNetworkNaming) CyNetworkFactory(org.cytoscape.model.CyNetworkFactory) NullCyNetworkViewFactory(org.cytoscape.view.model.internal.NullCyNetworkViewFactory) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) CyGroupFactory(org.cytoscape.group.CyGroupFactory) CyGroupManager(org.cytoscape.group.CyGroupManager) Test(org.junit.Test)

Example 2 with CyRootNetworkManagerImpl

use of org.cytoscape.model.internal.CyRootNetworkManagerImpl 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));
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) Task(org.cytoscape.work.Task) ObservableTask(org.cytoscape.work.ObservableTask) CyNetwork(org.cytoscape.model.CyNetwork) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) ObservableTask(org.cytoscape.work.ObservableTask) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) CyLayoutAlgorithm(org.cytoscape.view.layout.CyLayoutAlgorithm) CyNode(org.cytoscape.model.CyNode) CyGroupManager(org.cytoscape.group.CyGroupManager) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) CyRootNetworkManagerImpl(org.cytoscape.model.internal.CyRootNetworkManagerImpl) NetworkTestSupport(org.cytoscape.model.NetworkTestSupport) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyApplicationManager(org.cytoscape.application.CyApplicationManager) TaskObserver(org.cytoscape.work.TaskObserver) CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) CyLayoutAlgorithmManager(org.cytoscape.view.layout.CyLayoutAlgorithmManager) CyNetworkNaming(org.cytoscape.session.CyNetworkNaming) CyNetworkFactory(org.cytoscape.model.CyNetworkFactory) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) Test(org.junit.Test)

Example 3 with CyRootNetworkManagerImpl

use of org.cytoscape.model.internal.CyRootNetworkManagerImpl in project cytoscape-impl by cytoscape.

the class AbstractGroupTaskTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    support = new NetworkTestSupport();
    network = support.getNetwork();
    CyRootNetworkManager rootNetworkManager = new CyRootNetworkManagerImpl();
    rootNetwork = rootNetworkManager.getRootNetwork(network);
    when(registrar.getService(VisualMappingManager.class)).thenReturn(vmMgr);
    when(registrar.getService(CyNetworkViewManager.class)).thenReturn(netViewMgr);
    when(registrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
    final LockedVisualPropertiesManager lvpCache = new LockedVisualPropertiesManager(registrar);
    groupManager = new CyGroupManagerImpl(registrar);
    groupFactory = new CyGroupFactoryImpl(groupManager, lvpCache);
    group1 = groupFactory.createGroup(network, true);
    rootNetwork.getRow(group1.getGroupNode(), CyRootNetwork.SHARED_ATTRS).set(CyRootNetwork.SHARED_NAME, "group1");
    group2 = groupFactory.createGroup(network, true);
    rootNetwork.getRow(group2.getGroupNode(), CyRootNetwork.SHARED_ATTRS).set(CyRootNetwork.SHARED_NAME, "group2");
    task = new AbstractGroupTask() {

        @Override
        public void run(TaskMonitor taskMonitor) throws Exception {
        }
    };
    task.net = network;
    task.groupMgr = groupManager;
}
Also used : CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyGroupManagerImpl(org.cytoscape.group.internal.CyGroupManagerImpl) TaskMonitor(org.cytoscape.work.TaskMonitor) CyRootNetworkManagerImpl(org.cytoscape.model.internal.CyRootNetworkManagerImpl) NetworkTestSupport(org.cytoscape.model.NetworkTestSupport) LockedVisualPropertiesManager(org.cytoscape.group.internal.LockedVisualPropertiesManager) CyGroupFactoryImpl(org.cytoscape.group.internal.CyGroupFactoryImpl) Before(org.junit.Before)

Example 4 with CyRootNetworkManagerImpl

use of org.cytoscape.model.internal.CyRootNetworkManagerImpl in project cytoscape-impl by cytoscape.

the class DGraphViewApplyTest method setUp.

@Before
public void setUp() throws Exception {
    // Build real DGraphView object.
    MockitoAnnotations.initMocks(this);
    testSupport.getNetworkTableManager();
    network = buildNetworkModel();
    rootNetworkManager = new CyRootNetworkManagerImpl();
    spacialFactory = new RTreeFactory();
    dingLexicon = new DVisualLexicon(cgManager);
    handleFactory = new HandleFactoryImpl();
    when(serviceRegistrar.getService(CyRootNetworkManager.class)).thenReturn(rootNetworkManager);
    when(serviceRegistrar.getService(UndoSupport.class)).thenReturn(undoSupport);
    when(serviceRegistrar.getService(SpacialIndex2DFactory.class)).thenReturn(spacialFactory);
    when(serviceRegistrar.getService(DialogTaskManager.class)).thenReturn(dialogTaskManager);
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
    when(serviceRegistrar.getService(IconManager.class)).thenReturn(iconManager);
    when(serviceRegistrar.getService(VisualMappingManager.class)).thenReturn(visualMappingManager);
    when(serviceRegistrar.getService(CyNetworkViewManager.class)).thenReturn(networkViewManager);
    dgv = new DGraphView(network, dingLexicon, vtfListener, annotationFactoryManager, dingGraphLOD, handleFactory, serviceRegistrar);
    assertNotNull(dgv);
    assertEquals(3, dgv.getModel().getNodeCount());
    assertEquals(3, dgv.getModel().getEdgeCount());
    nodeView1 = dgv.getDNodeView(node1);
    nodeView2 = dgv.getDNodeView(node2);
    nodeView3 = dgv.getDNodeView(node3);
    ev1 = dgv.getDEdgeView(edge12);
    ev2 = dgv.getDEdgeView(edge13);
    ev3 = dgv.getDEdgeView(edge23);
}
Also used : CyRootNetworkManagerImpl(org.cytoscape.model.internal.CyRootNetworkManagerImpl) DVisualLexicon(org.cytoscape.ding.DVisualLexicon) RTreeFactory(org.cytoscape.spacial.internal.rtree.RTreeFactory) Before(org.junit.Before)

Example 5 with CyRootNetworkManagerImpl

use of org.cytoscape.model.internal.CyRootNetworkManagerImpl in project cytoscape-impl by cytoscape.

the class NewNetworkSelectedNodesOnlyTaskFactoryTest 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);
    NewNetworkSelectedNodesOnlyTaskFactoryImpl factory = new NewNetworkSelectedNodesOnlyTaskFactoryImpl(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));
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) Task(org.cytoscape.work.Task) ObservableTask(org.cytoscape.work.ObservableTask) CyNetwork(org.cytoscape.model.CyNetwork) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) ObservableTask(org.cytoscape.work.ObservableTask) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) CyLayoutAlgorithm(org.cytoscape.view.layout.CyLayoutAlgorithm) CyNode(org.cytoscape.model.CyNode) CyGroupManager(org.cytoscape.group.CyGroupManager) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) CyRootNetworkManagerImpl(org.cytoscape.model.internal.CyRootNetworkManagerImpl) NetworkTestSupport(org.cytoscape.model.NetworkTestSupport) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyApplicationManager(org.cytoscape.application.CyApplicationManager) TaskObserver(org.cytoscape.work.TaskObserver) CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) CyLayoutAlgorithmManager(org.cytoscape.view.layout.CyLayoutAlgorithmManager) CyNetworkNaming(org.cytoscape.session.CyNetworkNaming) CyNetworkFactory(org.cytoscape.model.CyNetworkFactory) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) Test(org.junit.Test)

Aggregations

CyRootNetworkManagerImpl (org.cytoscape.model.internal.CyRootNetworkManagerImpl)5 NetworkTestSupport (org.cytoscape.model.NetworkTestSupport)4 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)4 TaskMonitor (org.cytoscape.work.TaskMonitor)4 CyApplicationManager (org.cytoscape.application.CyApplicationManager)3 NetworkViewTestSupport (org.cytoscape.ding.NetworkViewTestSupport)3 CyGroupManager (org.cytoscape.group.CyGroupManager)3 CyNetwork (org.cytoscape.model.CyNetwork)3 CyNetworkFactory (org.cytoscape.model.CyNetworkFactory)3 CyNetworkManager (org.cytoscape.model.CyNetworkManager)3 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)3 CyNetworkNaming (org.cytoscape.session.CyNetworkNaming)3 CyNetworkViewFactory (org.cytoscape.view.model.CyNetworkViewFactory)3 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)3 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)3 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)3 ObservableTask (org.cytoscape.work.ObservableTask)3 Task (org.cytoscape.work.Task)3 TaskIterator (org.cytoscape.work.TaskIterator)3 TaskObserver (org.cytoscape.work.TaskObserver)3