use of com.opensimulationplatform.modeldescription.xml.converter.ConverterContext in project osp-validator by open-simulation-platform.
the class VariableTypeConverterTest method canConvert.
@Test
public void canConvert() {
ConverterContext converterContext = new ConverterContext();
Variable v = new Variable();
v.setName("variableName");
converterContext.modelDescription.getVariables().add(v);
Unit u = new Unit();
u.setName("unitName");
converterContext.modelDescription.getUnits().add(u);
VariableType variableType = new VariableType();
variableType.setRef(v.getName().get());
variableType.setUnit(u.getName().get());
VariableTypeConverter variableTypeConverter = new VariableTypeConverter(converterContext);
Variable variable = variableTypeConverter.convert(variableType);
assertEquals(v, variable);
assertEquals(u, variable.getUnit());
}
use of com.opensimulationplatform.modeldescription.xml.converter.ConverterContext in project osp-validator by open-simulation-platform.
the class OspModelDescriptionTypeConverterTest method getConverterContext.
@NotNull
private ConverterContext getConverterContext() {
ConverterContext converterContext = new ConverterContext();
converterContext.fmiModelDescription = new FmiModelDescription();
Variable fmiVariable = new Variable();
fmiVariable.setName("fmiVariable");
converterContext.fmiModelDescription.getVariables().add(fmiVariable);
Unit fmiUnit = new Unit();
fmiUnit.setName("fmiUnit");
converterContext.fmiModelDescription.getUnits().add(fmiUnit);
return converterContext;
}
use of com.opensimulationplatform.modeldescription.xml.converter.ConverterContext in project osp-validator by open-simulation-platform.
the class OspModelDescriptionTypeConverterTest method canConvert.
@Test
public void canConvert() {
ConverterContext converterContext = getConverterContext();
OspModelDescriptionType ospModelDescriptionType = getOspModelDescriptionType();
OspModelDescriptionTypeConverter ospModelDescriptionTypeConverter = new OspModelDescriptionTypeConverter(converterContext);
ModelDescription modelDescription = ospModelDescriptionTypeConverter.convert(ospModelDescriptionType);
assertEquals(1, modelDescription.getVariables().size());
assertEquals(2, modelDescription.getUnits().size());
assertEquals(1, modelDescription.getGenerics().size());
assertEquals(3, modelDescription.getForces().size());
assertEquals(3, modelDescription.getTorques().size());
assertEquals(3, modelDescription.getVoltages().size());
assertEquals(3, modelDescription.getPressures().size());
assertEquals(2, modelDescription.getLinearVelocities().size());
assertEquals(2, modelDescription.getAngularVelocities().size());
assertEquals(2, modelDescription.getCurrents().size());
assertEquals(2, modelDescription.getVolumeFlowRates().size());
assertEquals(2, modelDescription.getLinearDisplacements().size());
assertEquals(2, modelDescription.getAngularDisplacements().size());
assertEquals(2, modelDescription.getCharges().size());
assertEquals(2, modelDescription.getVolumes().size());
assertEquals(1, modelDescription.getLinearMechanicalPorts().size());
assertEquals(1, modelDescription.getAngularMechanicalPorts().size());
assertEquals(1, modelDescription.getElectromagneticPorts().size());
assertEquals(1, modelDescription.getHydraulicPorts().size());
assertEquals(1, modelDescription.getLinearMechanicalQuasiPorts().size());
assertEquals(1, modelDescription.getAngularMechanicalQuasiPorts().size());
assertEquals(1, modelDescription.getElectromagneticQuasiPorts().size());
assertEquals(1, modelDescription.getHydraulicQuasiPorts().size());
}
Aggregations