Search in sources :

Example 6 with ValidationDiagnostic

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

the class Validator method getSystemStructureErrorMessages.

private List<String> getSystemStructureErrorMessages(File ospSystemStructureFile, OspSystemStructure ospSystemStructureElement, Map<Object, Location> locations) {
    SystemStructureFactory factory = new SystemStructureFactory();
    SystemStructure systemStructure = factory.create(ospSystemStructureFile);
    SystemStructureValidator validator = new SystemStructureValidator();
    List<ValidationDiagnostic<Object>> diagnostics = validator.validate(systemStructure);
    Map<Object, Object> coreToJaxb = createSystemStructureMap(systemStructure, ospSystemStructureElement);
    return getErrorMessages(ospSystemStructureFile, locations, diagnostics, coreToJaxb);
}
Also used : SystemStructureFactory(com.opensimulationplatform.systemstructure.xml.factory.SystemStructureFactory) SystemStructureValidator(com.opensimulationplatform.core.validation.systemstructure.SystemStructureValidator) OspSystemStructure(com.opensimulationplatform.systemstructure.xml.model.OspSystemStructure) SystemStructure(com.opensimulationplatform.core.model.systemstructure.SystemStructure) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic)

Example 7 with ValidationDiagnostic

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

the class VE_Name_1_Test method valid.

@Test
public void valid() {
    Variable v1 = new Variable();
    v1.setName("v1-unique-name");
    Variable v2 = new Variable();
    v2.setName("v2-unique-name");
    builder.build(v1);
    builder.build(v2);
    builder.complete();
    List<ValidationDiagnostic<Name>> diagnostics = validationError.validate();
    assertTrue(diagnostics.isEmpty());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Test(org.junit.Test)

Example 8 with ValidationDiagnostic

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

the class VE_Name_1_Test method invalid.

@Test
public void invalid() {
    Variable v1 = new Variable();
    v1.setName("not-a-unique-name");
    Variable v2 = new Variable();
    v2.setName("not-a-unique-name");
    builder.build(v1);
    builder.build(v2);
    builder.complete();
    List<ValidationDiagnostic<Name>> diagnostics = validationError.validate();
    assertEquals(1, diagnostics.size());
    Name invalidName = diagnostics.get(0).getValidatedObject();
    assertEquals(invalidName.get(), v1.getName().get());
    assertEquals(invalidName.get(), v2.getName().get());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Name(com.opensimulationplatform.core.model.modeldescription.Name) Test(org.junit.Test)

Example 9 with ValidationDiagnostic

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

the class VE_Name_2_Test method valid.

@Test
public void valid() {
    Simulator s1 = new Simulator();
    s1.setName("s1-unique-name");
    Simulator s2 = new Simulator();
    s2.setName("s2-unique-name");
    builder.build(s1);
    builder.build(s2);
    builder.complete();
    List<ValidationDiagnostic<Name>> diagnostics = validationError.validate();
    assertTrue(diagnostics.isEmpty());
}
Also used : ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) Test(org.junit.Test)

Example 10 with ValidationDiagnostic

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

the class VE_Name_2_Test method invalid.

@Test
public void invalid() {
    Simulator s1 = new Simulator();
    s1.setName("not-a-unique-name");
    Simulator s2 = new Simulator();
    s2.setName("not-a-unique-name");
    builder.build(s1);
    builder.build(s2);
    builder.complete();
    List<ValidationDiagnostic<Name>> diagnostics = validationError.validate();
    assertEquals(1, diagnostics.size());
    Name invalidName = diagnostics.get(0).getValidatedObject();
    assertEquals(invalidName.get(), s1.getName().get());
    assertEquals(invalidName.get(), s2.getName().get());
}
Also used : ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) Name(com.opensimulationplatform.core.model.modeldescription.Name) 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