use of org.cytoscape.model.NetworkTestSupport in project cytoscape-impl by cytoscape.
the class ColumnFilterTest method testColumnFilterList.
@Test
public void testColumnFilterList() {
NetworkTestSupport networkSupport = new NetworkTestSupport();
CyNetwork network = networkSupport.getNetworkFactory().createNetwork();
network.getDefaultNodeTable().createListColumn("l", String.class, false);
CyNode n1 = network.addNode();
CyNode n2 = network.addNode();
CyNode n3 = network.addNode();
network.getRow(n1).set("l", Arrays.asList("a", "b", "c"));
network.getRow(n2).set("l", Arrays.asList("c", "d"));
network.getRow(n3).set("l", Arrays.asList("a", "a"));
ColumnFilter columnFilter = new ColumnFilter("l", Predicate.IS, "a");
columnFilter.setAnyMatch(true);
assertTrue(columnFilter.accepts(network, n1));
assertFalse(columnFilter.accepts(network, n2));
assertTrue(columnFilter.accepts(network, n3));
columnFilter.setAnyMatch(false);
assertFalse(columnFilter.accepts(network, n1));
assertFalse(columnFilter.accepts(network, n2));
assertTrue(columnFilter.accepts(network, n3));
}
use of org.cytoscape.model.NetworkTestSupport in project cytoscape-impl by cytoscape.
the class ColumnFilterTest method testColumnFilterBoolean.
@Test
public void testColumnFilterBoolean() {
NetworkTestSupport networkSupport = new NetworkTestSupport();
CyNetwork network = networkSupport.getNetworkFactory().createNetwork();
network.getDefaultNodeTable().createColumn("b", Boolean.class, false);
CyNode n1 = network.addNode();
CyNode n2 = network.addNode();
CyNode n3 = network.addNode();
network.getRow(n1).set("b", true);
network.getRow(n2).set("b", false);
ColumnFilter columnFilter = new ColumnFilter("b", Predicate.IS, true);
assertTrue(columnFilter.accepts(network, n1));
assertFalse(columnFilter.accepts(network, n2));
assertFalse(columnFilter.accepts(network, n3));
columnFilter.setPredicateAndCriterion(Predicate.IS, false);
assertFalse(columnFilter.accepts(network, n1));
assertTrue(columnFilter.accepts(network, n2));
assertFalse(columnFilter.accepts(network, n3));
}
use of org.cytoscape.model.NetworkTestSupport in project cytoscape-impl by cytoscape.
the class TopologyFilterTest method testTopologyFilter.
@Test
public void testTopologyFilter() {
NetworkTestSupport networkSupport = new NetworkTestSupport();
CyNetwork network = networkSupport.getNetworkFactory().createNetwork();
network.getDefaultNodeTable().createColumn("s", String.class, false);
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();
CyNode n8 = network.addNode();
network.addEdge(n1, n2, false);
network.addEdge(n1, n3, false);
network.addEdge(n1, n4, false);
network.addEdge(n2, n5, false);
network.addEdge(n3, n6, false);
network.addEdge(n4, n7, false);
network.addEdge(n7, n8, false);
TopologyFilter topologyFilter = new TopologyFilter();
topologyFilter.setThreshold(6);
topologyFilter.setDistance(2);
topologyFilter.setPredicate(Predicate.GREATER_THAN_OR_EQUAL);
assertTrue(topologyFilter.accepts(network, n1));
topologyFilter.setDistance(1);
assertFalse(topologyFilter.accepts(network, n1));
network.getRow(n2).set("s", "a");
network.getRow(n6).set("s", "a");
ColumnFilter columnFilter = new ColumnFilter("s", Predicate.IS, "a");
assertTrue(columnFilter.accepts(network, n2));
assertTrue(columnFilter.accepts(network, n6));
topologyFilter.append(columnFilter);
topologyFilter.setThreshold(2);
topologyFilter.setDistance(2);
assertTrue(topologyFilter.accepts(network, n1));
topologyFilter.setDistance(1);
assertFalse(topologyFilter.accepts(network, n1));
}
use of org.cytoscape.model.NetworkTestSupport in project cytoscape-impl by cytoscape.
the class OBOReaderTest method setUp.
@Before
public void setUp() throws Exception {
viewSupport = new NetworkViewTestSupport();
netSupport = new NetworkTestSupport();
netViewFactory = viewSupport.getNetworkViewFactory();
netFactory = netSupport.getNetworkFactory();
eventHelper = mock(CyEventHelper.class);
serviceRegistrar = mock(CyServiceRegistrar.class);
when(serviceRegistrar.getService(CyNetworkViewFactory.class)).thenReturn(netViewFactory);
when(serviceRegistrar.getService(CyNetworkFactory.class)).thenReturn(netFactory);
when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
}
use of org.cytoscape.model.NetworkTestSupport 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));
}
Aggregations