Search in sources :

Example 1 with SystemStructureValidator

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

the class UseCase1Test method works.

@Test
public void works() {
    SystemStructureFactory factory = new SystemStructureFactory();
    SystemStructure systemStructure = factory.create(TestResources.OSP_SYSTEM_STRUCTURE_USE_CASE_1);
    SystemStructureValidator validator = new SystemStructureValidator();
    List<ValidationDiagnostic<Object>> diagnostics = validator.validate(systemStructure);
    for (ValidationDiagnostic<Object> diagnostic : diagnostics) {
        System.out.println(diagnostic.getValidatedObject());
        System.out.println(diagnostic.getErrorMessage());
    }
    assertTrue(diagnostics.isEmpty());
}
Also used : SystemStructureFactory(com.opensimulationplatform.systemstructure.xml.factory.SystemStructureFactory) SystemStructureValidator(com.opensimulationplatform.core.validation.systemstructure.SystemStructureValidator) SystemStructure(com.opensimulationplatform.core.model.systemstructure.SystemStructure) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Test(org.junit.Test)

Example 2 with SystemStructureValidator

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

the class UseCase3Test method works.

@Test
public void works() {
    SystemStructureFactory factory = new SystemStructureFactory();
    SystemStructure systemStructure = factory.create(TestResources.OSP_SYSTEM_STRUCTURE_USE_CASE_3);
    SystemStructureValidator validator = new SystemStructureValidator();
    List<ValidationDiagnostic<Object>> diagnostics = validator.validate(systemStructure);
    for (ValidationDiagnostic<Object> diagnostic : diagnostics) {
        System.out.println(diagnostic.getValidatedObject());
        System.out.println(diagnostic.getErrorMessage());
    }
    assertTrue(diagnostics.isEmpty());
}
Also used : SystemStructureFactory(com.opensimulationplatform.systemstructure.xml.factory.SystemStructureFactory) SystemStructureValidator(com.opensimulationplatform.core.validation.systemstructure.SystemStructureValidator) SystemStructure(com.opensimulationplatform.core.model.systemstructure.SystemStructure) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Test(org.junit.Test)

Example 3 with SystemStructureValidator

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

the class UseCase4Test method works.

@Test
public void works() {
    SystemStructureFactory factory = new SystemStructureFactory();
    SystemStructure systemStructure = factory.create(TestResources.OSP_SYSTEM_STRUCTURE_USE_CASE_4);
    SystemStructureValidator validator = new SystemStructureValidator();
    List<ValidationDiagnostic<Object>> diagnostics = validator.validate(systemStructure);
    for (ValidationDiagnostic<Object> diagnostic : diagnostics) {
        System.out.println(diagnostic.getValidatedObject());
        System.out.println(diagnostic.getErrorMessage());
    }
    assertTrue(diagnostics.isEmpty());
}
Also used : SystemStructureFactory(com.opensimulationplatform.systemstructure.xml.factory.SystemStructureFactory) SystemStructureValidator(com.opensimulationplatform.core.validation.systemstructure.SystemStructureValidator) SystemStructure(com.opensimulationplatform.core.model.systemstructure.SystemStructure) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Test(org.junit.Test)

Example 4 with SystemStructureValidator

use of com.opensimulationplatform.core.validation.systemstructure.SystemStructureValidator 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 5 with SystemStructureValidator

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

the class ValidateOspSystemStructureFile method main.

public static void main(String[] args) {
    File ospSystemStructureFile = new File("/path/to/OspSystemStructure.xml");
    SystemStructureFactory factory = new SystemStructureFactory();
    SystemStructure modelDescription = factory.create(ospSystemStructureFile);
    SystemStructureValidator validator = new SystemStructureValidator();
    List<ValidationDiagnostic<Object>> diagnostics = validator.validate(modelDescription);
    for (ValidationDiagnostic<Object> diagnostic : diagnostics) {
        System.out.println("Message: " + diagnostic.getErrorMessage());
        System.out.println("Object: " + diagnostic.getValidatedObject());
    }
}
Also used : SystemStructureFactory(com.opensimulationplatform.systemstructure.xml.factory.SystemStructureFactory) SystemStructureValidator(com.opensimulationplatform.core.validation.systemstructure.SystemStructureValidator) SystemStructure(com.opensimulationplatform.core.model.systemstructure.SystemStructure) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) File(java.io.File)

Aggregations

SystemStructure (com.opensimulationplatform.core.model.systemstructure.SystemStructure)7 ValidationDiagnostic (com.opensimulationplatform.core.validation.ValidationDiagnostic)7 SystemStructureValidator (com.opensimulationplatform.core.validation.systemstructure.SystemStructureValidator)7 SystemStructureFactory (com.opensimulationplatform.systemstructure.xml.factory.SystemStructureFactory)6 Test (org.junit.Test)4 Simulator (com.opensimulationplatform.core.model.systemstructure.Simulator)1 VariableConnection (com.opensimulationplatform.core.model.systemstructure.VariableConnection)1 VariableGroupConnection (com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection)1 OspSystemStructure (com.opensimulationplatform.systemstructure.xml.model.OspSystemStructure)1 File (java.io.File)1