Search in sources :

Example 1 with LoadNetworkFileTaskFactoryImpl

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);
}
Also used : Task(org.cytoscape.work.Task) LoadNetworkFileTask(org.cytoscape.task.internal.export.network.LoadNetworkFileTask) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) LoadNetworkFileTaskFactoryImpl(org.cytoscape.task.internal.export.network.LoadNetworkFileTaskFactoryImpl) TaskFactory(org.cytoscape.work.TaskFactory) Test(org.junit.Test)

Example 2 with LoadNetworkFileTaskFactoryImpl

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);
    }
}
Also used : Task(org.cytoscape.work.Task) LoadNetworkFileTask(org.cytoscape.task.internal.export.network.LoadNetworkFileTask) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) LoadNetworkFileTaskFactoryImpl(org.cytoscape.task.internal.export.network.LoadNetworkFileTaskFactoryImpl) TaskFactory(org.cytoscape.work.TaskFactory) Test(org.junit.Test)

Example 3 with LoadNetworkFileTaskFactoryImpl

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));
}
Also used : TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) Task(org.cytoscape.work.Task) ObservableTask(org.cytoscape.work.ObservableTask) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) LoadNetworkFileTaskFactoryImpl(org.cytoscape.task.internal.export.network.LoadNetworkFileTaskFactoryImpl) URI(java.net.URI) File(java.io.File) Test(org.junit.Test)

Aggregations

LoadNetworkFileTaskFactoryImpl (org.cytoscape.task.internal.export.network.LoadNetworkFileTaskFactoryImpl)3 Task (org.cytoscape.work.Task)3 TaskIterator (org.cytoscape.work.TaskIterator)3 TaskMonitor (org.cytoscape.work.TaskMonitor)3 Test (org.junit.Test)3 LoadNetworkFileTask (org.cytoscape.task.internal.export.network.LoadNetworkFileTask)2 TaskFactory (org.cytoscape.work.TaskFactory)2 File (java.io.File)1 URI (java.net.URI)1 ObservableTask (org.cytoscape.work.ObservableTask)1 TaskObserver (org.cytoscape.work.TaskObserver)1