Search in sources :

Example 1 with SyncTunableHandlerFactory

use of org.cytoscape.work.internal.sync.SyncTunableHandlerFactory in project cytoscape-impl by cytoscape.

the class LoadVizmapFileTaskFactoryTest method testObserver.

@Test
public void testObserver() throws Exception {
    VizmapReaderManager vizmapReaderMgr = mock(VizmapReaderManager.class);
    VizmapReader reader = mock(VizmapReader.class);
    when(vizmapReaderMgr.getReader(any(URI.class), any(String.class))).thenReturn(reader);
    VisualMappingManager vmMgr = mock(VisualMappingManager.class);
    SynchronousTaskManager<?> syncTaskManager = mock(SynchronousTaskManager.class);
    SyncTunableMutatorFactory mutatorFactory = new SyncTunableMutatorFactory(new SyncTunableHandlerFactory());
    TunableRecorderManager recorderManager = new TunableRecorderManager();
    TunableSetter tunableSetter = new TunableSetterImpl(mutatorFactory, recorderManager);
    CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(VizmapReaderManager.class)).thenReturn(vizmapReaderMgr);
    when(serviceRegistrar.getService(VisualMappingManager.class)).thenReturn(vmMgr);
    when(serviceRegistrar.getService(SynchronousTaskManager.class)).thenReturn(syncTaskManager);
    when(serviceRegistrar.getService(TunableSetter.class)).thenReturn(tunableSetter);
    LoadVizmapFileTaskFactory factory = new LoadVizmapFileTaskFactoryImpl(serviceRegistrar);
    File file = new File("");
    TaskObserver observer = mock(TaskObserver.class);
    TaskIterator iterator = factory.createTaskIterator(file, observer);
    TaskMonitor taskMonitor = mock(TaskMonitor.class);
    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 : Task(org.cytoscape.work.Task) ObservableTask(org.cytoscape.work.ObservableTask) SyncTunableHandlerFactory(org.cytoscape.work.internal.sync.SyncTunableHandlerFactory) VizmapReader(org.cytoscape.io.read.VizmapReader) URI(java.net.URI) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) VizmapReaderManager(org.cytoscape.io.read.VizmapReaderManager) TunableSetter(org.cytoscape.work.TunableSetter) LoadVizmapFileTaskFactory(org.cytoscape.task.read.LoadVizmapFileTaskFactory) TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) TunableRecorderManager(org.cytoscape.work.internal.sync.TunableRecorderManager) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) SyncTunableMutatorFactory(org.cytoscape.work.internal.sync.SyncTunableMutatorFactory) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) TunableSetterImpl(org.cytoscape.work.internal.sync.TunableSetterImpl) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)1 URI (java.net.URI)1 VizmapReader (org.cytoscape.io.read.VizmapReader)1 VizmapReaderManager (org.cytoscape.io.read.VizmapReaderManager)1 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)1 LoadVizmapFileTaskFactory (org.cytoscape.task.read.LoadVizmapFileTaskFactory)1 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)1 ObservableTask (org.cytoscape.work.ObservableTask)1 Task (org.cytoscape.work.Task)1 TaskIterator (org.cytoscape.work.TaskIterator)1 TaskMonitor (org.cytoscape.work.TaskMonitor)1 TaskObserver (org.cytoscape.work.TaskObserver)1 TunableSetter (org.cytoscape.work.TunableSetter)1 SyncTunableHandlerFactory (org.cytoscape.work.internal.sync.SyncTunableHandlerFactory)1 SyncTunableMutatorFactory (org.cytoscape.work.internal.sync.SyncTunableMutatorFactory)1 TunableRecorderManager (org.cytoscape.work.internal.sync.TunableRecorderManager)1 TunableSetterImpl (org.cytoscape.work.internal.sync.TunableSetterImpl)1 Test (org.junit.Test)1