Example #1
0
  @Test
  /** Single SBMLTestCase: Can be read and is network created ? */
  public void testSingleTestCase() throws Exception {
    logger.info(String.format("SBMLTestCase: %s", resource));

    final NetworkTestSupport nts = new NetworkTestSupport();
    final CyNetworkFactory networkFactory = nts.getNetworkFactory();
    final CyNetworkViewFactory viewFactory = null;
    TaskMonitor taskMonitor = null;

    // read SBML
    String[] tokens = resource.split("/");
    String fileName = tokens[2];
    InputStream instream = getClass().getResourceAsStream(resource);

    CyNetwork[] networks;
    try {
      // Reader can be tested without service adapter,
      SBMLReaderTask readerTask =
          new SBMLReaderTask(instream, fileName, networkFactory, null, null);
      readerTask.run(taskMonitor);
      networks = readerTask.getNetworks();
      assertFalse(readerTask.getError());
    } catch (Throwable t) {
      networks = null;
      t.printStackTrace();
    }
    // Networks could be read
    assertNotNull(networks);
    assertTrue(networks.length >= 1);
  }
  @Before
  public void setUp() throws Exception {
    NetworkTestSupport netSupport = new NetworkTestSupport();
    TableTestSupport tableSupport = new TableTestSupport();

    CyNetworkFactory cyNetworkFactory = netSupport.getNetworkFactory();

    tableFactory = tableSupport.getTableFactory();
    tableManager = mock(CyTableManager.class);
    dag = cyNetworkFactory.createNetwork();
    tm = mock(TaskMonitor.class);

    serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyTableFactory.class)).thenReturn(tableFactory);
    when(serviceRegistrar.getService(CyTableManager.class)).thenReturn(tableManager);
  }
  @Before
  public void setUp() throws Exception {
    taskMonitor = mock(TaskMonitor.class);

    CyLayoutAlgorithm def = mock(CyLayoutAlgorithm.class);
    Object context = new Object();
    when(def.createLayoutContext()).thenReturn(context);
    when(def.getDefaultLayoutContext()).thenReturn(context);
    when(def.createTaskIterator(
            Mockito.any(CyNetworkView.class),
            Mockito.any(Object.class),
            Mockito.anySet(),
            Mockito.any(String.class)))
        .thenReturn(new TaskIterator(new SimpleTask()));

    layouts = mock(CyLayoutAlgorithmManager.class);
    when(layouts.getDefaultLayout()).thenReturn(def);

    NetworkTestSupport nts = new NetworkTestSupport();
    netFactory = nts.getNetworkFactory();

    networkManager = nts.getNetworkManager();
    rootNetworkManager = nts.getRootNetworkFactory();

    cyApplicationManager = mock(CyApplicationManager.class);

    properties = new Properties();
    CyProperty<Properties> cyProperties =
        new SimpleCyProperty<Properties>(
            "Test", properties, Properties.class, SavePolicy.DO_NOT_SAVE);
    NetworkViewTestSupport nvts = new NetworkViewTestSupport();
    setViewThreshold(DEF_THRESHOLD);

    viewFactory = nvts.getNetworkViewFactory();
    readUtil = new ReadUtils(new StreamUtilImpl(cyProperties));
  }