addUnitDefinition() публичный Метод

public addUnitDefinition ( UnitDefinition ud ) : int
ud UnitDefinition
Результат int
 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() );
 }
Пример #2
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 );
 }
Пример #3
0
 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;
 }
Пример #4
0
 public void test_Model_addUnitDefinition4()
 {
     Model m = new  Model(2,2);
       UnitDefinition ud = null;
       int i = m.addUnitDefinition(ud);
       assertTrue( i == libsbml.LIBSBML_OPERATION_FAILED );
       assertTrue( m.getNumUnitDefinitions() == 0 );
       m = null;
 }
Пример #5
0
 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;
 }
 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;
 }