setId() public method

public setId ( string sid ) : int
sid string
return int
 public void test_Model_addUnitDefinition5()
 {
     Model m = new  Model(2,2);
       UnitDefinition ud = new  UnitDefinition(2,2);
       ud.setId( "ud");
       ud.createUnit();
       UnitDefinition ud1 = new  UnitDefinition(2,2);
       ud1.setId( "ud");
       ud1.createUnit();
       int i = m.addUnitDefinition(ud);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( m.getNumUnitDefinitions() == 1 );
       i = m.addUnitDefinition(ud1);
       assertTrue( i == libsbml.LIBSBML_DUPLICATE_OBJECT_ID );
       assertTrue( m.getNumUnitDefinitions() == 1 );
       ud = null;
       ud1 = null;
       m = null;
 }
 public void test_internal_consistency_check_99905_unitdef()
 {
     SBMLDocument d = new SBMLDocument(2,4);
       long errors;
       UnitDefinition u = new UnitDefinition(2,4);
       d.setLevelAndVersion(2,2,false);
       Model m = d.createModel();
       u.setId("ud");
       u.setSBOTerm(9);
       u.createUnit();
       m.addUnitDefinition(u);
       errors = d.checkInternalConsistency();
       assertTrue( errors == 0 );
       d = null;
 }
 public void test_Model_addUnitDefinition3()
 {
     Model m = new  Model(2,2);
       UnitDefinition ud = new  UnitDefinition(1,2);
       ud.createUnit();
       ud.setId( "ud");
       int i = m.addUnitDefinition(ud);
       assertTrue( i == libsbml.LIBSBML_LEVEL_MISMATCH );
       assertTrue( m.getNumUnitDefinitions() == 0 );
       ud = null;
       m = null;
 }
Example #4
0
 public void test_UnitDefinition_copyConstructor()
 {
     UnitDefinition o1 = new UnitDefinition(2,4);
       o1.setId("c");
       assertTrue( o1.getId() ==  "c" );
       UnitDefinition o2 = new UnitDefinition(o1);
       assertTrue( o2.getId() ==  "c" );
       assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() );
       o2 = null;
       o1 = null;
 }
 public void test_internal_consistency_check_99904_unitdef()
 {
     SBMLDocument d = new SBMLDocument(2,4);
       long errors;
       UnitDefinition u = new UnitDefinition(2,4);
       d.setLevelAndVersion(1,2,false);
       Model m = d.createModel();
       Compartment c = m.createCompartment();
       c.setId("cc");
       u.setId("ud");
       u.setMetaId("mmm");
       u.createUnit();
       m.addUnitDefinition(u);
       errors = d.checkInternalConsistency();
       assertTrue( errors == 0 );
       d = null;
 }
 public void test_UnitDefinition_printUnits()
 {
     UnitDefinition ud = new  UnitDefinition(2,4);
       ud.setId( "mmls");
       Unit perTime = ud.createUnit();
       perTime.setKind(libsbml.UnitKind_forName("second"));
       perTime.setExponent(-1);
       string ud_str = UnitDefinition.printUnits(ud,false);
       assertTrue((                 "second (exponent = -1, multiplier = 1, scale = 0)" == ud_str ));
       string ud_str1 = UnitDefinition.printUnits(ud,true);
       assertTrue((  "(1 second)^-1" == ud_str1 ));
       UnitDefinition ud1 = new  UnitDefinition(2,4);
       ud1.setId( "mmls");
       Unit u = ud1.createUnit();
       u.setKind(libsbml.UNIT_KIND_KILOGRAM);
       u.setExponent(1);
       u.setScale(2);
       u.setMultiplier(3.0);
       string ud_str2 = UnitDefinition.printUnits(ud1,false);
       assertTrue((                 "kilogram (exponent = 1, multiplier = 3, scale = 2)" == ud_str2 ));
       string ud_str3 = UnitDefinition.printUnits(ud1,true);
       assertTrue((  "(300 kilogram)^1" == ud_str3 ));
 }
Example #7
0
 public void test_UnitDefinition_assignmentOperator()
 {
     UnitDefinition o1 = new UnitDefinition(2,4);
       o1.setId("c");
       assertTrue( o1.getId() ==  "c" );
       UnitDefinition o2 = new UnitDefinition(2,4);
       o2 = o1;
       assertTrue( o2.getId() ==  "c" );
       assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() );
       o2 = null;
       o1 = null;
 }
Example #8
0
 public void test_Model_getUnitDefinition()
 {
     UnitDefinition ud1 = new  UnitDefinition(2,4);
       UnitDefinition ud2 = new  UnitDefinition(2,4);
       ud1.setId( "mmls"   );
       ud2.setId( "volume" );
       ud1.createUnit();
       ud2.createUnit();
       M.addUnitDefinition(ud1);
       M.addUnitDefinition(ud2);
       assertTrue( M.getNumUnitDefinitions() == 2 );
       ud1 = M.getUnitDefinition(0);
       ud2 = M.getUnitDefinition(1);
       assertTrue((  "mmls"    == ud1.getId() ));
       assertTrue((  "volume"  == ud2.getId() ));
 }
Example #9
0
 public void test_Model_getUnitDefinitionById()
 {
     UnitDefinition ud1 = new  UnitDefinition(2,4);
       UnitDefinition ud2 = new  UnitDefinition(2,4);
       ud1.setId( "mmls"   );
       ud2.setId( "volume" );
       ud1.createUnit();
       ud2.createUnit();
       M.addUnitDefinition(ud1);
       M.addUnitDefinition(ud2);
       assertTrue( M.getNumUnitDefinitions() == 2 );
       assertNotEquals(M.getUnitDefinition( "mmls"       ),ud1);
       assertNotEquals(M.getUnitDefinition( "volume"     ),ud2);
       assertEquals(M.getUnitDefinition( "rototillers"),null);
 }
Example #10
0
 public void test_Model_add_get_UnitDefinitions()
 {
     UnitDefinition ud1 = new  UnitDefinition(2,4);
       UnitDefinition ud2 = new  UnitDefinition(2,4);
       ud1.setId( "ud1");
       ud2.setId( "ud2");
       ud1.createUnit();
       ud2.createUnit();
       M.addUnitDefinition(ud1);
       M.addUnitDefinition(ud2);
       assertTrue( M.getNumUnitDefinitions() == 2 );
       assertNotEquals(M.getUnitDefinition(0),ud1);
       assertNotEquals(M.getUnitDefinition(1),ud2);
       assertEquals(M.getUnitDefinition(2),null);
 }
Example #11
0
 public void test_SBMLDocument_setLevelAndVersion_Error()
 {
     SBMLDocument d = new  SBMLDocument();
       d.setLevelAndVersion(2,1,true);
       Model m1 = new  Model(2,1);
       Unit u = new  Unit(2,1);
       u.setKind(libsbml.UnitKind_forName("mole"));
       u.setOffset(3.2);
       UnitDefinition ud = new  UnitDefinition(2,1);
       ud.setId( "ud");
       ud.addUnit(u);
       m1.addUnitDefinition(ud);
       d.setModel(m1);
       assertTrue( d.setLevelAndVersion(2,2,true) == false );
       assertTrue( d.setLevelAndVersion(2,3,true) == false );
       assertTrue( d.setLevelAndVersion(1,2,true) == false );
       assertTrue( d.setLevelAndVersion(1,1,true) == false );
       d = null;
 }
 public void test_UnitDefinition_parent_add()
 {
     UnitDefinition ia = new UnitDefinition(2,4);
       Model m = new Model(2,4);
       ia.setId("u");
       ia.createUnit();
       m.addUnitDefinition(ia);
       ia = null;
       ListOf lo = m.getListOfUnitDefinitions();
       assertTrue( lo == m.getUnitDefinition(0).getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
 public void test_UnitDefinition()
 {
     UnitDefinition ud = new UnitDefinition(2,4);
       assertEquals( false, (ud.hasRequiredAttributes()) );
       ud.setId("ud");
       assertEquals( true, ud.hasRequiredAttributes() );
       ud = null;
 }
Example #14
0
 public void test_UnitDefinition_ancestor_add()
 {
     UnitDefinition ia = new UnitDefinition(2,4);
       Model m = new Model(2,4);
       ia.setId("u");
       ia.createUnit();
       m.addUnitDefinition(ia);
       ia = null;
       ListOf lo = m.getListOfUnitDefinitions();
       UnitDefinition obj = m.getUnitDefinition(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 );
 }