use of com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force 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.variablegroup.force.Force 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.variablegroup.force.Force in project osp-validator by open-simulation-platform.
the class VE_Force_1_Test method valid.
@Test
public void valid() {
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));
builder.build(force);
builder.complete();
List<ValidationDiagnostic<Force>> diagnostics = validationError.validate();
assertTrue(diagnostics.isEmpty());
}
use of com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force in project osp-validator by open-simulation-platform.
the class VE_Force_2_Test method valid.
@Test
public void valid() {
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));
builder.build(force);
builder.complete();
List<ValidationDiagnostic<Force>> diagnostics = validationError.validate();
assertTrue(diagnostics.isEmpty());
}
use of com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force in project osp-validator by open-simulation-platform.
the class VE_Force_2_Test method invalid.
@Test
public void invalid() {
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(Variable.Type.INTEGER);
v2.setUnit(v1.getUnit());
force.setVariables(Arrays.asList(v1, v2));
builder.build(force);
builder.complete();
List<ValidationDiagnostic<Force>> diagnostics = validationError.validate();
assertEquals(1, diagnostics.size());
Force invalidObject = diagnostics.get(0).getValidatedObject();
List<Variable> variables = invalidObject.getVariables();
assertTrue(variables.contains(v1));
assertTrue(variables.contains(v2));
}
Aggregations