use of com.opensimulationplatform.core.model.systemstructure.Simulator in project osp-validator by open-simulation-platform.
the class NamesValidatorTest method invaliSystemStructure.
@Test
public void invaliSystemStructure() {
SystemStructure systemStructure = new SystemStructure();
Simulator s1 = new Simulator();
s1.setName("not-unique");
Simulator s2 = new Simulator();
s2.setName("not-unique");
ModelDescription modelDescription = new ModelDescription();
Variable v1 = new Variable();
v1.setName("not-unique");
Variable v2 = new Variable();
v2.setName("not-unique");
modelDescription.getVariables().add(v1);
modelDescription.getVariables().add(v2);
Generic vg1 = new Generic();
vg1.setName("not-unique");
vg1.setVariables(Arrays.asList(v1));
Generic vg2 = new Generic();
vg2.setName("not-unique");
vg2.setVariables(Arrays.asList(v2));
modelDescription.getGenerics().add(vg1);
modelDescription.getGenerics().add(vg2);
s1.setModelDescription(modelDescription);
systemStructure.getSimulators().add(s1);
systemStructure.getSimulators().add(s2);
NamesValidator namesValidator = new NamesValidator();
List<ValidationDiagnostic<Name>> diagnostics = namesValidator.validate(systemStructure);
assertEquals(3, diagnostics.size());
}
use of com.opensimulationplatform.core.model.systemstructure.Simulator in project osp-validator by open-simulation-platform.
the class SystemStructureValidatorTest method invalid.
@Test
public void invalid() {
Simulator s1 = new Simulator();
s1.setName("s1");
s1.setModelDescription(createInvalidModelDescription());
Simulator s2 = new Simulator();
s2.setName("s2");
s2.setModelDescription(createInvalidModelDescription());
SystemStructure systemStructure = new SystemStructure();
systemStructure.getSimulators().add(s1);
systemStructure.getSimulators().add(s2);
VariableConnection vc1 = new VariableConnection();
vc1.setSimulatorA(s1);
vc1.setSimulatorB(s2);
vc1.setVariableA(ModelDescriptionUtil.getVariableByName(s1.getModelDescription(), "v3"));
vc1.setVariableB(ModelDescriptionUtil.getVariableByName(s1.getModelDescription(), "v4"));
VariableConnection vc2 = new VariableConnection();
vc2.setSimulatorA(s1);
vc2.setSimulatorB(s2);
vc2.setVariableA(ModelDescriptionUtil.getVariableByName(s1.getModelDescription(), "v3"));
vc2.setVariableB(ModelDescriptionUtil.getVariableByName(s1.getModelDescription(), "v5"));
VariableConnection vc3 = new VariableConnection();
vc3.setSimulatorA(s1);
vc3.setSimulatorB(s2);
vc3.setVariableA(ModelDescriptionUtil.getVariableByName(s1.getModelDescription(), "v3"));
vc3.setVariableB(ModelDescriptionUtil.getVariableByName(s2.getModelDescription(), "v6"));
systemStructure.getVariableConnections().add(vc1);
systemStructure.getVariableConnections().add(vc2);
systemStructure.getVariableConnections().add(vc3);
VariableGroupConnection vgc1 = new VariableGroupConnection();
vgc1.setSimulatorA(s1);
vgc1.setSimulatorB(s2);
vgc1.setVariableGroupA(ModelDescriptionUtil.getVariableGroupByName(s1.getModelDescription(), "f3"));
vgc1.setVariableGroupB(ModelDescriptionUtil.getVariableGroupByName(s2.getModelDescription(), "lv1"));
systemStructure.getVariableGroupConnections().add(vgc1);
SystemStructureValidator v = new SystemStructureValidator();
List<ValidationDiagnostic<Object>> diagnostics = v.validate(systemStructure);
assertEquals(32, diagnostics.size());
}
use of com.opensimulationplatform.core.model.systemstructure.Simulator in project osp-validator by open-simulation-platform.
the class VE_VariableConnection_1_Test method valid.
@Test
public void valid() {
Variable va = new Variable();
va.setName("va");
va.setType(Variable.Type.REAL);
va.setCausality(Variable.Causality.INPUT);
Variable vb = new Variable();
vb.setName("vb");
vb.setType(Variable.Type.REAL);
vb.setCausality(Variable.Causality.INPUT);
VariableConnection vc = new VariableConnection();
vc.setVariableA(va);
vc.setVariableB(vb);
vc.setSimulatorA(new Simulator());
vc.setSimulatorB(new Simulator());
builder.build(vc);
builder.complete();
List<ValidationDiagnostic<VariableConnection>> diagnostics = validationError.validate();
assertTrue(diagnostics.isEmpty());
}
use of com.opensimulationplatform.core.model.systemstructure.Simulator in project osp-validator by open-simulation-platform.
the class VE_VariableConnection_2_Test method invalid.
@Test
public void invalid() {
Variable va = new Variable();
va.setName("va");
va.setType(Variable.Type.REAL);
va.setCausality(Variable.Causality.INPUT);
Variable vb = new Variable();
vb.setName("vb");
vb.setType(Variable.Type.INTEGER);
vb.setCausality(Variable.Causality.INPUT);
VariableConnection vc = new VariableConnection();
vc.setVariableA(va);
vc.setVariableB(vb);
vc.setSimulatorA(new Simulator());
vc.setSimulatorB(new Simulator());
builder.build(vc);
builder.complete();
List<ValidationDiagnostic<VariableConnection>> diagnostics = validationError.validate();
assertEquals(1, diagnostics.size());
VariableConnection invalidVariableConnection = diagnostics.get(0).getValidatedObject();
assertEquals(vc, invalidVariableConnection);
assertEquals(va, invalidVariableConnection.getVariableA());
assertEquals(vb, invalidVariableConnection.getVariableB());
}
use of com.opensimulationplatform.core.model.systemstructure.Simulator in project osp-validator by open-simulation-platform.
the class VE_VariableConnection_3_Test method invalid.
@Test
public void invalid() {
Unit ua = new Unit();
ua.setExponent(Unit.Exponent.KILOGRAM, 1);
Unit ub = new Unit();
ub.setExponent(Unit.Exponent.KILOGRAM, 2);
Variable va = new Variable();
va.setName("va");
va.setType(Variable.Type.REAL);
va.setCausality(Variable.Causality.INPUT);
va.setUnit(ua);
Variable vb = new Variable();
vb.setName("vb");
vb.setType(Variable.Type.INTEGER);
vb.setCausality(Variable.Causality.INPUT);
vb.setUnit(ub);
VariableConnection vc = new VariableConnection();
vc.setVariableA(va);
vc.setVariableB(vb);
vc.setSimulatorA(new Simulator());
vc.setSimulatorB(new Simulator());
builder.build(vc);
builder.complete();
List<ValidationDiagnostic<VariableConnection>> diagnostics = validationError.validate();
assertEquals(1, diagnostics.size());
VariableConnection invalidVariableConnection = diagnostics.get(0).getValidatedObject();
assertEquals(vc, invalidVariableConnection);
assertEquals(va, invalidVariableConnection.getVariableA());
assertEquals(vb, invalidVariableConnection.getVariableB());
}
Aggregations