Search in sources :

Example 36 with ValidationDiagnostic

use of com.opensimulationplatform.core.validation.ValidationDiagnostic in project osp-validator by open-simulation-platform.

the class VariableGroupsValidatorTest method invalid.

@Test
public void invalid() {
    ModelDescription modelDescription = new ModelDescription();
    Force f1 = new Force();
    Variable v1 = new Variable();
    Unit u1 = new Unit();
    u1.setExponent(Unit.Exponent.KILOGRAM, 1);
    v1.setUnit(u1);
    v1.setName("v1");
    v1.setType(Variable.Type.REAL);
    v1.setCausality(Variable.Causality.OUTPUT);
    Variable v2 = new Variable();
    Unit u2 = new Unit();
    u2.setExponent(Unit.Exponent.KILOGRAM, 2);
    v2.setUnit(u2);
    v2.setName("v2");
    v2.setType(Variable.Type.REAL);
    v2.setCausality(Variable.Causality.OUTPUT);
    f1.setVariables(Arrays.asList(v1, v2));
    f1.setName("f1");
    Force f2 = new Force();
    Variable v3 = new Variable();
    v3.setUnit(u1);
    v3.setName("v3");
    v3.setType(Variable.Type.REAL);
    v3.setCausality(Variable.Causality.OUTPUT);
    Variable v4 = new Variable();
    v4.setUnit(u1);
    v4.setName("v4");
    v4.setType(Variable.Type.INTEGER);
    v4.setCausality(Variable.Causality.OUTPUT);
    f2.setVariables(Arrays.asList(v3, v4));
    f2.setName("f2");
    Force f3 = new Force();
    Variable v5 = new Variable();
    v5.setUnit(u1);
    v5.setName("v5");
    v5.setType(Variable.Type.REAL);
    v5.setCausality(Variable.Causality.OUTPUT);
    Variable v6 = new Variable();
    v6.setUnit(u1);
    v6.setName("v6");
    v6.setType(Variable.Type.REAL);
    v6.setCausality(Variable.Causality.INPUT);
    f3.setVariables(Arrays.asList(v5, v6));
    f3.setName("f3");
    modelDescription.getVariables().add(v1);
    modelDescription.getVariables().add(v2);
    modelDescription.getVariables().add(v3);
    modelDescription.getVariables().add(v4);
    modelDescription.getVariables().add(v5);
    modelDescription.getVariables().add(v6);
    modelDescription.getUnits().add(u1);
    modelDescription.getUnits().add(u2);
    modelDescription.getForces().add(f1);
    modelDescription.getForces().add(f2);
    modelDescription.getForces().add(f3);
    VariableGroupsValidator v = new VariableGroupsValidator();
    List<ValidationDiagnostic<VariableGroup>> diagnostics = v.validate(modelDescription);
    assertEquals(3, diagnostics.size());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Force(com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force) 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 37 with ValidationDiagnostic

use of com.opensimulationplatform.core.validation.ValidationDiagnostic in project osp-validator by open-simulation-platform.

the class ElectromagneticPortValidatorTest method valid.

@Test
public void valid() {
    ModelDescription modelDescription = new ModelDescription();
    Variable v1 = new Variable();
    v1.setCausality(Variable.Causality.OUTPUT);
    Voltage voltage = new Voltage();
    voltage.setVariables(Arrays.asList(v1));
    Variable v2 = new Variable();
    v2.setCausality(Variable.Causality.INPUT);
    Current current = new Current();
    current.setVariables(Arrays.asList(v2));
    ElectromagneticPort electromagneticPort = new ElectromagneticPort();
    electromagneticPort.setVoltage(voltage);
    electromagneticPort.setCurrent(current);
    modelDescription.getElectromagneticPorts().add(electromagneticPort);
    ElectromagneticPortValidator electromagneticPortValidator = new ElectromagneticPortValidator();
    List<ValidationDiagnostic<ElectromagneticPort>> diagnostics = electromagneticPortValidator.validate(modelDescription);
    assertTrue(diagnostics.isEmpty());
}
Also used : ElectromagneticPort(com.opensimulationplatform.core.model.modeldescription.variablegroup.electromagneticport.ElectromagneticPort) Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Voltage(com.opensimulationplatform.core.model.modeldescription.variablegroup.voltage.Voltage) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) Current(com.opensimulationplatform.core.model.modeldescription.variablegroup.current.Current) Test(org.junit.Test)

Example 38 with ValidationDiagnostic

use of com.opensimulationplatform.core.validation.ValidationDiagnostic in project osp-validator by open-simulation-platform.

the class ElectromagneticPortValidatorTest method invalid.

@Test
public void invalid() {
    ModelDescription modelDescription = new ModelDescription();
    Variable v1 = new Variable();
    v1.setCausality(Variable.Causality.OUTPUT);
    Voltage voltage = new Voltage();
    voltage.setVariables(Arrays.asList(v1));
    Variable v2 = new Variable();
    v2.setCausality(Variable.Causality.OUTPUT);
    Current current = new Current();
    current.setVariables(Arrays.asList(v2));
    ElectromagneticPort electromagneticPort = new ElectromagneticPort();
    electromagneticPort.setVoltage(voltage);
    electromagneticPort.setCurrent(current);
    modelDescription.getElectromagneticPorts().add(electromagneticPort);
    ElectromagneticPortValidator electromagneticPortValidator = new ElectromagneticPortValidator();
    List<ValidationDiagnostic<ElectromagneticPort>> diagnostics = electromagneticPortValidator.validate(modelDescription);
    assertEquals(1, diagnostics.size());
    assertEquals(electromagneticPort, diagnostics.get(0).getValidatedObject());
}
Also used : ElectromagneticPort(com.opensimulationplatform.core.model.modeldescription.variablegroup.electromagneticport.ElectromagneticPort) Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Voltage(com.opensimulationplatform.core.model.modeldescription.variablegroup.voltage.Voltage) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) Current(com.opensimulationplatform.core.model.modeldescription.variablegroup.current.Current) Test(org.junit.Test)

Example 39 with ValidationDiagnostic

use of com.opensimulationplatform.core.validation.ValidationDiagnostic in project osp-validator by open-simulation-platform.

the class VE_ElectromagneticPort_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);
    Voltage voltage = new Voltage();
    voltage.setVariables(Arrays.asList(v1, v2));
    Current current = new Current();
    current.setVariables(Arrays.asList(v3, v4));
    ElectromagneticPort electromagneticPort = new ElectromagneticPort();
    electromagneticPort.setVoltage(voltage);
    electromagneticPort.setCurrent(current);
    builder.build(electromagneticPort);
    builder.complete();
    List<ValidationDiagnostic<ElectromagneticPort>> diagnostics = validationError.validate();
    assertEquals(1, diagnostics.size());
    ElectromagneticPort invalidElectromagneticPort = diagnostics.get(0).getValidatedObject();
    assertEquals(electromagneticPort, invalidElectromagneticPort);
}
Also used : ElectromagneticPort(com.opensimulationplatform.core.model.modeldescription.variablegroup.electromagneticport.ElectromagneticPort) Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Voltage(com.opensimulationplatform.core.model.modeldescription.variablegroup.voltage.Voltage) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Current(com.opensimulationplatform.core.model.modeldescription.variablegroup.current.Current) Test(org.junit.Test)

Example 40 with ValidationDiagnostic

use of com.opensimulationplatform.core.validation.ValidationDiagnostic in project osp-validator by open-simulation-platform.

the class ElectromagneticQuasiPortValidatorTest method invalid.

@Test
public void invalid() {
    ModelDescription modelDescription = new ModelDescription();
    Variable v1 = new Variable();
    v1.setCausality(Variable.Causality.OUTPUT);
    Voltage voltage = new Voltage();
    voltage.setVariables(Arrays.asList(v1));
    Variable v2 = new Variable();
    v2.setCausality(Variable.Causality.OUTPUT);
    Charge charge = new Charge();
    charge.setVariables(Arrays.asList(v2));
    ElectromagneticQuasiPort electromagneticQuasiPort = new ElectromagneticQuasiPort();
    electromagneticQuasiPort.setVoltage(voltage);
    electromagneticQuasiPort.setCharge(charge);
    modelDescription.getElectromagneticQuasiPorts().add(electromagneticQuasiPort);
    ElectromagneticQuasiPortValidator electromagneticQuasiPortValidator = new ElectromagneticQuasiPortValidator();
    List<ValidationDiagnostic<ElectromagneticQuasiPort>> diagnostics = electromagneticQuasiPortValidator.validate(modelDescription);
    assertEquals(1, diagnostics.size());
    assertEquals(electromagneticQuasiPort, diagnostics.get(0).getValidatedObject());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) ElectromagneticQuasiPort(com.opensimulationplatform.core.model.modeldescription.variablegroup.electromagneticquasiport.ElectromagneticQuasiPort) Voltage(com.opensimulationplatform.core.model.modeldescription.variablegroup.voltage.Voltage) Charge(com.opensimulationplatform.core.model.modeldescription.variablegroup.charge.Charge) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) Test(org.junit.Test)

Aggregations

ValidationDiagnostic (com.opensimulationplatform.core.validation.ValidationDiagnostic)206 Test (org.junit.Test)200 Variable (com.opensimulationplatform.core.model.modeldescription.Variable)183 Unit (com.opensimulationplatform.core.model.modeldescription.Unit)137 ModelDescription (com.opensimulationplatform.core.model.modeldescription.ModelDescription)60 Force (com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force)31 Simulator (com.opensimulationplatform.core.model.systemstructure.Simulator)30 LinearVelocity (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearvelocity.LinearVelocity)23 SystemStructure (com.opensimulationplatform.core.model.systemstructure.SystemStructure)19 Pressure (com.opensimulationplatform.core.model.modeldescription.variablegroup.pressure.Pressure)16 Torque (com.opensimulationplatform.core.model.modeldescription.variablegroup.torque.Torque)16 Voltage (com.opensimulationplatform.core.model.modeldescription.variablegroup.voltage.Voltage)16 Generic (com.opensimulationplatform.core.model.modeldescription.variablegroup.generic.Generic)14 VariableConnection (com.opensimulationplatform.core.model.systemstructure.VariableConnection)13 AngularDisplacement (com.opensimulationplatform.core.model.modeldescription.variablegroup.angulardisplacement.AngularDisplacement)12 AngularVelocity (com.opensimulationplatform.core.model.modeldescription.variablegroup.angularvelocity.AngularVelocity)12 Charge (com.opensimulationplatform.core.model.modeldescription.variablegroup.charge.Charge)12 Current (com.opensimulationplatform.core.model.modeldescription.variablegroup.current.Current)12 LinearDisplacement (com.opensimulationplatform.core.model.modeldescription.variablegroup.lineardisplacement.LinearDisplacement)12 Volume (com.opensimulationplatform.core.model.modeldescription.variablegroup.volume.Volume)12