use of org.cytoscape.task.internal.export.network.LoadNetworkURLTaskFactoryImpl in project cytoscape-impl by cytoscape.
the class LoadNetworkURLTaskTest method testNullURL.
@Test(expected = NullPointerException.class)
public void testNullURL() throws Exception {
TaskFactory factory = new LoadNetworkURLTaskFactoryImpl(serviceRegistrar);
TaskIterator ti = factory.createTaskIterator();
TaskMonitor tm = mock(TaskMonitor.class);
boolean first = true;
while (ti.hasNext()) {
Task t = ti.next();
if (first) {
((LoadNetworkURLTask) t).url = null;
first = false;
}
t.run(tm);
}
}
use of org.cytoscape.task.internal.export.network.LoadNetworkURLTaskFactoryImpl in project cytoscape-impl by cytoscape.
the class LoadNetworkURLTaskTest method testRun.
@Test
public void testRun() throws Exception {
TaskFactory factory = new LoadNetworkURLTaskFactoryImpl(serviceRegistrar);
assertNotNull(netViewManager);
TaskIterator ti = factory.createTaskIterator();
TaskMonitor tm = mock(TaskMonitor.class);
boolean first = true;
while (ti.hasNext()) {
Task t = ti.next();
if (first) {
((LoadNetworkURLTask) t).url = url;
first = false;
}
t.run(tm);
}
verify(netManager).addNetwork(net, false);
// verify(networkViewManager).addNetworkView(view);
verify(tm, atLeast(1)).setProgress(1.0);
}
use of org.cytoscape.task.internal.export.network.LoadNetworkURLTaskFactoryImpl in project cytoscape-impl by cytoscape.
the class LoadNetworkURLTaskTest method testBadConnection.
@Test(expected = Exception.class)
public void testBadConnection() throws Exception {
doThrow(new IOException("bad connection")).when(connection).connect();
TaskFactory factory = new LoadNetworkURLTaskFactoryImpl(serviceRegistrar);
TaskIterator ti = factory.createTaskIterator();
TaskMonitor tm = mock(TaskMonitor.class);
boolean first = true;
while (ti.hasNext()) {
Task t = ti.next();
if (first) {
((LoadNetworkURLTask) t).url = url;
first = false;
}
t.run(tm);
}
}
use of org.cytoscape.task.internal.export.network.LoadNetworkURLTaskFactoryImpl in project cytoscape-impl by cytoscape.
the class LoadNetworkURLTaskFactoryTest method testObserver.
@Test
public void testObserver() throws Exception {
URLConnection con = mock(URLConnection.class);
StreamUtil streamUtil = mock(StreamUtil.class);
when(streamUtil.getURLConnection(url)).thenReturn(con);
LoadNetworkURLTaskFactoryImpl factory = new LoadNetworkURLTaskFactoryImpl(serviceRegistrar);
TaskMonitor taskMonitor = mock(TaskMonitor.class);
TaskObserver observer = mock(TaskObserver.class);
TaskIterator iterator = factory.createTaskIterator(url, observer);
while (iterator.hasNext()) {
Task t = iterator.next();
t.run(taskMonitor);
if (t instanceof ObservableTask)
observer.taskFinished((ObservableTask) t);
}
// This is sort of a stupid verification. We should actually be testing the results, here....
verify(observer, times(1)).taskFinished(any(ObservableTask.class));
}
Aggregations