Author: ruschein
Date: 2010-11-10 14:28:30 -0800 (Wed, 10 Nov 2010)
New Revision: 22806

Added:
   
core3/equations-functions-impl/trunk/src/test/java/org/cytoscape/equations/internal/functions/SourceIDTest.java
   
core3/equations-functions-impl/trunk/src/test/java/org/cytoscape/equations/internal/functions/TargetIDTest.java
Log:
Added 2 more tests.

Copied: 
core3/equations-functions-impl/trunk/src/test/java/org/cytoscape/equations/internal/functions/SourceIDTest.java
 (from rev 22803, 
core3/equations-functions-impl/trunk/src/test/java/org/cytoscape/equations/internal/functions/DegreeTest.java)
===================================================================
--- 
core3/equations-functions-impl/trunk/src/test/java/org/cytoscape/equations/internal/functions/SourceIDTest.java
                             (rev 0)
+++ 
core3/equations-functions-impl/trunk/src/test/java/org/cytoscape/equations/internal/functions/SourceIDTest.java
     2010-11-10 22:28:30 UTC (rev 22806)
@@ -0,0 +1,91 @@
+/*
+  File: SourceIDTest.java
+
+  Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+  This library is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2.1 of the License, or
+  any later version.
+
+  This library is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+  MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+  documentation provided hereunder is on an "as is" basis, and the
+  Institute for Systems Biology and the Whitehead Institute
+  have no obligations to provide maintenance, support,
+  updates, enhancements or modifications.  In no event shall the
+  Institute for Systems Biology and the Whitehead Institute
+  be liable to any party for direct, indirect, special,
+  incidental or consequential damages, including lost profits, arising
+  out of the use of this software and its documentation, even if the
+  Institute for Systems Biology and the Whitehead Institute
+  have been advised of the possibility of such damage.  See
+  the GNU Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with this library; if not, write to the Free Software Foundation,
+  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.equations.internal.functions;
+
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.Mockito.*;
+
+import org.cytoscape.equations.EqnCompiler;
+import org.cytoscape.equations.Equation;
+import org.cytoscape.equations.IdentDescriptor;
+import org.cytoscape.equations.Interpreter;
+import org.cytoscape.equations.internal.EqnCompilerImpl;
+import org.cytoscape.equations.internal.EqnParserImpl;
+import org.cytoscape.equations.internal.SUIDToEdgeMapper;
+import org.cytoscape.equations.internal.interpreter.InterpreterImpl;
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.model.events.AddedEdgeEvent;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+
+
+public class SourceIDTest {
+       private SUIDToEdgeMapper suidToEdgeMapper;
+
+       @Before
+       public void init() {
+               final CyNode node = mock(CyNode.class);
+               when(node.getSUID()).thenReturn(101L);
+
+               final List<CyEdge> edgeList = mock(List.class);
+               when(edgeList.size()).thenReturn(3);
+
+               final CyNetwork network = mock(CyNetwork.class);
+
+               final CyEdge edge = mock(CyEdge.class);
+               when(edge.getSUID()).thenReturn(11L);
+               when(edge.getSource()).thenReturn(node);
+
+               suidToEdgeMapper = new SUIDToEdgeMapper();
+               suidToEdgeMapper.handleEvent(new AddedEdgeEvent(network, edge));
+       }
+
+       @Test
+       public void test() {
+               final EqnCompiler compiler = new EqnCompilerImpl(new 
EqnParserImpl());
+               compiler.getParser().registerFunction(new 
SourceID(suidToEdgeMapper));
+               final Map<String, Class> variableNameToTypeMap = new 
HashMap<String, Class>();
+               if (!compiler.compile("=SOURCEID(11)", 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!", 101L,
+                            interpreter.execute(equation, 
variableNameToDescriptorMap));
+       }
+}

Copied: 
core3/equations-functions-impl/trunk/src/test/java/org/cytoscape/equations/internal/functions/TargetIDTest.java
 (from rev 22803, 
core3/equations-functions-impl/trunk/src/test/java/org/cytoscape/equations/internal/functions/DegreeTest.java)
===================================================================
--- 
core3/equations-functions-impl/trunk/src/test/java/org/cytoscape/equations/internal/functions/TargetIDTest.java
                             (rev 0)
+++ 
core3/equations-functions-impl/trunk/src/test/java/org/cytoscape/equations/internal/functions/TargetIDTest.java
     2010-11-10 22:28:30 UTC (rev 22806)
@@ -0,0 +1,91 @@
+/*
+  File: TargetIDTest.java
+
+  Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+  This library is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2.1 of the License, or
+  any later version.
+
+  This library is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+  MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+  documentation provided hereunder is on an "as is" basis, and the
+  Institute for Systems Biology and the Whitehead Institute
+  have no obligations to provide maintenance, support,
+  updates, enhancements or modifications.  In no event shall the
+  Institute for Systems Biology and the Whitehead Institute
+  be liable to any party for direct, indirect, special,
+  incidental or consequential damages, including lost profits, arising
+  out of the use of this software and its documentation, even if the
+  Institute for Systems Biology and the Whitehead Institute
+  have been advised of the possibility of such damage.  See
+  the GNU Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with this library; if not, write to the Free Software Foundation,
+  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.equations.internal.functions;
+
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.Mockito.*;
+
+import org.cytoscape.equations.EqnCompiler;
+import org.cytoscape.equations.Equation;
+import org.cytoscape.equations.IdentDescriptor;
+import org.cytoscape.equations.Interpreter;
+import org.cytoscape.equations.internal.EqnCompilerImpl;
+import org.cytoscape.equations.internal.EqnParserImpl;
+import org.cytoscape.equations.internal.SUIDToEdgeMapper;
+import org.cytoscape.equations.internal.interpreter.InterpreterImpl;
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.model.events.AddedEdgeEvent;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+
+
+public class TargetIDTest {
+       private SUIDToEdgeMapper suidToEdgeMapper;
+
+       @Before
+       public void init() {
+               final CyNode node = mock(CyNode.class);
+               when(node.getSUID()).thenReturn(101L);
+
+               final List<CyEdge> edgeList = mock(List.class);
+               when(edgeList.size()).thenReturn(3);
+
+               final CyNetwork network = mock(CyNetwork.class);
+
+               final CyEdge edge = mock(CyEdge.class);
+               when(edge.getSUID()).thenReturn(11L);
+               when(edge.getTarget()).thenReturn(node);
+
+               suidToEdgeMapper = new SUIDToEdgeMapper();
+               suidToEdgeMapper.handleEvent(new AddedEdgeEvent(network, edge));
+       }
+
+       @Test
+       public void test() {
+               final EqnCompiler compiler = new EqnCompilerImpl(new 
EqnParserImpl());
+               compiler.getParser().registerFunction(new 
TargetID(suidToEdgeMapper));
+               final Map<String, Class> variableNameToTypeMap = new 
HashMap<String, Class>();
+               if (!compiler.compile("=TARGETID(11)", 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!", 101L,
+                            interpreter.execute(equation, 
variableNameToDescriptorMap));
+       }
+}

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to