Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public
events
ev: error event;
states
s: state {ErrorLibrary::CommonErrors};
s: initial state {ErrorLibrary::CommonErrors};
end behavior;
**};

Expand All @@ -24,4 +24,4 @@ public
end component;
**};
end S;
end emv::transition;
end emv::transition;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.aadlbin-gen/
/instances/
18 changes: 18 additions & 0 deletions emv2/org.osate.aadl2.errormodel.tests/models/issue2804/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>issue2804</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.osate.core.aadlnature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package Issue2804
public
annex EMV2 {**
error behavior no_initial
states
one: state;
two: state;
three: state;
end behavior;

error behavior multiple_initial
states
a: initial state;
b: state;
c: initial state;
end behavior;

error behavior no_states
end behavior;
**};
end Issue2804;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ValidInitialStates
public
annex EMV2 {**
error behavior one_state
states
only: initial state;
end behavior;

error behavior initial_not_first
states
one: state;
two: initial state;
three: state;
end behavior;
**};
end ValidInitialStates;
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ public void testBasicEMV2PropertyAssociationInErrorBehaviorStateMachine() throws
\t\tevents
\t\t\tevt1: error event;
\t\tstates
\t\t\tstate1: state;
\t\t\tstate1: initial state;
\t\ttransitions
\t\t\ttrans1: all -[ evt1 ]-> same state;
\t\tproperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public void testErrorModelLibraryReference() throws Exception {
\t\terror behavior b
\t\t\tuse types ErrorLibrary;
\t\t\tuse transformations t;
\t\tstates
\t\t\tstate1: initial state;
\t\tend behavior;
\t\t
\t\ttype mappings m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void testBranchValue() throws Exception {
\t\tevents
\t\t\terr_evt1: error event;
\t\tstates
\t\t\tbvr_state1: state;
\t\t\tbvr_state1: initial state;
\t\t\tbvr_state2: state;
\t\ttransitions
\t\t\ttransition1: bvr_state1 -[ err_evt1 ]-> (bvr_state2 with 0.2_0, bvr_state2 with ps1::def1);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* Copyright (c) 2004-2026 Carnegie Mellon University and others. (see Contributors file).
* All Rights Reserved.
*
* NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY
* KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE
* OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT
* MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT.
*
* This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
* SPDX-License-Identifier: EPL-2.0
*
* Created, in part, with funding and support from the United States Government. (see Acknowledgments file).
*
* This program includes and/or can make use of certain third party source code, object code, documentation and other
* files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system
* configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and
* conditions contained in any such Third Party Software or separate license file distributed with such Third Party
* Software. The parties who own the Third Party Software ("Third Party Licensors") are intended third party benefici-
* aries to this license with respect to the terms applicable to their Third Party Software. Third Party Software li-
* censes only apply to the Third Party Software and not any other portion of this program or this program as a whole.
*/
package org.osate.aadl2.errormodel.tests.issues;

import java.util.ArrayList;

import org.eclipse.xtext.testing.InjectWith;
import org.eclipse.xtext.testing.XtextRunner;
import org.eclipse.xtext.testing.validation.ValidationTestHelper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.osate.aadl2.AadlPackage;
import org.osate.aadl2.DefaultAnnexLibrary;
import org.osate.aadl2.errormodel.tests.ErrorModelInjectorProvider;
import org.osate.testsupport.AssertHelper;
import org.osate.testsupport.TestHelper;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary;

import com.google.inject.Inject;
import com.itemis.xtext.testing.FluentIssueCollection;
import com.itemis.xtext.testing.XtextTest;

@RunWith(XtextRunner.class)
@InjectWith(ErrorModelInjectorProvider.class)
public class Issue2804Test extends XtextTest {
private static final String PROJECT_LOCATION = "org.osate.aadl2.errormodel.tests/models/issue2804/";

@Inject
private TestHelper<AadlPackage> testHelper;

@Inject
private ValidationTestHelper validationHelper;

@Test
public void rejectMissingAndMultipleInitialStates() throws Exception {
var result = issues = testHelper.testFile(PROJECT_LOCATION + "Issue2804.aadl");
var expected = new FluentIssueCollection(result.getResource(), new ArrayList<>(), new ArrayList<>());
var pkg = (AadlPackage) result.getResource().getContents().getFirst();
var library = (ErrorModelLibrary) ((DefaultAnnexLibrary) pkg.getPublicSection().getOwnedAnnexLibraries()
.getFirst()).getParsedAnnexLibrary();
for (var behavior : library.getBehaviors()) {
AssertHelper.assertError(behavior, result.getIssues(), expected,
"Error behavior state machine must have exactly one initial state");
}
expected.sizeIs(3);
assertConstraints(expected);
}

@Test
public void acceptExactlyOneInitialState() {
validationHelper.assertNoIssues(testHelper.parseFile(PROJECT_LOCATION + "ValidInitialStates.aadl"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ public void caseErrorModelLibrary(ErrorModelLibrary errorModelLibrary) {
@Check(CheckType.FAST)
public void caseErrorBehaviorStateMachine(ErrorBehaviorStateMachine ebsm) {
checkUniqueEBSMElements(ebsm);
if (ebsm.getStates().stream().filter(ErrorBehaviorState::isIntial).count() != 1) {
error(ebsm, "Error behavior state machine must have exactly one initial state");
}
}

@Check(CheckType.FAST)
Expand Down