use of org.cytoscape.task.internal.export.network.LoadNetworkFileTaskFactoryImpl in project cytoscape-impl by cytoscape.
the class LoadNetworkFileTaskTest method testRun.
@Test
public void testRun() throws Exception {
TaskFactory factory = new LoadNetworkFileTaskFactoryImpl(serviceRegistrar);
TaskIterator ti = factory.createTaskIterator();
TaskMonitor tm = mock(TaskMonitor.class);
boolean first = true;
while (ti.hasNext()) {
Task t = ti.next();
if (first) {
((LoadNetworkFileTask) t).file = file;
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.LoadNetworkFileTaskFactoryImpl in project cytoscape-impl by cytoscape.
the class LoadNetworkFileTaskTest method testNullFile.
@Test(expected = NullPointerException.class)
public void testNullFile() throws Exception {
TaskFactory factory = new LoadNetworkFileTaskFactoryImpl(serviceRegistrar);
TaskIterator ti = factory.createTaskIterator();
TaskMonitor tm = mock(TaskMonitor.class);
boolean first = true;
while (ti.hasNext()) {
Task t = ti.next();
if (first) {
((LoadNetworkFileTask) t).file = null;
first = false;
}
t.run(tm);
}
}
use of org.cytoscape.task.internal.export.network.LoadNetworkFileTaskFactoryImpl in project cytoscape-impl by cytoscape.
the class LoadNetworkFileTaskFactoryTest method testObserver.
@Test
public void testObserver() throws Exception {
when(netReaderManager.getReader(any(URI.class), anyString())).thenReturn(reader);
LoadNetworkFileTaskFactoryImpl factory = new LoadNetworkFileTaskFactoryImpl(serviceRegistrar);
TaskMonitor taskMonitor = mock(TaskMonitor.class);
TaskObserver observer = mock(TaskObserver.class);
TaskIterator iterator = factory.createTaskIterator(new File(""), observer);
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