Search in sources :

Example 1 with NetworkViewTestSupport

use of org.cytoscape.ding.NetworkViewTestSupport 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 NetworkViewTestSupport

use of org.cytoscape.ding.NetworkViewTestSupport 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 NetworkViewTestSupport

use of org.cytoscape.ding.NetworkViewTestSupport in project cytoscape-impl by cytoscape.

the class PartitionUtilTest method testPartition.

@Test
public void testPartition() {
    NetworkViewTestSupport networkSupport = new NetworkViewTestSupport();
    CyNetwork network = networkSupport.getNetworkFactory().createNetwork();
    {
        // Partition 1
        CyNode n1 = network.addNode();
        CyNode n2 = network.addNode();
        CyNode n3 = network.addNode();
        CyNode n4 = network.addNode();
        network.addEdge(n1, n2, false);
        network.addEdge(n2, n3, false);
        network.addEdge(n3, n4, false);
    }
    {
        // Partition 2
        CyNode n1 = network.addNode();
        CyNode n2 = network.addNode();
        CyNode n3 = network.addNode();
        CyNode n4 = network.addNode();
        network.addEdge(n1, n2, false);
        network.addEdge(n2, n3, false);
        network.addEdge(n3, n4, false);
        // cycle
        network.addEdge(n4, n1, false);
    }
    {
        // Partition 3
        CyNode n1 = network.addNode();
        CyNode n2 = network.addNode();
        CyNode n3 = network.addNode();
        CyNode n4 = network.addNode();
        network.addEdge(n1, n2, true);
        network.addEdge(n1, n3, true);
        network.addEdge(n1, n4, true);
        network.addEdge(n2, n3, true);
        network.addEdge(n3, n4, true);
        network.addEdge(n4, n1, true);
    }
    CyNetworkView networkView = networkSupport.getNetworkViewFactory().createNetworkView(network);
    EdgeWeighter edgeWeighter = new EdgeWeighter();
    List<LayoutPartition> result = PartitionUtil.partition(networkView, false, edgeWeighter);
    assertNotNull(result);
    assertEquals(3, result.size());
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) CyNetworkView(org.cytoscape.view.model.CyNetworkView) Test(org.junit.Test)

Example 4 with NetworkViewTestSupport

use of org.cytoscape.ding.NetworkViewTestSupport in project cytoscape-impl by cytoscape.

the class CyApplicationManagerImplTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    nvtSupport = new NetworkViewTestSupport();
    final Set<CyNetwork> networks = new HashSet<>();
    when(netMgr.getNetworkSet()).thenReturn(networks);
    when(netMgr.networkExists(anyLong())).thenReturn(false);
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(evtHelper);
    when(serviceRegistrar.getService(CyNetworkManager.class)).thenReturn(netMgr);
    when(serviceRegistrar.getService(CyProperty.class, "(cyPropertyName=cytoscape3.props)")).thenReturn(cyProperty);
    appMgr = new CyApplicationManagerImpl(serviceRegistrar);
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 5 with NetworkViewTestSupport

use of org.cytoscape.ding.NetworkViewTestSupport in project cytoscape-impl by cytoscape.

the class ApplyVisualStyleTaskTest method testRun.

@Test
public void testRun() throws Exception {
    NetworkViewTestSupport nvts = new NetworkViewTestSupport();
    TaskMonitor tm = mock(TaskMonitor.class);
    final CyNetworkView view = nvts.getNetworkView();
    final Set<CyNetworkView> views = new HashSet<CyNetworkView>();
    views.add(view);
    ApplyVisualStyleTask task = new ApplyVisualStyleTask(views, serviceRegistrar);
    final List<VisualStyle> vsList = new ArrayList<VisualStyle>();
    VisualStyle style1 = mock(VisualStyle.class);
    vsList.add(style1);
    task.styles = new ListSingleSelection<VisualStyle>(vsList);
    task.styles.setSelectedValue(style1);
    task.run(tm);
    verify(style1, times(1)).apply(view);
}
Also used : TaskMonitor(org.cytoscape.work.TaskMonitor) ArrayList(java.util.ArrayList) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) CyNetworkView(org.cytoscape.view.model.CyNetworkView) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

NetworkViewTestSupport (org.cytoscape.ding.NetworkViewTestSupport)14 CyNetwork (org.cytoscape.model.CyNetwork)9 Test (org.junit.Test)8 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)7 CyNetworkView (org.cytoscape.view.model.CyNetworkView)7 NetworkTestSupport (org.cytoscape.model.NetworkTestSupport)6 TaskMonitor (org.cytoscape.work.TaskMonitor)6 Before (org.junit.Before)6 CyApplicationManager (org.cytoscape.application.CyApplicationManager)5 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)5 HashSet (java.util.HashSet)4 CyEventHelper (org.cytoscape.event.CyEventHelper)4 CyGroupManager (org.cytoscape.group.CyGroupManager)4 CyNetworkManager (org.cytoscape.model.CyNetworkManager)4 CyNode (org.cytoscape.model.CyNode)4 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)4 TaskIterator (org.cytoscape.work.TaskIterator)4 CyNetworkFactory (org.cytoscape.model.CyNetworkFactory)3 CyRootNetworkManagerImpl (org.cytoscape.model.internal.CyRootNetworkManagerImpl)3 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)3