use of com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force 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.model.modeldescription.variablegroup.force.Force 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.model.modeldescription.variablegroup.force.Force 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.model.modeldescription.variablegroup.force.Force 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());
}
use of com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force in project osp-validator by open-simulation-platform.
the class VE_VariableGroupConnection_1_Test method invalid.
@Test
public void invalid() {
Force va = new Force();
va.setName("va");
LinearVelocity vb = new LinearVelocity();
vb.setName("vb");
VariableGroupConnection vgc = new VariableGroupConnection();
vgc.setVariableGroupA(va);
vgc.setVariableGroupB(vb);
vgc.setSimulatorA(new Simulator());
vgc.setSimulatorB(new Simulator());
builder.build(vgc);
builder.complete();
List<ValidationDiagnostic<VariableGroupConnection>> diagnostics = validationError.validate();
assertEquals(1, diagnostics.size());
VariableGroupConnection invalidVariableConnection = diagnostics.get(0).getValidatedObject();
assertEquals(vgc, invalidVariableConnection);
assertEquals(va, invalidVariableConnection.getVariableGroupA());
assertEquals(vb, invalidVariableConnection.getVariableGroupB());
}
Aggregations