setMath() public method

public setMath ( ASTNode math ) : int
math ASTNode
return int
 public void test_Constraint()
 {
     Constraint c = new Constraint(2,4);
       assertEquals( false, (c.hasRequiredElements()) );
       c.setMath(libsbml.parseFormula("a+b"));
       assertEquals( true, c.hasRequiredElements() );
       c = null;
 }
 public void test_Model_addConstraint2()
 {
     Model m = new  Model(2,2);
       Constraint c = new  Constraint(2,3);
       c.setMath(libsbml.parseFormula("a+b"));
       int i = m.addConstraint(c);
       assertTrue( i == libsbml.LIBSBML_VERSION_MISMATCH );
       assertTrue( m.getNumConstraints() == 0 );
       c = null;
       m = null;
 }
 public void test_Model_addConstraint1()
 {
     Model m = new  Model(2,2);
       Constraint c = new  Constraint(2,2);
       int i = m.addConstraint(c);
       assertTrue( i == libsbml.LIBSBML_INVALID_OBJECT );
       c.setMath(libsbml.parseFormula("a+b"));
       i = m.addConstraint(c);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( m.getNumConstraints() == 1 );
       c = null;
       m = null;
 }
Esempio n. 4
0
 public void test_Constraint_copyConstructor()
 {
     Constraint o1 = new Constraint(2,4);
       o1.setMetaId("c");
       assertTrue( o1.getMetaId() ==  "c" );
       XMLNode text = XMLNode.convertStringToXMLNode(" Some text ");
       XMLTriple triple = new XMLTriple("p", "http://www.w3.org/1999/xhtml", "");
       XMLAttributes att = new XMLAttributes();
       XMLNamespaces xmlns = new XMLNamespaces();
       xmlns.add("http://www.w3.org/1999/xhtml");
       XMLNode p = new XMLNode(triple,att,xmlns);
       p.addChild(text);
       XMLTriple triple1 = new XMLTriple("message", "", "");
       XMLAttributes att1 = new XMLAttributes();
       XMLNode message = new XMLNode(triple1,att1);
       message.addChild(p);
       ASTNode math = new ASTNode(libsbml.AST_CONSTANT_PI);
       o1.setMath(math);
       o1.setMessage(message);
       math = null;
       message = null;
       XMLNode msg;
       assertTrue( o1.getMath() != null );
       msg = o1.getMessage();
       assertTrue( msg != null );
       Constraint o2 = new Constraint(o1);
       assertTrue( o2.getMetaId() ==  "c" );
       assertTrue( o2.getMath() != null );
       msg = o2.getMessage();
       assertTrue( msg != null );
       assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() );
       o2 = null;
       o1 = null;
 }
 public void test_Constraint_parent_add()
 {
     Constraint ct = new Constraint(2,4);
       Model m = new Model(2,4);
       ct.setMath(libsbml.parseFormula("a-k"));
       m.addConstraint(ct);
       ct = null;
       ListOf lo = m.getListOfConstraints();
       assertTrue( lo == m.getConstraint(0).getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
Esempio n. 6
0
 public void test_Constraint_ancestor_add()
 {
     Constraint ct = new Constraint(2,4);
       Model m = new Model(2,4);
       ct.setMath(libsbml.parseFormula("k+k"));
       m.addConstraint(ct);
       ct = null;
       ListOf lo = m.getListOfConstraints();
       Constraint obj = m.getConstraint(0);
       assertTrue( obj.getAncestorOfType(libsbml.SBML_MODEL) == m );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_EVENT) == null );
 }