use of com.opensimulationplatform.core.model.modeldescription.ModelDescription in project osp-validator by open-simulation-platform.
the class ForceValidatorTest method invalid.
@Test
public void invalid() {
ModelDescription modelDescription = new ModelDescription();
Variable v1 = new Variable();
v1.setCausality(Variable.Causality.INPUT);
v1.setType(Variable.Type.REAL);
v1.setUnit(new Unit());
Variable v2 = new Variable();
v2.setCausality(Variable.Causality.OUTPUT);
v2.setType(Variable.Type.INTEGER);
Unit unit = new Unit();
unit.setExponent(Unit.Exponent.KILOGRAM, 1);
v2.setUnit(unit);
Force force = new Force();
force.setVariables(Arrays.asList(v1, v2));
modelDescription.getForces().add(force);
ForceValidator v = new ForceValidator();
List<ValidationDiagnostic<Force>> diagnostics = v.validate(modelDescription);
assertEquals(3, diagnostics.size());
for (ValidationDiagnostic<Force> diagnostic : diagnostics) {
assertEquals(force, diagnostic.getValidatedObject());
}
}
use of com.opensimulationplatform.core.model.modeldescription.ModelDescription in project osp-validator by open-simulation-platform.
the class ForceValidatorTest method valid.
@Test
public void valid() {
ModelDescription modelDescription = new ModelDescription();
Force force = new Force();
Variable v1 = new Variable();
v1.setCausality(Variable.Causality.INPUT);
v1.setType(Variable.Type.REAL);
v1.setUnit(new Unit());
Variable v2 = new Variable();
v2.setCausality(v1.getCausality());
v2.setType(v1.getType());
v2.setUnit(v1.getUnit());
force.setVariables(Arrays.asList(v1, v2));
modelDescription.getForces().add(force);
ForceValidator v = new ForceValidator();
List<ValidationDiagnostic<Force>> diagnostics = v.validate(modelDescription);
assertTrue(diagnostics.isEmpty());
}
use of com.opensimulationplatform.core.model.modeldescription.ModelDescription in project osp-validator by open-simulation-platform.
the class LinearDisplacementValidatorTest method invalid.
@Test
public void invalid() {
ModelDescription modelDescription = new ModelDescription();
Variable v1 = new Variable();
v1.setCausality(Variable.Causality.INPUT);
v1.setType(Variable.Type.REAL);
v1.setUnit(new Unit());
Variable v2 = new Variable();
v2.setCausality(Variable.Causality.OUTPUT);
v2.setType(Variable.Type.INTEGER);
Unit unit = new Unit();
unit.setExponent(Unit.Exponent.KILOGRAM, 1);
v2.setUnit(unit);
LinearDisplacement linearDisplacement = new LinearDisplacement();
linearDisplacement.setVariables(Arrays.asList(v1, v2));
modelDescription.getLinearDisplacements().add(linearDisplacement);
LinearDisplacementValidator v = new LinearDisplacementValidator();
List<ValidationDiagnostic<LinearDisplacement>> diagnostics = v.validate(modelDescription);
assertEquals(3, diagnostics.size());
for (ValidationDiagnostic<LinearDisplacement> diagnostic : diagnostics) {
assertEquals(linearDisplacement, diagnostic.getValidatedObject());
}
}
use of com.opensimulationplatform.core.model.modeldescription.ModelDescription in project osp-validator by open-simulation-platform.
the class TorqueValidatorTest method invalid.
@Test
public void invalid() {
ModelDescription modelDescription = new ModelDescription();
Variable v1 = new Variable();
v1.setCausality(Variable.Causality.INPUT);
v1.setType(Variable.Type.REAL);
v1.setUnit(new Unit());
Variable v2 = new Variable();
v2.setCausality(Variable.Causality.OUTPUT);
v2.setType(Variable.Type.INTEGER);
Unit unit = new Unit();
unit.setExponent(Unit.Exponent.KILOGRAM, 1);
v2.setUnit(unit);
Torque torque = new Torque();
torque.setVariables(Arrays.asList(v1, v2));
modelDescription.getTorques().add(torque);
TorqueValidator v = new TorqueValidator();
List<ValidationDiagnostic<Torque>> diagnostics = v.validate(modelDescription);
assertEquals(3, diagnostics.size());
for (ValidationDiagnostic<Torque> diagnostic : diagnostics) {
assertEquals(torque, diagnostic.getValidatedObject());
}
}
use of com.opensimulationplatform.core.model.modeldescription.ModelDescription in project osp-validator by open-simulation-platform.
the class PressureValidatorTest method invalid.
@Test
public void invalid() {
ModelDescription modelDescription = new ModelDescription();
Variable v1 = new Variable();
v1.setCausality(Variable.Causality.INPUT);
v1.setType(Variable.Type.REAL);
v1.setUnit(new Unit());
Variable v2 = new Variable();
v2.setCausality(Variable.Causality.OUTPUT);
v2.setType(Variable.Type.INTEGER);
Unit unit = new Unit();
unit.setExponent(Unit.Exponent.KILOGRAM, 1);
v2.setUnit(unit);
Pressure pressure = new Pressure();
pressure.setVariables(Arrays.asList(v1, v2));
modelDescription.getPressures().add(pressure);
PressureValidator v = new PressureValidator();
List<ValidationDiagnostic<Pressure>> diagnostics = v.validate(modelDescription);
assertEquals(3, diagnostics.size());
for (ValidationDiagnostic<Pressure> diagnostic : diagnostics) {
assertEquals(pressure, diagnostic.getValidatedObject());
}
}
Aggregations