public void test_WriteSBML_Event_full() { string expected = "<event id=\"e\">\n" + " <trigger>\n" + " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n" + " <apply>\n" + " <leq/>\n" + " <ci> P1 </ci>\n" + " <ci> t </ci>\n" + " </apply>\n" + " </math>\n" + " </trigger>\n" + " <listOfEventAssignments>\n" + " <eventAssignment variable=\"k2\" sboTerm=\"SBO:0000064\">\n" + " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n" + " <cn type=\"integer\"> 0 </cn>\n" + " </math>\n" + " </eventAssignment>\n" + " </listOfEventAssignments>\n" + "</event>"; D.setLevelAndVersion(2,3,false); Event e = D.createModel().createEvent(); e.setId("e"); ASTNode node = libsbml.parseFormula("leq(P1,t)"); Trigger t = new Trigger ( 2,3 ); t.setMath(node); ASTNode math = libsbml.parseFormula("0"); EventAssignment ea = new EventAssignment ( 2,3 ); ea.setVariable("k2"); ea.setMath(math); ea.setSBOTerm(64); e.setTrigger(t); e.addEventAssignment(ea); assertEquals( true, equals(expected,e.toSBML()) ); }
public void test_WriteSBML_Event_trigger_withSBO() { string expected = "<event id=\"e\">\n" + " <trigger sboTerm=\"SBO:0000064\">\n" + " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n" + " <apply>\n" + " <leq/>\n" + " <ci> P1 </ci>\n" + " <ci> t </ci>\n" + " </apply>\n" + " </math>\n" + " </trigger>\n" + "</event>"; D.setLevelAndVersion(2,3,false); Event e = D.createModel().createEvent(); e.setId("e"); ASTNode node = libsbml.parseFormula("leq(P1,t)"); Trigger t = new Trigger ( 2,3 ); t.setMath(node); t.setSBOTerm(64); e.setTrigger(t); assertEquals( true, equals(expected,e.toSBML()) ); }
public void test_Event_setTrigger2() { ASTNode math1 = libsbml.parseFormula("0"); Trigger trigger = new Trigger(2,4); trigger.setMath(math1); int i = E.setTrigger(trigger); assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS ); assertNotEquals(E.getTrigger(),null); assertEquals( true, E.isSetTrigger() ); }
public void test_WriteSBML_Event_both() { string expected = "<event id=\"e\">\n" + " <trigger>\n" + " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n" + " <apply>\n" + " <leq/>\n" + " <ci> P1 </ci>\n" + " <ci> t </ci>\n" + " </apply>\n" + " </math>\n" + " </trigger>\n" + " <delay>\n" + " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n" + " <cn type=\"integer\"> 5 </cn>\n" + " </math>\n" + " </delay>\n" + "</event>"; D.setLevelAndVersion(2,1,false); Event e = D.createModel().createEvent(); e.setId("e"); ASTNode node1 = libsbml.parseFormula("leq(P1,t)"); Trigger t = new Trigger ( 2,1 ); t.setMath(node1); ASTNode node = libsbml.parseFormula("5"); Delay d = new Delay ( 2,1 ); d.setMath(node); e.setDelay(d); e.setTrigger(t); assertEquals( true, equals(expected,e.toSBML()) ); }
public void test_Trigger_copyConstructor() { Trigger o1 = new Trigger(2,4); ASTNode node = new ASTNode(libsbml.AST_CONSTANT_PI); o1.setMath(node); node = null; assertTrue( o1.getMath() != null ); Trigger o2 = new Trigger(o1); assertTrue( o2.getMath() != null ); assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() ); o2 = null; o1 = null; }
public void test_Event_full() { ASTNode math1 = libsbml.parseFormula("0"); Trigger trigger = new Trigger(2,4); ASTNode math = libsbml.parseFormula("0"); Event e = new Event(2,4); EventAssignment ea = new EventAssignment(2,4); ea.setVariable( "k"); ea.setMath(math); trigger.setMath(math1); e.setTrigger(trigger); e.setId( "e1"); e.setName( "Set k2 to zero when P1 <= t"); e.addEventAssignment(ea); assertTrue( e.getNumEventAssignments() == 1 ); assertNotEquals(e.getEventAssignment(0),ea); math = null; e = null; }
public void test_Event_setTrigger() { ASTNode math1 = libsbml.parseFormula("0"); Trigger trigger = new Trigger(2,4); trigger.setMath(math1); E.setTrigger(trigger); assertNotEquals(E.getTrigger(),null); assertEquals( true, E.isSetTrigger() ); if (E.getTrigger() == trigger); { } E.setTrigger(E.getTrigger()); assertNotEquals(E.getTrigger(),trigger); E.setTrigger(null); assertEquals( false, E.isSetTrigger() ); if (E.getTrigger() != null); { } }
public void test_Trigger() { Trigger t = new Trigger(2,4); assertEquals( false, (t.hasRequiredElements()) ); t.setMath(libsbml.parseFormula("ar")); assertEquals( true, t.hasRequiredElements() ); t = null; }
public void test_Event_parent_NULL() { SBMLDocument d = new SBMLDocument(2,4); Model m = d.createModel(); Event c = m.createEvent(); EventAssignment ea = c.createEventAssignment(); Trigger t = new Trigger(2,4); t.setMath(new ASTNode()); Delay dy = new Delay(2,4); dy.setMath(new ASTNode()); c.setTrigger(t); c.setDelay(dy); assertTrue( c.getAncestorOfType(libsbml.SBML_MODEL) == m ); assertTrue( c.getTrigger().getParentSBMLObject() == c ); assertEquals(c.getDelay().getSBMLDocument(),d); assertTrue( ea.getAncestorOfType(libsbml.SBML_EVENT) == c ); Event c1 = c.clone(); d = null; assertTrue( c1.getAncestorOfType(libsbml.SBML_MODEL) == null ); assertTrue( c1.getParentSBMLObject() == null ); assertEquals(c1.getSBMLDocument(),null); assertTrue( c1.getEventAssignment(0).getAncestorOfType(libsbml.SBML_MODEL) == null ); assertTrue( c1.getEventAssignment(0).getAncestorOfType(libsbml.SBML_EVENT) == c1 ); assertTrue( c1.getEventAssignment(0).getParentSBMLObject() != null ); assertEquals(c1.getEventAssignment(0).getSBMLDocument(),null); assertTrue( c1.getTrigger().getAncestorOfType(libsbml.SBML_MODEL) == null ); assertTrue( c1.getTrigger().getAncestorOfType(libsbml.SBML_EVENT) == c1 ); assertTrue( c1.getTrigger().getParentSBMLObject() != null ); assertEquals(c1.getTrigger().getSBMLDocument(),null); assertTrue( c1.getDelay().getAncestorOfType(libsbml.SBML_MODEL) == null ); assertTrue( c1.getDelay().getAncestorOfType(libsbml.SBML_EVENT) == c1 ); assertTrue( c1.getDelay().getParentSBMLObject() != null ); assertEquals(c1.getDelay().getSBMLDocument(),null); c1 = null; }