Search in sources :

Example 6 with Generic

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

the class NamesValidatorTest method validModelDescription.

@Test
public void validModelDescription() {
    ModelDescription modelDescription = new ModelDescription();
    Variable v1 = new Variable();
    v1.setName("v1");
    Variable v2 = new Variable();
    v2.setName("v2");
    modelDescription.getVariables().add(v1);
    modelDescription.getVariables().add(v2);
    Generic vg1 = new Generic();
    vg1.setName("v3");
    Generic vg2 = new Generic();
    vg2.setName("v4");
    modelDescription.getGenerics().add(vg1);
    modelDescription.getGenerics().add(vg2);
    NamesValidator namesValidator = new NamesValidator();
    List<ValidationDiagnostic<Name>> diagnostics = namesValidator.validate(modelDescription);
    assertEquals(0, diagnostics.size());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Generic(com.opensimulationplatform.core.model.modeldescription.variablegroup.generic.Generic) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) Test(org.junit.Test)

Example 7 with Generic

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

the class VE_VariableGroup_1_Test method valid.

@Test
public void valid() {
    Variable v1 = new Variable();
    v1.setName("v1");
    v1.setCausality(Variable.Causality.INPUT);
    v1.setType(Variable.Type.REAL);
    Variable v2 = new Variable();
    v2.setName("v2");
    v2.setCausality(Variable.Causality.INPUT);
    v2.setType(Variable.Type.REAL);
    Generic variableGroup = new Generic();
    variableGroup.setVariables(Arrays.asList(v1, v2));
    builder.build(variableGroup);
    builder.complete();
    List<ValidationDiagnostic<VariableGroup>> diagnostics = validationError.validate();
    assertTrue(diagnostics.isEmpty());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Generic(com.opensimulationplatform.core.model.modeldescription.variablegroup.generic.Generic) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Test(org.junit.Test)

Example 8 with Generic

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

the class VE_VariableGroup_2_Test method valid.

@Test
public void valid() {
    Generic vg1 = new Generic();
    vg1.setName("vg1");
    Generic vg2 = new Generic();
    vg2.setName("vg2");
    builder.build(vg1);
    builder.build(vg2);
    builder.complete();
    List<ValidationDiagnostic<VariableGroup>> diagnostics = validationError.validate();
    assertTrue(diagnostics.isEmpty());
}
Also used : Generic(com.opensimulationplatform.core.model.modeldescription.variablegroup.generic.Generic) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Test(org.junit.Test)

Example 9 with Generic

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

the class VE_VariableGroup_3_Test method invalid.

@Test
public void invalid() {
    Generic vg1 = new Generic();
    vg1.setName("vg1");
    Generic vg2 = new Generic();
    vg2.setName("vg2");
    Variable v1 = new Variable();
    v1.setName("not-unique");
    v1.setCausality(Variable.Causality.INPUT);
    v1.setType(Variable.Type.REAL);
    Variable v2 = new Variable();
    v2.setName("not-unique");
    v2.setCausality(Variable.Causality.INPUT);
    v2.setType(Variable.Type.REAL);
    vg2.setVariables(Arrays.asList(v1, v2));
    vg1.getGenerics().add(vg2);
    builder.build(vg1);
    builder.complete();
    List<ValidationDiagnostic<VariableGroup>> diagnostics = validationError.validate();
    assertEquals(1, diagnostics.size());
    List<VariableGroup> invalidVariableGroups = diagnostics.stream().map(ValidationDiagnostic::getValidatedObject).collect(Collectors.toList());
    assertTrue(invalidVariableGroups.contains(vg1));
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Generic(com.opensimulationplatform.core.model.modeldescription.variablegroup.generic.Generic) VariableGroup(com.opensimulationplatform.core.model.modeldescription.variablegroup.VariableGroup) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Test(org.junit.Test)

Example 10 with Generic

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

the class VE_VariableGroup_3_Test method valid.

@Test
public void valid() {
    Generic vg1 = new Generic();
    vg1.setName("vg1");
    Generic vg2 = new Generic();
    vg2.setName("vg2");
    Variable v1 = new Variable();
    v1.setName("v1");
    v1.setCausality(Variable.Causality.INPUT);
    v1.setType(Variable.Type.REAL);
    Variable v2 = new Variable();
    v2.setName("v2");
    v2.setCausality(Variable.Causality.INPUT);
    v2.setType(Variable.Type.REAL);
    vg2.setVariables(Arrays.asList(v1, v2));
    vg1.getGenerics().add(vg2);
    builder.build(vg1);
    builder.complete();
    List<ValidationDiagnostic<VariableGroup>> diagnostics = validationError.validate();
    assertTrue(diagnostics.isEmpty());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Generic(com.opensimulationplatform.core.model.modeldescription.variablegroup.generic.Generic) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Test(org.junit.Test)

Aggregations

Generic (com.opensimulationplatform.core.model.modeldescription.variablegroup.generic.Generic)18 Test (org.junit.Test)15 ValidationDiagnostic (com.opensimulationplatform.core.validation.ValidationDiagnostic)14 Variable (com.opensimulationplatform.core.model.modeldescription.Variable)13 ModelDescription (com.opensimulationplatform.core.model.modeldescription.ModelDescription)9 LinearMechanicalPort (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearmechanicalport.LinearMechanicalPort)6 Force (com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force)5 LinearVelocity (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearvelocity.LinearVelocity)5 VariableGroup (com.opensimulationplatform.core.model.modeldescription.variablegroup.VariableGroup)3 Simulator (com.opensimulationplatform.core.model.systemstructure.Simulator)3 SystemStructure (com.opensimulationplatform.core.model.systemstructure.SystemStructure)3 Unit (com.opensimulationplatform.core.model.modeldescription.Unit)2 AngularAcceleration (com.opensimulationplatform.core.model.modeldescription.variablegroup.angularacceleration.AngularAcceleration)2 AngularDisplacement (com.opensimulationplatform.core.model.modeldescription.variablegroup.angulardisplacement.AngularDisplacement)2 AngularMechanicalPort (com.opensimulationplatform.core.model.modeldescription.variablegroup.angularmechanicalport.AngularMechanicalPort)2 AngularMechanicalQuasiPort (com.opensimulationplatform.core.model.modeldescription.variablegroup.angularmechanicalquasiport.AngularMechanicalQuasiPort)2 AngularVelocity (com.opensimulationplatform.core.model.modeldescription.variablegroup.angularvelocity.AngularVelocity)2 AzimuthAngle (com.opensimulationplatform.core.model.modeldescription.variablegroup.azimuthangle.AzimuthAngle)2 AzimuthThrusterFeedback (com.opensimulationplatform.core.model.modeldescription.variablegroup.azimuththrusterfeedback.AzimuthThrusterFeedback)2 AzimuthThrusterSetpoint (com.opensimulationplatform.core.model.modeldescription.variablegroup.azimuththrustersetpoint.AzimuthThrusterSetpoint)2