Search in sources :

Example 1 with LoadNetworkURLTask

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

Example 2 with LoadNetworkURLTask

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

Example 3 with LoadNetworkURLTask

use of org.cytoscape.task.internal.export.network.LoadNetworkURLTask 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);
    }
}
Also used : Task(org.cytoscape.work.Task) LoadNetworkURLTask(org.cytoscape.task.internal.export.network.LoadNetworkURLTask) TaskIterator(org.cytoscape.work.TaskIterator) LoadNetworkURLTaskFactoryImpl(org.cytoscape.task.internal.export.network.LoadNetworkURLTaskFactoryImpl) TaskMonitor(org.cytoscape.work.TaskMonitor) TaskFactory(org.cytoscape.work.TaskFactory) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

LoadNetworkURLTask (org.cytoscape.task.internal.export.network.LoadNetworkURLTask)3 LoadNetworkURLTaskFactoryImpl (org.cytoscape.task.internal.export.network.LoadNetworkURLTaskFactoryImpl)3 Task (org.cytoscape.work.Task)3 TaskFactory (org.cytoscape.work.TaskFactory)3 TaskIterator (org.cytoscape.work.TaskIterator)3 TaskMonitor (org.cytoscape.work.TaskMonitor)3 Test (org.junit.Test)3 IOException (java.io.IOException)1