use of com.opensimulationplatform.core.model.modeldescription.ModelDescription 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());
}
use of com.opensimulationplatform.core.model.modeldescription.ModelDescription 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());
}
use of com.opensimulationplatform.core.model.modeldescription.ModelDescription 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());
}
use of com.opensimulationplatform.core.model.modeldescription.ModelDescription in project osp-validator by open-simulation-platform.
the class ElectromagneticQuasiPortValidatorTest 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);
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);
assertTrue(diagnostics.isEmpty());
}
use of com.opensimulationplatform.core.model.modeldescription.ModelDescription in project osp-validator by open-simulation-platform.
the class HydraulicPortValidatorTest method invalid.
@Test
public void invalid() {
ModelDescription modelDescription = new ModelDescription();
Variable v1 = new Variable();
v1.setCausality(Variable.Causality.OUTPUT);
Pressure pressure = new Pressure();
pressure.setVariables(Arrays.asList(v1));
Variable v2 = new Variable();
v2.setCausality(Variable.Causality.OUTPUT);
VolumeFlowRate volumeFlowRate = new VolumeFlowRate();
volumeFlowRate.setVariables(Arrays.asList(v2));
HydraulicPort hydraulicPort = new HydraulicPort();
hydraulicPort.setPressure(pressure);
hydraulicPort.setVolumeFlowRate(volumeFlowRate);
modelDescription.getHydraulicPorts().add(hydraulicPort);
HydraulicPortValidator hydraulicPortValidator = new HydraulicPortValidator();
List<ValidationDiagnostic<HydraulicPort>> diagnostics = hydraulicPortValidator.validate(modelDescription);
assertEquals(1, diagnostics.size());
assertEquals(hydraulicPort, diagnostics.get(0).getValidatedObject());
}
Aggregations