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));
}
Aggregations