Search in sources :

Example 1 with PropertyImpl

use of org.osate.aadl2.impl.PropertyImpl in project kie-wb-common by kiegroup.

the class ParsedAssignmentsInfoTest method testCreateInitializedOutputVariablesDuplicates.

@Test
public void testCreateInitializedOutputVariablesDuplicates() {
    final String DATA_OUTPUT_ID = "_Data-TestOutputX";
    final String DATA_OUTPUT_NAME = "Data Test";
    final String DATA_OUTPUT_ASSOCIATION_ID = "Data Test";
    final String DATA_OUTPUT_ASSOCIATION_VALUE_1 = "BooleanTest";
    final String DATA_OUTPUT_ASSOCIATION_VALUE_2 = "BooleanTest2";
    final String INIT_OUTPUT_VAR_ID = "Data-Test";
    final String INIT_OUTPUT_VAR_TYPE = "Boolean";
    VariableScope variableScope = new FlatVariableScope();
    variableScope.declare("", "BooleanTest", "Boolean");
    variableScope.declare("", "BooleanTest2", "Boolean");
    List<InitializedVariable.InitializedOutputVariable> initializedOutputVariables = testedDuplicates.createInitializedOutputVariables("", variableScope, new HashSet<>());
    assertEquals(2, initializedOutputVariables.size());
    // Test first variable
    InitializedVariable.InitializedOutputVariable initializedOutputVariable1 = initializedOutputVariables.get(0);
    DataOutput dataOutput1 = initializedOutputVariable1.getDataOutput();
    DataOutputAssociation dataOutputAssociation1 = initializedOutputVariable1.getDataOutputAssociation();
    List<ItemAwareElement> sourceRef1 = dataOutputAssociation1.getSourceRef();
    DataOutput source1 = (DataOutput) sourceRef1.get(0);
    PropertyImpl target1 = (PropertyImpl) dataOutputAssociation1.getTargetRef();
    String dataOutputID1 = dataOutput1.getId();
    String dataOutputName1 = dataOutput1.getName();
    String dataOutputAssociationID1 = source1.getName();
    String dataOutputAssociationValue1 = target1.getId();
    String initVarID1 = initializedOutputVariable1.getIdentifier();
    String initVarType1 = initializedOutputVariable1.getType();
    assertEquals(dataOutputID1, DATA_OUTPUT_ID);
    assertEquals(dataOutputName1, DATA_OUTPUT_NAME);
    assertEquals(dataOutputAssociationID1, DATA_OUTPUT_ASSOCIATION_ID);
    assertEquals(dataOutputAssociationValue1, DATA_OUTPUT_ASSOCIATION_VALUE_1);
    assertEquals(initVarID1, INIT_OUTPUT_VAR_ID);
    assertEquals(initVarType1, INIT_OUTPUT_VAR_TYPE);
    // Test duplicate variable
    InitializedVariable.InitializedOutputVariable initializedOutputVariable2 = initializedOutputVariables.get(1);
    DataOutput dataOutput2 = initializedOutputVariable2.getDataOutput();
    DataOutputAssociation dataOutputAssociation2 = initializedOutputVariable2.getDataOutputAssociation();
    List<ItemAwareElement> sourceRef2 = dataOutputAssociation2.getSourceRef();
    DataOutput source2 = (DataOutput) sourceRef2.get(0);
    PropertyImpl target2 = (PropertyImpl) dataOutputAssociation2.getTargetRef();
    String dataOutputID2 = dataOutput2.getId();
    String dataOutputName2 = dataOutput2.getName();
    String dataOutputAssociationID2 = source2.getName();
    String dataOutputAssociationValue2 = target2.getId();
    String initVarID2 = initializedOutputVariable2.getIdentifier();
    String initVarType2 = initializedOutputVariable2.getType();
    assertEquals(dataOutputID2, DATA_OUTPUT_ID);
    assertEquals(dataOutputName2, DATA_OUTPUT_NAME);
    assertEquals(dataOutputAssociationID2, DATA_OUTPUT_ASSOCIATION_ID);
    assertEquals(dataOutputAssociationValue2, DATA_OUTPUT_ASSOCIATION_VALUE_2);
    assertEquals(initVarID2, INIT_OUTPUT_VAR_ID);
    assertEquals(initVarType2, INIT_OUTPUT_VAR_TYPE);
}
Also used : DataOutput(org.eclipse.bpmn2.DataOutput) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) PropertyImpl(org.eclipse.bpmn2.impl.PropertyImpl) InitializedVariable(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) VariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.VariableScope) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) Test(org.junit.Test)

Example 2 with PropertyImpl

use of org.osate.aadl2.impl.PropertyImpl in project AMASE by loonwerks.

the class SafetyValidator method checkInput.

/**
 * Checks fault def name is valid,
 * expressions passed into node match parameter types,
 * and correct number of arguments passed in.
 *
 * @param inputs
 */
@Check(CheckType.FAST)
public void checkInput(InputStatement inputs) {
    EObject container = inputs.eContainer();
    NamedElement defNameSub;
    List<Expr> exprList = inputs.getNom_conn();
    List<String> inputList = inputs.getFault_in();
    ArrayList<String> argNames = new ArrayList<String>();
    if (container instanceof FaultStatement) {
        FaultStatement faultStatement = (FaultStatement) container;
        DoubleDotRef defName = faultStatement.getFaultDefName();
        defNameSub = defName.getElm();
        // Make sure we have a NodeDefExpr
        if (defNameSub instanceof NodeDef) {
            List<Arg> nodeArgs = ((NodeDef) defNameSub).getArgs();
            for (Arg arg : nodeArgs) {
                argNames.add(arg.getFullName());
                if (arg.getType() instanceof DoubleDotRefImpl) {
                    if ((((DoubleDotRefImpl) arg.getType()).getElm() instanceof PropertyImpl) || (((DoubleDotRefImpl) arg.getType()).getElm() instanceof DataTypeImpl)) {
                        error(inputs, "Fault node parameters are not recognized: a possible issue is that the keyword 'float' is used instead of 'real.'");
                    }
                }
            }
            // If the sizes are accurate, make sure names match
            if (nodeArgs.size() - 1 == (inputList.size())) {
                // Go through input list and make sure each name is in the arg list
                for (String inputName : inputList) {
                    if (!argNames.contains(inputName)) {
                        error(inputs, "Input names must match fault node definition names. " + "The input name " + inputName + " is not an input in the node definition. " + "All possible input names are: " + argNames.toString());
                    }
                }
            } else {
                argNames.remove("trigger");
                error(inputs, "With this fault definition, you must have " + (argNames.size() - 1) + " inputs." + " These are called: " + argNames.toString());
            }
            if (inputListHasRepeats(inputList)) {
                error(inputs, "There is a repeated name in the input list: " + inputList.toString());
            }
            if (!checkInputTypes(exprList, nodeArgs)) {
                error(inputs, "Types of inputs do not match types of node parameters");
            }
        } else {
            // Not a node def expr
            error(defName, "Fault definition: " + defNameSub.getFullName() + " must be a valid agree node definition name.");
        }
    } else {
        error(inputs, "Fault inputs must be defined within a fault statement.");
    }
}
Also used : NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) ArrayList(java.util.ArrayList) FaultStatement(edu.umn.cs.crisys.safety.safety.FaultStatement) HWFaultStatement(edu.umn.cs.crisys.safety.safety.HWFaultStatement) PropertyImpl(org.osate.aadl2.impl.PropertyImpl) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) Expr(com.rockwellcollins.atc.agree.agree.Expr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) DataTypeImpl(org.osate.aadl2.impl.DataTypeImpl) EObject(org.eclipse.emf.ecore.EObject) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) Arg(com.rockwellcollins.atc.agree.agree.Arg) DoubleDotRefImpl(com.rockwellcollins.atc.agree.agree.impl.DoubleDotRefImpl) NamedElement(org.osate.aadl2.NamedElement) Check(org.eclipse.xtext.validation.Check)

Example 3 with PropertyImpl

use of org.osate.aadl2.impl.PropertyImpl in project kie-wb-common by kiegroup.

the class InitializedVariableTest method testGetDataOuput.

@Test
public void testGetDataOuput() {
    final VariableDeclaration varDeclaration = new VariableDeclaration("Data Output Test", "Boolean");
    final String TARGET_VAR = "BooleanTarget";
    final String DATA_OUTPUT_ID = "_Data-Output-TestOutputX";
    final String DATA_OUTPUT_NAME = "Data Output Test";
    final String DATA_OUTPUT_ASSOCIATION_ID = "Data Output Test";
    final String DATA_OUTPUT_ASSOCIATION_VALUE = "BooleanTarget";
    final String INIT_OUTPUT_VAR_ID = "Data-Output-Test";
    final String INIT_OUTPUT_VAR_TYPE = "Boolean";
    InitializedVariable.InitializedOutputVariable initializedOutputVar = new InitializedVariable.OutputVariableReference("", varScope, varDeclaration, TARGET_VAR, new HashSet<>());
    DataOutput dataOuput = initializedOutputVar.getDataOutput();
    DataOutputAssociation dataOutputAssociation = initializedOutputVar.getDataOutputAssociation();
    List<ItemAwareElement> sourceRef = dataOutputAssociation.getSourceRef();
    DataOutput source = (DataOutput) sourceRef.get(0);
    PropertyImpl target = (PropertyImpl) dataOutputAssociation.getTargetRef();
    String dataOuputID = dataOuput.getId();
    String dataOutputName = dataOuput.getName();
    String dataOutputAssociationID = source.getName();
    String dataOutputAssocationValue = target.getId();
    String initVarID = initializedOutputVar.getIdentifier();
    String initVarType = initializedOutputVar.getType();
    assertEquals(dataOuputID, DATA_OUTPUT_ID);
    assertEquals(dataOutputName, DATA_OUTPUT_NAME);
    assertEquals(dataOutputAssociationID, DATA_OUTPUT_ASSOCIATION_ID);
    assertEquals(dataOutputAssocationValue, DATA_OUTPUT_ASSOCIATION_VALUE);
    assertEquals(initVarID, INIT_OUTPUT_VAR_ID);
    assertEquals(initVarType, INIT_OUTPUT_VAR_TYPE);
}
Also used : DataOutput(org.eclipse.bpmn2.DataOutput) InitializedVariable(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) VariableDeclaration(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.VariableDeclaration) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) PropertyImpl(org.eclipse.bpmn2.impl.PropertyImpl) Test(org.junit.Test)

Example 4 with PropertyImpl

use of org.osate.aadl2.impl.PropertyImpl in project kie-wb-common by kiegroup.

the class InitializedVariableTest method testGetDataInput.

@Test
public void testGetDataInput() {
    final String SOURCE_VAR = "BooleanSource";
    final String DATA_INPUT_ID = "_Data-Input-TestInputX";
    final String DATA_INPUT_NAME = "Data Input Test";
    final String DATA_INPUT_ASSOCIATION_ID = "Data Input Test";
    final String DATA_INPUT_ASSOCIATION_VALUE = "BooleanSource";
    final String INIT_INPUT_VAR_ID = "Data-Input-Test";
    final String INIT_INPUT_VAR_TYPE = "Boolean";
    final VariableDeclaration varDeclaration = new VariableDeclaration("Data Input Test", "Boolean");
    InitializedVariable.InitializedInputVariable initializedInputVar = new InitializedVariable.InputVariableReference("", varScope, varDeclaration, SOURCE_VAR, new HashSet<>());
    DataInput dataInput = initializedInputVar.getDataInput();
    DataInputAssociation dataInputAssociation = initializedInputVar.getDataInputAssociation();
    List<ItemAwareElement> sourceRef = dataInputAssociation.getSourceRef();
    PropertyImpl source = (PropertyImpl) sourceRef.get(0);
    DataInput target = (DataInput) dataInputAssociation.getTargetRef();
    String dataInputId = dataInput.getId();
    String dataInputName = dataInput.getName();
    String dataInputAssociationID = target.getName();
    String dataInputAssociationValue = source.getId();
    String initVarID = initializedInputVar.getIdentifier();
    String initVarType = initializedInputVar.getType();
    assertEquals(dataInputId, DATA_INPUT_ID);
    assertEquals(dataInputName, DATA_INPUT_NAME);
    assertEquals(dataInputAssociationID, DATA_INPUT_ASSOCIATION_ID);
    assertEquals(dataInputAssociationValue, DATA_INPUT_ASSOCIATION_VALUE);
    assertEquals(initVarID, INIT_INPUT_VAR_ID);
    assertEquals(initVarType, INIT_INPUT_VAR_TYPE);
}
Also used : DataInput(org.eclipse.bpmn2.DataInput) InitializedVariable(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) VariableDeclaration(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.VariableDeclaration) PropertyImpl(org.eclipse.bpmn2.impl.PropertyImpl) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) Test(org.junit.Test)

Example 5 with PropertyImpl

use of org.osate.aadl2.impl.PropertyImpl in project kie-wb-common by kiegroup.

the class ParsedAssignmentsInfoTest method testCreateInitializedOutputVariables.

@Test
public void testCreateInitializedOutputVariables() {
    final String DATA_OUTPUT_ID = "_Data-TestOutputX";
    final String DATA_OUTPUT_NAME = "Data Test";
    final String DATA_OUTPUT_ASSOCIATION_ID = "Data Test";
    final String DATA_OUTPUT_ASSOCIATION_VALUE = "BooleanTest";
    final String INIT_OUTPUT_VAR_ID = "Data-Test";
    final String INIT_OUTPUT_VAR_TYPE = "Boolean";
    VariableScope variableScope = new FlatVariableScope();
    variableScope.declare("", "BooleanTest", "Boolean");
    List<InitializedVariable.InitializedOutputVariable> initializedOutputVariables = tested.createInitializedOutputVariables("", variableScope, new HashSet<>());
    assertEquals(1, initializedOutputVariables.size());
    InitializedVariable.InitializedOutputVariable initializedOutputVariable = initializedOutputVariables.get(0);
    DataOutput dataOutput = initializedOutputVariable.getDataOutput();
    DataOutputAssociation dataOutputAssociation = initializedOutputVariable.getDataOutputAssociation();
    List<ItemAwareElement> sourceRef = dataOutputAssociation.getSourceRef();
    DataOutput source = (DataOutput) sourceRef.get(0);
    PropertyImpl target = (PropertyImpl) dataOutputAssociation.getTargetRef();
    String dataOutputID = dataOutput.getId();
    String dataOutputName = dataOutput.getName();
    String dataOutputAssociationID = source.getName();
    String dataOutputAssociationValue = target.getId();
    String initVarID = initializedOutputVariable.getIdentifier();
    String initVarType = initializedOutputVariable.getType();
    assertEquals(dataOutputID, DATA_OUTPUT_ID);
    assertEquals(dataOutputName, DATA_OUTPUT_NAME);
    assertEquals(dataOutputAssociationID, DATA_OUTPUT_ASSOCIATION_ID);
    assertEquals(dataOutputAssociationValue, DATA_OUTPUT_ASSOCIATION_VALUE);
    assertEquals(initVarID, INIT_OUTPUT_VAR_ID);
    assertEquals(initVarType, INIT_OUTPUT_VAR_TYPE);
}
Also used : DataOutput(org.eclipse.bpmn2.DataOutput) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) PropertyImpl(org.eclipse.bpmn2.impl.PropertyImpl) InitializedVariable(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) VariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.VariableScope) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) Test(org.junit.Test)

Aggregations

ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)4 PropertyImpl (org.eclipse.bpmn2.impl.PropertyImpl)4 Test (org.junit.Test)4 InitializedVariable (org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable)4 DataOutput (org.eclipse.bpmn2.DataOutput)3 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)3 VariableDeclaration (org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.VariableDeclaration)2 FlatVariableScope (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope)2 VariableScope (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.VariableScope)2 Arg (com.rockwellcollins.atc.agree.agree.Arg)1 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)1 DoubleDotRef (com.rockwellcollins.atc.agree.agree.DoubleDotRef)1 Expr (com.rockwellcollins.atc.agree.agree.Expr)1 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)1 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)1 NodeDef (com.rockwellcollins.atc.agree.agree.NodeDef)1 PrevExpr (com.rockwellcollins.atc.agree.agree.PrevExpr)1 RealLitExpr (com.rockwellcollins.atc.agree.agree.RealLitExpr)1 UnaryExpr (com.rockwellcollins.atc.agree.agree.UnaryExpr)1 DoubleDotRefImpl (com.rockwellcollins.atc.agree.agree.impl.DoubleDotRefImpl)1