Search in sources :

Example 1 with ConverterContext

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());
}
Also used : ConverterContext(com.opensimulationplatform.modeldescription.xml.converter.ConverterContext) Variable(com.opensimulationplatform.core.model.modeldescription.Variable) VariableType(com.opensimulationplatform.modeldescription.xml.model.VariableType) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Example 2 with ConverterContext

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;
}
Also used : ConverterContext(com.opensimulationplatform.modeldescription.xml.converter.ConverterContext) Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) FmiModelDescription(com.opensimulationplatform.modeldescription.util.FmiModelDescription) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with 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());
}
Also used : ConverterContext(com.opensimulationplatform.modeldescription.xml.converter.ConverterContext) FmiModelDescription(com.opensimulationplatform.modeldescription.util.FmiModelDescription) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) Test(org.junit.Test)

Aggregations

ConverterContext (com.opensimulationplatform.modeldescription.xml.converter.ConverterContext)3 Unit (com.opensimulationplatform.core.model.modeldescription.Unit)2 Variable (com.opensimulationplatform.core.model.modeldescription.Variable)2 FmiModelDescription (com.opensimulationplatform.modeldescription.util.FmiModelDescription)2 Test (org.junit.Test)2 ModelDescription (com.opensimulationplatform.core.model.modeldescription.ModelDescription)1 VariableType (com.opensimulationplatform.modeldescription.xml.model.VariableType)1 NotNull (org.jetbrains.annotations.NotNull)1