use of com.opensimulationplatform.core.validation.systemstructure.SystemStructureValidator in project osp-validator by open-simulation-platform.
the class ValidateSystemStructureDataModel method main.
public static void main(String[] args) {
SystemStructure systemStructure = new SystemStructure();
Simulator s1 = new Simulator();
s1.setName("s1");
s1.setModelDescription(getModelDescription(Variable.Causality.INPUT, Variable.Causality.OUTPUT));
Simulator s2 = new Simulator();
s2.setName("s2");
s2.setModelDescription(getModelDescription(Variable.Causality.OUTPUT, Variable.Causality.INPUT));
VariableConnection vc = new VariableConnection();
vc.setSimulatorA(s1);
vc.setVariableA(ModelDescriptionUtil.getVariableByName(s1.getModelDescription(), "v5"));
vc.setSimulatorB(s2);
vc.setVariableB(ModelDescriptionUtil.getVariableByName(s2.getModelDescription(), "v5"));
VariableGroupConnection vgc = new VariableGroupConnection();
vgc.setSimulatorA(s1);
vgc.setVariableGroupA(ModelDescriptionUtil.getVariableGroupByName(s1.getModelDescription(), "linearMechanicalPort"));
vgc.setSimulatorB(s2);
vgc.setVariableGroupB(ModelDescriptionUtil.getVariableGroupByName(s2.getModelDescription(), "linearMechanicalPort"));
systemStructure.getSimulators().add(s1);
systemStructure.getSimulators().add(s2);
systemStructure.getVariableConnections().add(vc);
systemStructure.getVariableGroupConnections().add(vgc);
SystemStructureValidator validator = new SystemStructureValidator();
List<ValidationDiagnostic<Object>> diagnostics = validator.validate(systemStructure);
for (ValidationDiagnostic<Object> diagnostic : diagnostics) {
System.out.println("Message: " + diagnostic.getErrorMessage());
System.out.println("Object: " + diagnostic.getValidatedObject());
}
}
use of com.opensimulationplatform.core.validation.systemstructure.SystemStructureValidator in project osp-validator by open-simulation-platform.
the class UseCase2Test method works.
@Test
public void works() {
SystemStructureFactory factory = new SystemStructureFactory();
SystemStructure systemStructure = factory.create(TestResources.OSP_SYSTEM_STRUCTURE_USE_CASE_2);
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());
}
Aggregations