Search in sources :

Example 81 with Unit

use of com.opensimulationplatform.core.model.modeldescription.Unit in project osp-validator by open-simulation-platform.

the class AngularAccelerationValidatorTest method valid.

@Test
public void valid() {
    ModelDescription modelDescription = new ModelDescription();
    AngularAcceleration angularAcceleration = new AngularAcceleration();
    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());
    angularAcceleration.setVariables(Arrays.asList(v1, v2));
    modelDescription.getAngularAccelerations().add(angularAcceleration);
    AngularAccelerationValidator v = new AngularAccelerationValidator();
    List<ValidationDiagnostic<AngularAcceleration>> diagnostics = v.validate(modelDescription);
    assertTrue(diagnostics.isEmpty());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) AngularAcceleration(com.opensimulationplatform.core.model.modeldescription.variablegroup.angularacceleration.AngularAcceleration) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Example 82 with Unit

use of com.opensimulationplatform.core.model.modeldescription.Unit in project osp-validator by open-simulation-platform.

the class AngularAccelerationValidatorTest 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);
    AngularAcceleration angularAcceleration = new AngularAcceleration();
    angularAcceleration.setVariables(Arrays.asList(v1, v2));
    modelDescription.getAngularAccelerations().add(angularAcceleration);
    AngularAccelerationValidator v = new AngularAccelerationValidator();
    List<ValidationDiagnostic<AngularAcceleration>> diagnostics = v.validate(modelDescription);
    assertEquals(3, diagnostics.size());
    for (ValidationDiagnostic<AngularAcceleration> diagnostic : diagnostics) {
        assertEquals(angularAcceleration, diagnostic.getValidatedObject());
    }
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) AngularAcceleration(com.opensimulationplatform.core.model.modeldescription.variablegroup.angularacceleration.AngularAcceleration) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Example 83 with Unit

use of com.opensimulationplatform.core.model.modeldescription.Unit in project osp-validator by open-simulation-platform.

the class VE_AngularAcceleration_1_Test method invalid.

@Test
public void invalid() {
    AngularAcceleration angularAcceleration = new AngularAcceleration();
    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());
    angularAcceleration.setVariables(Arrays.asList(v1, v2));
    builder.build(angularAcceleration);
    builder.complete();
    List<ValidationDiagnostic<AngularAcceleration>> diagnostics = validationError.validate();
    assertEquals(1, diagnostics.size());
    AngularAcceleration invalidObject = diagnostics.get(0).getValidatedObject();
    List<Variable> variables = invalidObject.getVariables();
    assertTrue(variables.contains(v1));
    assertTrue(variables.contains(v2));
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) AngularAcceleration(com.opensimulationplatform.core.model.modeldescription.variablegroup.angularacceleration.AngularAcceleration) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Example 84 with Unit

use of com.opensimulationplatform.core.model.modeldescription.Unit in project osp-validator by open-simulation-platform.

the class VE_AngularAcceleration_1_Test method valid.

@Test
public void valid() {
    AngularAcceleration angularAcceleration = new AngularAcceleration();
    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());
    angularAcceleration.setVariables(Arrays.asList(v1, v2));
    builder.build(angularAcceleration);
    builder.complete();
    List<ValidationDiagnostic<AngularAcceleration>> diagnostics = validationError.validate();
    assertTrue(diagnostics.isEmpty());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) AngularAcceleration(com.opensimulationplatform.core.model.modeldescription.variablegroup.angularacceleration.AngularAcceleration) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Example 85 with Unit

use of com.opensimulationplatform.core.model.modeldescription.Unit in project osp-validator by open-simulation-platform.

the class VE_AngularAcceleration_2_Test method valid.

@Test
public void valid() {
    AngularAcceleration angularAcceleration = new AngularAcceleration();
    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());
    angularAcceleration.setVariables(Arrays.asList(v1, v2));
    builder.build(angularAcceleration);
    builder.complete();
    List<ValidationDiagnostic<AngularAcceleration>> diagnostics = validationError.validate();
    assertTrue(diagnostics.isEmpty());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) AngularAcceleration(com.opensimulationplatform.core.model.modeldescription.variablegroup.angularacceleration.AngularAcceleration) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Aggregations

Unit (com.opensimulationplatform.core.model.modeldescription.Unit)149 Variable (com.opensimulationplatform.core.model.modeldescription.Variable)145 ValidationDiagnostic (com.opensimulationplatform.core.validation.ValidationDiagnostic)137 Test (org.junit.Test)137 ModelDescription (com.opensimulationplatform.core.model.modeldescription.ModelDescription)35 Force (com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force)21 LinearVelocity (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearvelocity.LinearVelocity)16 Pressure (com.opensimulationplatform.core.model.modeldescription.variablegroup.pressure.Pressure)13 Torque (com.opensimulationplatform.core.model.modeldescription.variablegroup.torque.Torque)13 Voltage (com.opensimulationplatform.core.model.modeldescription.variablegroup.voltage.Voltage)13 AngularDisplacement (com.opensimulationplatform.core.model.modeldescription.variablegroup.angulardisplacement.AngularDisplacement)11 AngularVelocity (com.opensimulationplatform.core.model.modeldescription.variablegroup.angularvelocity.AngularVelocity)11 Charge (com.opensimulationplatform.core.model.modeldescription.variablegroup.charge.Charge)11 Current (com.opensimulationplatform.core.model.modeldescription.variablegroup.current.Current)11 LinearDisplacement (com.opensimulationplatform.core.model.modeldescription.variablegroup.lineardisplacement.LinearDisplacement)11 Volume (com.opensimulationplatform.core.model.modeldescription.variablegroup.volume.Volume)11 VolumeFlowRate (com.opensimulationplatform.core.model.modeldescription.variablegroup.volumeflowrate.VolumeFlowRate)11 AngularAcceleration (com.opensimulationplatform.core.model.modeldescription.variablegroup.angularacceleration.AngularAcceleration)9 LinearAcceleration (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearacceleration.LinearAcceleration)9 LinearMechanicalPort (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearmechanicalport.LinearMechanicalPort)7