use of org.cytoscape.equations.internal.EquationParserImpl in project cytoscape-impl by cytoscape.
the class TestCyNetworkFactory method mockCyServiceRegistrar.
private static CyServiceRegistrar mockCyServiceRegistrar(CyEventHelper deh) {
CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
CyNetworkNaming namingUtil = mock(CyNetworkNaming.class);
EquationCompiler compiler = new EquationCompilerImpl(new EquationParserImpl(serviceRegistrar));
final Interpreter interpreter = new InterpreterImpl();
when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(deh);
when(serviceRegistrar.getService(CyNetworkNaming.class)).thenReturn(namingUtil);
when(serviceRegistrar.getService(EquationCompiler.class)).thenReturn(compiler);
when(serviceRegistrar.getService(Interpreter.class)).thenReturn(interpreter);
return serviceRegistrar;
}
use of org.cytoscape.equations.internal.EquationParserImpl in project cytoscape-impl by cytoscape.
the class TestCyNetworkFactory method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
eh = new DummyCyEventHelper(false);
Interpreter interpreter = new InterpreterImpl();
EquationCompiler compiler = new EquationCompilerImpl(new EquationParserImpl(serviceRegistrar));
when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eh);
when(serviceRegistrar.getService(CyNetworkNaming.class)).thenReturn(namingUtil);
when(serviceRegistrar.getService(EquationCompiler.class)).thenReturn(compiler);
when(serviceRegistrar.getService(Interpreter.class)).thenReturn(interpreter);
netTblMgr = new CyNetworkTableManagerImpl();
netMgr = new CyNetworkManagerImpl(serviceRegistrar);
tblMgr = new CyTableManagerImpl(netTblMgr, netMgr, serviceRegistrar);
tblFactory = new CyTableFactoryImpl(eh, serviceRegistrar);
netFactory = new CyNetworkFactoryImpl(eh, tblMgr, netTblMgr, tblFactory, serviceRegistrar);
}
use of org.cytoscape.equations.internal.EquationParserImpl in project cytoscape-impl by cytoscape.
the class TableTestSupportTest method setUp.
@Before
public void setUp() {
eventHelper = support.getDummyCyEventHelper();
EquationCompiler compiler = new EquationCompilerImpl(new EquationParserImpl(serviceRegistrar));
when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
when(serviceRegistrar.getService(CyNetworkNaming.class)).thenReturn(namingUtil);
when(serviceRegistrar.getService(EquationCompiler.class)).thenReturn(compiler);
table = factory.createTable(Integer.toString(rand.nextInt(10000)), CyIdentifiable.SUID, Long.class, false, true);
table2 = factory.createTable(Integer.toString(rand.nextInt(10000)), CyIdentifiable.SUID, Long.class, false, true);
attrs = table.getRow(1l);
CyTableManagerImpl tblMgr = new CyTableManagerImpl(new CyNetworkTableManagerImpl(), new CyNetworkManagerImpl(serviceRegistrar), serviceRegistrar);
tblMgr.addTable(table);
((CyTableImpl) table).handleEvent(new TableAddedEvent(tblMgr, table));
tblMgr.addTable(table2);
((CyTableImpl) table2).handleEvent(new TableAddedEvent(tblMgr, table2));
}
use of org.cytoscape.equations.internal.EquationParserImpl in project cytoscape-impl by cytoscape.
the class EquationTest method setUp.
@Before
public void setUp() {
support = new TableTestSupport();
eventHelper = new DummyCyEventHelper();
serviceRegistrar = mock(CyServiceRegistrar.class);
when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
parser = new EquationParserImpl(serviceRegistrar);
}
use of org.cytoscape.equations.internal.EquationParserImpl in project cytoscape-impl by cytoscape.
the class InDegreeTest method test.
@Test
public void test() {
final EquationParserImpl parser = new EquationParserImpl(serviceRegistrar);
final EquationCompilerImpl compiler = new EquationCompilerImpl(parser);
parser.registerFunctionInternal(new InDegree(serviceRegistrar));
final Map<String, Class<?>> variableNameToTypeMap = new HashMap<String, Class<?>>();
if (!compiler.compile("=INDEGREE(101)", variableNameToTypeMap))
fail(compiler.getLastErrorMsg());
final Equation equation = compiler.getEquation();
final Interpreter interpreter = new InterpreterImpl();
final Map<String, IdentDescriptor> variableNameToDescriptorMap = new HashMap<String, IdentDescriptor>();
assertEquals("Equation evaluation returned an unexpected result!", 3L, interpreter.execute(equation, variableNameToDescriptorMap));
}
Aggregations