use of com.opensimulationplatform.core.validation.ValidationDiagnostic in project osp-validator by open-simulation-platform.
the class LinearMechanicalQuasiPortValidatorTest method invalid.
@Test
public void invalid() {
ModelDescription modelDescription = new ModelDescription();
Variable v1 = new Variable();
v1.setCausality(Variable.Causality.OUTPUT);
Force force = new Force();
force.setVariables(Arrays.asList(v1));
Variable v2 = new Variable();
v2.setCausality(Variable.Causality.OUTPUT);
LinearDisplacement linearDisplacement = new LinearDisplacement();
linearDisplacement.setVariables(Arrays.asList(v2));
LinearMechanicalQuasiPort linearMechanicalQuasiPort = new LinearMechanicalQuasiPort();
linearMechanicalQuasiPort.setForce(force);
linearMechanicalQuasiPort.setLinearDisplacement(linearDisplacement);
modelDescription.getLinearMechanicalQuasiPorts().add(linearMechanicalQuasiPort);
LinearMechanicalQuasiPortValidator linearMechanicalQuasiPortValidator = new LinearMechanicalQuasiPortValidator();
List<ValidationDiagnostic<LinearMechanicalQuasiPort>> diagnostics = linearMechanicalQuasiPortValidator.validate(modelDescription);
assertEquals(1, diagnostics.size());
assertEquals(linearMechanicalQuasiPort, diagnostics.get(0).getValidatedObject());
}
use of com.opensimulationplatform.core.validation.ValidationDiagnostic in project osp-validator by open-simulation-platform.
the class VE_LinearMechanicalQuasiPort_1_Test method valid.
@Test
public void valid() {
Variable v1 = new Variable();
v1.setCausality(Variable.Causality.OUTPUT);
v1.setUnit(new Unit());
v1.setType(Variable.Type.REAL);
Variable v2 = new Variable();
v2.setCausality(Variable.Causality.OUTPUT);
v2.setUnit(new Unit());
v2.setType(Variable.Type.REAL);
Variable v3 = new Variable();
v3.setCausality(Variable.Causality.INPUT);
v3.setUnit(new Unit());
v3.setType(Variable.Type.REAL);
Variable v4 = new Variable();
v4.setCausality(Variable.Causality.INPUT);
v4.setUnit(new Unit());
v4.setType(Variable.Type.REAL);
Force force = new Force();
force.setVariables(Arrays.asList(v1, v2));
LinearDisplacement linearDisplacement = new LinearDisplacement();
linearDisplacement.setVariables(Arrays.asList(v3, v4));
LinearMechanicalQuasiPort linearMechanicalQuasiPort = new LinearMechanicalQuasiPort();
linearMechanicalQuasiPort.setForce(force);
linearMechanicalQuasiPort.setLinearDisplacement(linearDisplacement);
builder.build(linearMechanicalQuasiPort);
builder.complete();
List<ValidationDiagnostic<LinearMechanicalQuasiPort>> diagnostics = validationError.validate();
assertTrue(diagnostics.isEmpty());
}
use of com.opensimulationplatform.core.validation.ValidationDiagnostic in project osp-validator by open-simulation-platform.
the class VE_LinearMechanicalQuasiPort_1_Test method invalid.
@Test
public void invalid() {
Variable v1 = new Variable();
v1.setCausality(Variable.Causality.OUTPUT);
v1.setUnit(new Unit());
v1.setType(Variable.Type.REAL);
Variable v2 = new Variable();
v2.setCausality(Variable.Causality.OUTPUT);
v2.setUnit(new Unit());
v2.setType(Variable.Type.REAL);
Variable v3 = new Variable();
v3.setCausality(Variable.Causality.OUTPUT);
v3.setUnit(new Unit());
v3.setType(Variable.Type.REAL);
Variable v4 = new Variable();
v4.setCausality(Variable.Causality.OUTPUT);
v4.setUnit(new Unit());
v4.setType(Variable.Type.REAL);
Force force = new Force();
force.setVariables(Arrays.asList(v1, v2));
LinearDisplacement linearDisplacement = new LinearDisplacement();
linearDisplacement.setVariables(Arrays.asList(v3, v4));
LinearMechanicalQuasiPort linearMechanicalQuasiPort = new LinearMechanicalQuasiPort();
linearMechanicalQuasiPort.setForce(force);
linearMechanicalQuasiPort.setLinearDisplacement(linearDisplacement);
builder.build(linearMechanicalQuasiPort);
builder.complete();
List<ValidationDiagnostic<LinearMechanicalQuasiPort>> diagnostics = validationError.validate();
assertEquals(1, diagnostics.size());
LinearMechanicalQuasiPort invalidLinearMechanicalQuasiPort = diagnostics.get(0).getValidatedObject();
assertEquals(linearMechanicalQuasiPort, invalidLinearMechanicalQuasiPort);
}
use of com.opensimulationplatform.core.validation.ValidationDiagnostic in project osp-validator by open-simulation-platform.
the class VE_LinearVelocity_1_Test method valid.
@Test
public void valid() {
LinearVelocity linearVelocity = new LinearVelocity();
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());
linearVelocity.setVariables(Arrays.asList(v1, v2));
builder.build(linearVelocity);
builder.complete();
List<ValidationDiagnostic<LinearVelocity>> diagnostics = validationError.validate();
assertTrue(diagnostics.isEmpty());
}
use of com.opensimulationplatform.core.validation.ValidationDiagnostic in project osp-validator by open-simulation-platform.
the class VE_LinearVelocity_2_Test method invalid.
@Test
public void invalid() {
LinearVelocity linearVelocity = new LinearVelocity();
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());
linearVelocity.setVariables(Arrays.asList(v1, v2));
builder.build(linearVelocity);
builder.complete();
List<ValidationDiagnostic<LinearVelocity>> diagnostics = validationError.validate();
assertEquals(1, diagnostics.size());
LinearVelocity invalidObject = diagnostics.get(0).getValidatedObject();
List<Variable> variables = invalidObject.getVariables();
assertTrue(variables.contains(v1));
assertTrue(variables.contains(v2));
}
Aggregations