Search in sources :

Example 91 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class CyApplicationManagerImplTest method testSetSelectedViews.

@Test
public void testSetSelectedViews() {
    final List<CyNetwork> nets = Collections.singletonList(newNetwork());
    appMgr.setSelectedNetworks(nets);
    final CyNetworkView v1 = newNetworkView();
    final CyNetworkView v2 = newNetworkView();
    final List<CyNetworkView> views = Arrays.asList(new CyNetworkView[] { v1, v2 });
    appMgr.setSelectedNetworkViews(views);
    final List<CyNetworkView> selectedViews = appMgr.getSelectedNetworkViews();
    final List<CyNetwork> selectedNets = appMgr.getSelectedNetworks();
    assertEquals(2, selectedViews.size());
    assertTrue(selectedViews.containsAll(views));
    // Selected networks didn't change
    assertEquals(1, selectedNets.size());
    assertTrue(selectedNets.containsAll(nets));
    // Shouldn't change the current network
    assertNull(appMgr.getCurrentNetwork());
    // Shouldn't change the current network view
    assertNull(appMgr.getCurrentNetworkView());
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView) Test(org.junit.Test)

Example 92 with CyNetwork

use of org.cytoscape.model.CyNetwork 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 93 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class CyApplicationManagerImplTest method testSetCurrentNetwork.

@Test
public void testSetCurrentNetwork() {
    CyNetworkView view = newNetworkView();
    CyNetwork net = view.getModel();
    appMgr.setCurrentNetwork(net);
    assertEquals(net, appMgr.getCurrentNetwork());
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView) Test(org.junit.Test)

Example 94 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class CyApplicationManagerImplTest method testSetUnselectedCurrentNetworkChangesNetworkSelection.

@Test
public void testSetUnselectedCurrentNetworkChangesNetworkSelection() {
    // Setting a current view that is not selected changes the network view selection
    CyNetworkView v1 = newNetworkView();
    CyNetworkView v2 = newNetworkView();
    CyNetworkView v3 = newNetworkView();
    appMgr.setSelectedNetworks(Arrays.asList(new CyNetwork[] { v1.getModel(), v2.getModel() }));
    appMgr.setCurrentNetwork(v3.getModel());
    assertEquals(v3.getModel(), appMgr.getCurrentNetwork());
    assertEquals(1, appMgr.getSelectedNetworks().size());
    assertTrue(appMgr.getSelectedNetworks().contains(v3.getModel()));
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView) Test(org.junit.Test)

Example 95 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class CyApplicationManagerImplTest method testSetSelectedCurrentNetworkDoesNotChangeNetworkSelection.

@Test
public void testSetSelectedCurrentNetworkDoesNotChangeNetworkSelection() {
    // Setting a current network that is already selected does NOT change the network selection state
    CyNetwork n1 = newNetwork();
    CyNetwork n2 = newNetwork();
    CyNetwork n3 = newNetwork();
    appMgr.setSelectedNetworks(Arrays.asList(new CyNetwork[] { n1, n2, n3 }));
    appMgr.setCurrentNetwork(n3);
    assertEquals(n3, appMgr.getCurrentNetwork());
    assertEquals(3, appMgr.getSelectedNetworks().size());
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) Test(org.junit.Test)

Aggregations

CyNetwork (org.cytoscape.model.CyNetwork)517 CyNode (org.cytoscape.model.CyNode)183 CyNetworkView (org.cytoscape.view.model.CyNetworkView)129 CyEdge (org.cytoscape.model.CyEdge)108 Test (org.junit.Test)107 ArrayList (java.util.ArrayList)87 CyTable (org.cytoscape.model.CyTable)75 CyApplicationManager (org.cytoscape.application.CyApplicationManager)70 CyIdentifiable (org.cytoscape.model.CyIdentifiable)57 CyRow (org.cytoscape.model.CyRow)48 HashSet (java.util.HashSet)45 CyNetworkManager (org.cytoscape.model.CyNetworkManager)40 HashMap (java.util.HashMap)35 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)35 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)32 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)31 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)30 AbstractNetworkReaderTest (org.cytoscape.io.internal.read.AbstractNetworkReaderTest)27 TaskIterator (org.cytoscape.work.TaskIterator)27 List (java.util.List)26