use of org.cytoscape.model.NetworkTestSupport 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));
}
use of org.cytoscape.model.NetworkTestSupport 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.model.NetworkTestSupport 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;
}
use of org.cytoscape.model.NetworkTestSupport in project cytoscape-impl by cytoscape.
the class GeneAssociationReaderTest method setUp.
@Before
public void setUp() throws Exception {
NetworkTestSupport netSupport = new NetworkTestSupport();
TableTestSupport tableSupport = new TableTestSupport();
CyNetworkFactory cyNetworkFactory = netSupport.getNetworkFactory();
tableFactory = tableSupport.getTableFactory();
tableManager = mock(CyTableManager.class);
dag = cyNetworkFactory.createNetwork();
tm = mock(TaskMonitor.class);
serviceRegistrar = mock(CyServiceRegistrar.class);
when(serviceRegistrar.getService(CyTableFactory.class)).thenReturn(tableFactory);
when(serviceRegistrar.getService(CyTableManager.class)).thenReturn(tableManager);
}
use of org.cytoscape.model.NetworkTestSupport in project cytoscape-impl by cytoscape.
the class StringToModelTest method testNodeListParsing.
// TODO still need to test SUID
@Test
public void testNodeListParsing() {
NetworkTestSupport networkTestSupport = new NetworkTestSupport();
CyNetwork network = networkTestSupport.getNetwork();
CyNode n1 = network.addNode();
CyNode n2 = network.addNode();
CyNode n3 = network.addNode();
CyNode n4 = network.addNode();
CyNode n5 = network.addNode();
CyNode n6 = network.addNode();
CyNode n7 = network.addNode();
network.getRow(n1).set("name", "node 1");
network.getRow(n2).set("name", "node 2");
network.getRow(n3).set("name", "node,3");
network.getRow(n4).set("name", "node:4");
network.getRow(n5).set("name", "node:5,5");
network.getRow(n6).set("name", "node\\:6");
network.getRow(n7).set("name", "name:7");
StringToModel stringToModel = new StringToModelImpl(serviceRegistrar);
List<CyNode> nodes;
nodes = stringToModel.getNodeList(network, "node 1,node 2");
assertEquals(2, nodes.size());
assertTrue(nodes.contains(n1));
assertTrue(nodes.contains(n2));
nodes = stringToModel.getNodeList(network, "name:node 1,name:node 2");
assertEquals(2, nodes.size());
assertTrue(nodes.contains(n1));
assertTrue(nodes.contains(n2));
nodes = stringToModel.getNodeList(network, "name:node\\,3,name:node 1,name:node 2");
assertEquals(3, nodes.size());
assertTrue(nodes.contains(n1));
assertTrue(nodes.contains(n2));
assertTrue(nodes.contains(n3));
nodes = stringToModel.getNodeList(network, "name:node\\:4,name:node 1,name:node 2");
assertEquals(3, nodes.size());
assertTrue(nodes.contains(n1));
assertTrue(nodes.contains(n2));
assertTrue(nodes.contains(n4));
nodes = stringToModel.getNodeList(network, "name:node\\:5\\,5");
assertEquals(1, nodes.size());
assertTrue(nodes.contains(n5));
nodes = stringToModel.getNodeList(network, "node\\\\:6");
assertEquals(1, nodes.size());
assertTrue(nodes.contains(n6));
// shouldn't need to escape colons after the first colon
nodes = stringToModel.getNodeList(network, "name:node:4");
assertEquals(1, nodes.size());
assertTrue(nodes.contains(n4));
}
Aggregations