Search in sources :

Example 86 with ListValue

use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.

the class Issue2264Test method testInstantiation.

@Test
public void testInstantiation() throws Exception {
    AadlPackage pkg = testHelper.parseFile(FILE);
    Optional<Classifier> impl = pkg.getOwnedPublicSection().getOwnedClassifiers().stream().filter(c -> c.getName().equals("S.i")).findFirst();
    SystemInstance instance = InstantiateModel.instantiate((ComponentImplementation) impl.get());
    Assert.assertEquals("S_i_Instance", instance.getName());
    ConnectionInstance conni = instance.getConnectionInstances().get(0);
    Assert.assertEquals("a1.o -> a2.i", conni.getName());
    PropertyExpression pe = conni.getOwnedPropertyAssociations().get(0).getOwnedValues().get(0).getOwnedValue();
    Assert.assertEquals(1, ((ListValue) pe).getOwnedListElements().size());
    pe = ((ListValue) pe).getOwnedListElements().get(0);
    InstanceObject io = ((InstanceReferenceValue) pe).getReferencedInstanceObject();
    Assert.assertEquals("b", io.getName());
}
Also used : SystemInstance(org.osate.aadl2.instance.SystemInstance) ListValue(org.osate.aadl2.ListValue) Aadl2InjectorProvider(org.osate.testsupport.Aadl2InjectorProvider) InstantiateModel(org.osate.aadl2.instantiation.InstantiateModel) Inject(com.google.inject.Inject) RunWith(org.junit.runner.RunWith) ComponentImplementation(org.osate.aadl2.ComponentImplementation) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) Test(org.junit.Test) AadlPackage(org.osate.aadl2.AadlPackage) XtextRunner(org.eclipse.xtext.testing.XtextRunner) TestHelper(org.osate.testsupport.TestHelper) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) XtextTest(com.itemis.xtext.testing.XtextTest) PropertyExpression(org.osate.aadl2.PropertyExpression) Classifier(org.osate.aadl2.Classifier) InjectWith(org.eclipse.xtext.testing.InjectWith) Optional(java.util.Optional) Assert(org.junit.Assert) InstanceObject(org.osate.aadl2.instance.InstanceObject) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) InstanceObject(org.osate.aadl2.instance.InstanceObject) AadlPackage(org.osate.aadl2.AadlPackage) SystemInstance(org.osate.aadl2.instance.SystemInstance) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) Classifier(org.osate.aadl2.Classifier) Test(org.junit.Test) XtextTest(com.itemis.xtext.testing.XtextTest)

Example 87 with ListValue

use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.

the class Issue2265Test method testInstantiation.

@Test
public void testInstantiation() throws Exception {
    AadlPackage pkg = testHelper.parseFile(FILE);
    Optional<Classifier> impl = pkg.getOwnedPublicSection().getOwnedClassifiers().stream().filter(c -> c.getName().equals("top.i")).findFirst();
    SystemInstance instance = InstantiateModel.instantiate((ComponentImplementation) impl.get());
    Assert.assertEquals("top_i_Instance", instance.getName());
    ComponentInstance a = instance.getComponentInstances().get(0);
    Assert.assertEquals("a", a.getName());
    PropertyExpression pe = a.getOwnedPropertyAssociations().get(0).getOwnedValues().get(0).getOwnedValue();
    Assert.assertEquals(1, ((ListValue) pe).getOwnedListElements().size());
    pe = ((ListValue) pe).getOwnedListElements().get(0);
    AbstractNamedValue nv = ((NamedValue) pe).getNamedValue();
    Assert.assertEquals("Ada95", ((EnumerationLiteral) nv).getName());
    ConnectionInstance conni = instance.getConnectionInstances().get(0);
    Assert.assertEquals("sub1.out1 -> sub2.in1", conni.getName());
    pe = conni.getOwnedPropertyAssociations().get(0).getOwnedValues().get(0).getOwnedValue();
    Assert.assertEquals(1, ((ListValue) pe).getOwnedListElements().size());
    pe = ((ListValue) pe).getOwnedListElements().get(0);
    InstanceObject io = ((InstanceReferenceValue) pe).getReferencedInstanceObject();
    Assert.assertEquals("theBus2", io.getName());
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) SystemInstance(org.osate.aadl2.instance.SystemInstance) ListValue(org.osate.aadl2.ListValue) NamedValue(org.osate.aadl2.NamedValue) Aadl2InjectorProvider(org.osate.testsupport.Aadl2InjectorProvider) InstantiateModel(org.osate.aadl2.instantiation.InstantiateModel) Inject(com.google.inject.Inject) RunWith(org.junit.runner.RunWith) ComponentImplementation(org.osate.aadl2.ComponentImplementation) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) Test(org.junit.Test) AadlPackage(org.osate.aadl2.AadlPackage) XtextRunner(org.eclipse.xtext.testing.XtextRunner) TestHelper(org.osate.testsupport.TestHelper) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) XtextTest(com.itemis.xtext.testing.XtextTest) PropertyExpression(org.osate.aadl2.PropertyExpression) Classifier(org.osate.aadl2.Classifier) InjectWith(org.eclipse.xtext.testing.InjectWith) Optional(java.util.Optional) Assert(org.junit.Assert) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) InstanceObject(org.osate.aadl2.instance.InstanceObject) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) AadlPackage(org.osate.aadl2.AadlPackage) ListValue(org.osate.aadl2.ListValue) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) NamedValue(org.osate.aadl2.NamedValue) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) Classifier(org.osate.aadl2.Classifier) InstanceObject(org.osate.aadl2.instance.InstanceObject) SystemInstance(org.osate.aadl2.instance.SystemInstance) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) Test(org.junit.Test) XtextTest(com.itemis.xtext.testing.XtextTest)

Example 88 with ListValue

use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.

the class Arinc653 method getHmErrorIdLevels.

public static Optional<List<HmErrorIdLevelType>> getHmErrorIdLevels(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getHmErrorIdLevels_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((ListValue) resolved).getOwnedListElements().stream().map(element1 -> {
            PropertyExpression resolved1 = CodeGenUtil.resolveNamedValue(element1, lookupContext, mode);
            return new HmErrorIdLevelType(resolved1, lookupContext, mode);
        }).collect(Collectors.toList()));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 89 with ListValue

use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.

the class Arinc653 method getModuleSchedule.

public static Optional<List<ScheduleWindow>> getModuleSchedule(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getModuleSchedule_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((ListValue) resolved).getOwnedListElements().stream().map(element1 -> {
            PropertyExpression resolved1 = CodeGenUtil.resolveNamedValue(element1, lookupContext, mode);
            return new ScheduleWindow(resolved1, lookupContext, mode);
        }).collect(Collectors.toList()));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 90 with ListValue

use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.

the class Arinc653 method getHmErrorIdActions.

public static Optional<List<HmErrorIdActionType>> getHmErrorIdActions(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getHmErrorIdActions_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((ListValue) resolved).getOwnedListElements().stream().map(element1 -> {
            PropertyExpression resolved1 = CodeGenUtil.resolveNamedValue(element1, lookupContext, mode);
            return new HmErrorIdActionType(resolved1, lookupContext, mode);
        }).collect(Collectors.toList()));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Aggregations

ListValue (org.osate.aadl2.ListValue)101 PropertyExpression (org.osate.aadl2.PropertyExpression)85 Property (org.osate.aadl2.Property)64 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)51 ClassifierValue (org.osate.aadl2.ClassifierValue)29 StringLiteral (org.osate.aadl2.StringLiteral)24 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)22 PropertyAssociation (org.osate.aadl2.PropertyAssociation)21 InstanceReferenceValue (org.osate.aadl2.instance.InstanceReferenceValue)21 IntegerLiteral (org.osate.aadl2.IntegerLiteral)19 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)19 RecordValue (org.osate.aadl2.RecordValue)19 ReferenceValue (org.osate.aadl2.ReferenceValue)16 NamedValue (org.osate.aadl2.NamedValue)15 Classifier (org.osate.aadl2.Classifier)14 RangeValue (org.osate.aadl2.RangeValue)13 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)12 ArrayList (java.util.ArrayList)11 BooleanLiteral (org.osate.aadl2.BooleanLiteral)11 PropertyConstant (org.osate.aadl2.PropertyConstant)11