Package org.sbml.jsbml

Examples of org.sbml.jsbml.ASTNode


   */
  @Override
  public ASTNodeValue root(double rootExponent, ASTNode radiant)
      throws SBMLException  
  {
    return function("root", new ASTNode(rootExponent), radiant);
  }
View Full Code Here


  }
   */

  @Test public void test_Event_full() throws ParseException
  {
    ASTNode math1 = ASTNode.parseFormula("0");
    Trigger trigger = new  Trigger(2,4);
    ASTNode math = ASTNode.parseFormula("0");
    Event e = new  Event(2,4);
    EventAssignment ea = new  EventAssignment(2,4);
    ea.setVariable( "k");
    ea.setMath(math);
    trigger.setMath(math1);
View Full Code Here

  }

  @Test public void test_Event_removeEventAssignment()
  {
    EventAssignment o1,o2,o3;
    ASTNode math = null;
    try {
      math = ASTNode.parseFormula("0");
    } catch (ParseException e) {
      assertTrue(false);
    }
View Full Code Here

    o3 = null;
  }

  @Test public void test_Event_setDelay() throws ParseException
  {
    ASTNode math1 = ASTNode.parseFormula("0");
    Delay delay = new  Delay(2,4);
    delay.setMath(math1);
    E.setDelay(delay);
    assertTrue(E.getDelay() != null);
    assertEquals( true, E.isSetDelay() );
View Full Code Here

    E1 = null;
  }

  @Test public void test_Event_setTrigger() throws ParseException
  {
    ASTNode math1 =  ASTNode.parseFormula("0");
    Trigger trigger = new  Trigger(2,4);
    trigger.setMath(math1);
    E.setTrigger(trigger);
    assertTrue(E.getTrigger() != null);
    assertEquals( true, E.isSetTrigger() );
View Full Code Here

  @SuppressWarnings("deprecation")
  @Test
public void test_ASTNode_addChild1()
  {
    ASTNode node = new  ASTNode(Type.NAME); // TODO: setName will assign Type.FUNCTION if type and variable are not defined !!!
    ASTNode c1 = new  ASTNode(Type.NAME);
    ASTNode c2 = new  ASTNode(Type.NAME);
    ASTNode c1_1 = new  ASTNode(Type.NAME);

    node.setType(ASTNode.Type.LOGICAL_AND);
    c1.setName( "a");
    c2.setName( "b");
    node.addChild(c1);
    node.addChild(c2);
    assertTrue( node.getNumChildren() == 2 );
   
    // System.out.println("test_ASTNode_addChild1: formula = " + node.toFormula());
   
    assertTrue(JSBML.formulaToString(node).equals( "a and b")); // libsbml output that as a function: and(a, b)
    c1_1.setName( "d");
    node.addChild(c1_1);
    assertTrue( node.getNumChildren() == 3 );
   
    // System.out.println("test_ASTNode_addChild1: formula = " + node.toFormula());
   
View Full Code Here

 
  @SuppressWarnings("deprecation")
  @Test
public void test_ASTNode_children()
  {
    ASTNode parent = new  ASTNode();
    ASTNode left = new  ASTNode();
    ASTNode right = new  ASTNode();
    ASTNode right2 = new  ASTNode();
    parent.setType(ASTNode.Type.PLUS);
    left.setValue(1);
    right.setValue(2);
    right2.setValue(3);
    parent.addChild(left);
    parent.addChild(right);
    assertTrue( parent.getNumChildren() == 2 );
    assertTrue( left.getNumChildren() == 0 );
    assertTrue( right.getNumChildren() == 0 );
    assertTrue( parent.getLeftChild().equals(left) );
    assertTrue( parent.getRightChild().equals(right) );
    assertTrue( parent.getChild(0).equals(left) );
    assertTrue( parent.getChild(1).equals(right) );
   
    try {
      parent.getChild(2); // libsbml would return null instead of throwing an exception: assertTrue( parent.getChild(2) == null );
      assertTrue(false);
    } catch (IndexOutOfBoundsException e) {
      assertTrue(true);
    }
   
    parent.addChild(right2);
    assertTrue( parent.getNumChildren() == 3 );
    assertTrue( left.getNumChildren() == 0 );
    assertTrue( right.getNumChildren() == 0 );
    assertTrue( right2.getNumChildren() == 0 );
    assertTrue( parent.getLeftChild().equals(left) );
    assertTrue( parent.getRightChild().equals(right2) );
    assertTrue( parent.getChild(0).equals(left) );
    assertTrue( parent.getChild(1).equals(right) );
    assertTrue( parent.getChild(2).equals(right2) );
View Full Code Here

  // The ASTNode.getXXX methods will throw exception in JSBML if not called with the right Type
  @SuppressWarnings("deprecation")
  @Test
public void test_ASTNode_create()
  {
    ASTNode n = new  ASTNode();

    assertTrue( n.getType() == ASTNode.Type.UNKNOWN );
   
    try {
      n.getCharacter();
      assertTrue(false);
    } catch (Exception e) {
      assertTrue(true);
    }
   
    assertTrue(n.getName() == null);

    try {
      n.getInteger();
      assertTrue(false);
    } catch (Exception e) {
      assertTrue(true);
    }
    try {
      n.getExponent();
      assertTrue(false);
    } catch (Exception e) {
      assertTrue(true);
    }

    assertTrue( n.getNumChildren() == 0 );

    assertTrue( n.getParentSBMLObject() == null );

    n = null;
  }
View Full Code Here

  // libsbml deepCopy() == JSBML clone()
  @SuppressWarnings("deprecation")
  @Test
public void test_ASTNode_deepCopy_1()
  {
    ASTNode node = new  ASTNode();
    ASTNode child,copy;
    node.setCharacter( '+');
    node.addChild(new  ASTNode());
    node.addChild(new  ASTNode());
    node.getLeftChild().setValue(1);
    node.getRightChild().setValue(2);
    assertTrue( node.getType() == ASTNode.Type.PLUS );
    assertTrue( node.getCharacter() ==  '+'       );
    assertTrue( node.getNumChildren() == 2 );
    child = node.getLeftChild();
    assertTrue( child.getType() == ASTNode.Type.INTEGER );
    assertTrue( child.getInteger() == 1 );
    assertTrue( child.getNumChildren() == 0 );
    child = node.getRightChild();
    assertTrue( child.getType() == ASTNode.Type.INTEGER );
    assertTrue( child.getInteger() == 2 );
    assertTrue( child.getNumChildren() == 0 );
    copy = node.clone();
    assertTruecopy.equals(node) ); // libsbml would say that they are not equals
    assertTrue( copy.getType() == ASTNode.Type.PLUS );
    assertTrue( copy.getCharacter() ==  '+'       );
    assertTrue( copy.getNumChildren() == 2 );
    child = copy.getLeftChild();
    assertTrue( child.equals(node.getLeftChild()) );
    assertTrue( child.getType() == ASTNode.Type.INTEGER );
    assertTrue( child.getInteger() == 1 );
    assertTrue( child.getNumChildren() == 0 );
    child = copy.getRightChild();
    assertTrue( child.equals(node.getRightChild()) );
    assertTrue( child.getType() == ASTNode.Type.INTEGER );
    assertTrue( child.getInteger() == 2 );
    assertTrue( child.getNumChildren() == 0 );
    node = null;
    copy = null;
  }
View Full Code Here

    assertTrue(M.getSpeciesCount() == 1);
  }

  @Test
  public void test_Model_add_get_Event() {
      ASTNode math = null;
      try {
      math = ASTNode.parseFormula("0");
    } catch (ParseException e) {
      assertTrue(false);
    }
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.ASTNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.