use of com.opensimulationplatform.core.model.modeldescription.Unit in project osp-validator by open-simulation-platform.
the class VE_Volume_3_Test method valid.
@Test
public void valid() {
Volume volume = new Volume();
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());
volume.setVariables(Arrays.asList(v1, v2));
builder.build(volume);
builder.complete();
List<ValidationDiagnostic<Volume>> diagnostics = validationError.validate();
assertTrue(diagnostics.isEmpty());
}
use of com.opensimulationplatform.core.model.modeldescription.Unit in project osp-validator by open-simulation-platform.
the class VE_VolumeFlowRate_1_Test method valid.
@Test
public void valid() {
VolumeFlowRate volumeFlowRate = new VolumeFlowRate();
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());
volumeFlowRate.setVariables(Arrays.asList(v1, v2));
builder.build(volumeFlowRate);
builder.complete();
List<ValidationDiagnostic<VolumeFlowRate>> diagnostics = validationError.validate();
assertTrue(diagnostics.isEmpty());
}
use of com.opensimulationplatform.core.model.modeldescription.Unit in project osp-validator by open-simulation-platform.
the class VE_VolumeFlowRate_1_Test method invalid.
@Test
public void invalid() {
VolumeFlowRate volumeFlowRate = new VolumeFlowRate();
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(v1.getType());
v2.setUnit(v1.getUnit());
volumeFlowRate.setVariables(Arrays.asList(v1, v2));
builder.build(volumeFlowRate);
builder.complete();
List<ValidationDiagnostic<VolumeFlowRate>> diagnostics = validationError.validate();
assertEquals(1, diagnostics.size());
VolumeFlowRate invalidObject = diagnostics.get(0).getValidatedObject();
List<Variable> variables = invalidObject.getVariables();
assertTrue(variables.contains(v1));
assertTrue(variables.contains(v2));
}
use of com.opensimulationplatform.core.model.modeldescription.Unit in project osp-validator by open-simulation-platform.
the class VE_VolumeFlowRate_2_Test method invalid.
@Test
public void invalid() {
VolumeFlowRate volumeFlowRate = new VolumeFlowRate();
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());
volumeFlowRate.setVariables(Arrays.asList(v1, v2));
builder.build(volumeFlowRate);
builder.complete();
List<ValidationDiagnostic<VolumeFlowRate>> diagnostics = validationError.validate();
assertEquals(1, diagnostics.size());
VolumeFlowRate invalidObject = diagnostics.get(0).getValidatedObject();
List<Variable> variables = invalidObject.getVariables();
assertTrue(variables.contains(v1));
assertTrue(variables.contains(v2));
}
use of com.opensimulationplatform.core.model.modeldescription.Unit in project osp-validator by open-simulation-platform.
the class VariableGroupConnectionsValidatorTest method valid.
@Test
public void valid() {
SystemStructure systemStructure = new SystemStructure();
VariableGroupConnection variableGroupConnection = new VariableGroupConnection();
Simulator simulatorA = new Simulator();
Force forceA = new Force();
forceA.setName("forceA");
Variable variableA = new Variable();
Unit unitA = new Unit();
unitA.setExponent(Unit.Exponent.KILOGRAM, 1);
variableA.setName("variableA");
variableA.setUnit(unitA);
variableA.setType(Variable.Type.REAL);
variableA.setCausality(Variable.Causality.OUTPUT);
forceA.setVariables(Arrays.asList(variableA));
simulatorA.getModelDescription().getVariables().add(variableA);
simulatorA.getModelDescription().getForces().add(forceA);
variableGroupConnection.setSimulatorA(simulatorA);
variableGroupConnection.setVariableGroupA(forceA);
Simulator simulatorB = new Simulator();
Force forceB = new Force();
forceB.setName("forceB");
Variable variableB = new Variable();
Unit unitB = new Unit();
unitB.setExponent(Unit.Exponent.KILOGRAM, 1);
variableB.setName("variableB");
variableB.setUnit(unitB);
variableB.setType(Variable.Type.REAL);
variableB.setCausality(Variable.Causality.INPUT);
forceB.setVariables(Arrays.asList(variableB));
simulatorB.getModelDescription().getVariables().add(variableB);
simulatorB.getModelDescription().getForces().add(forceB);
variableGroupConnection.setSimulatorB(simulatorB);
variableGroupConnection.setVariableGroupB(forceB);
systemStructure.getSimulators().add(simulatorA);
systemStructure.getSimulators().add(simulatorB);
systemStructure.getVariableGroupConnections().add(variableGroupConnection);
VariableGroupConnectionsValidator validator = new VariableGroupConnectionsValidator();
List<ValidationDiagnostic<VariableGroupConnection>> diagnostics = validator.validate(systemStructure);
assertEquals(0, diagnostics.size());
}
Aggregations