Skip to content

Commit

Permalink
Merge pull request #2256 from osate/2128_detection_reporting_port
Browse files Browse the repository at this point in the history
Detection reporting port
  • Loading branch information
lwrage committed Apr 2, 2020
2 parents ee3e3bb + 3a55aec commit 39504e3
Show file tree
Hide file tree
Showing 26 changed files with 14,836 additions and 12,909 deletions.
Expand Up @@ -724,7 +724,7 @@ class OtherErrorModelScopeProviderTest extends XtextTest {
]
}

// Tests scope_ErrorDetection_detectionReportingPort and ErrorCodeValue's constant reference
// Tests scope_ReportingPortReference_element and ErrorCodeValue's constant reference
@Test
def void testErrorDetectionReferences() {
val ps = '''
Expand Down Expand Up @@ -755,6 +755,12 @@ class OtherErrorModelScopeProviderTest extends XtextTest {
dp2: in data port;
ep2: in event port;
edp2: in event data port;
annex EMV2 {**
component error behavior
detections
detection1: all -[ access ]-> dp1!;
end component;
**};
end a2;
abstract implementation a2.i extends a1.i
Expand All @@ -770,21 +776,31 @@ class OtherErrorModelScopeProviderTest extends XtextTest {
component error behavior
detections
detection1: all -[ access ]-> dp1! (ps1::const1);
detection2: all -[ access ]-> dp1! (ps1::const1);
end component;
**};
end a2.i;
end subclause1;
'''
testHelper.parseString(subclause, ps) => [
"subclause1".assertEquals(name)
publicSection.ownedClassifiers.get(2) => [
"a2".assertEquals(name)
((ownedAnnexSubclauses.head as DefaultAnnexSubclause).parsedAnnexSubclause as ErrorModelSubclause).
errorDetections.head => [
"detection1".assertEquals(name)
// Tests scope_ReportingPortReference_element
detectionReportingPort.assertScope(ErrorModelPackage.eINSTANCE.reportingPortReference_Element,
#["af1", "dp1", "ep1", "edp1", "af2", "dp2", "ep2", "edp2"])
]
]
publicSection.ownedClassifiers.get(3) => [
"a2.i".assertEquals(name)
((ownedAnnexSubclauses.head as DefaultAnnexSubclause).parsedAnnexSubclause as ErrorModelSubclause).
errorDetections.head => [
"detection1".assertEquals(name)
// Tests scope_ErrorDetection_detectionReportingPort
assertScope(ErrorModelPackage.eINSTANCE.errorDetection_DetectionReportingPort, #[
"detection2".assertEquals(name)
// Tests scope_ReportingPortReference_element
detectionReportingPort.assertScope(ErrorModelPackage.eINSTANCE.reportingPortReference_Element, #[
"af1",
"dp1",
"ep1",
Expand Down
@@ -0,0 +1,184 @@
package org.osate.aadl2.errormodel.tests.issues

import com.google.inject.Inject
import com.itemis.xtext.testing.FluentIssueCollection
import com.itemis.xtext.testing.XtextTest
import org.eclipse.emf.common.util.URI
import org.eclipse.xtext.resource.IResourceServiceProvider
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.DefaultAnnexSubclause
import org.osate.aadl2.errormodel.tests.ErrorModelInjectorProvider
import org.osate.testsupport.AssertHelper
import org.osate.testsupport.TestHelper
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelPackage
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause

import static extension org.junit.Assert.assertEquals
import static extension org.junit.Assert.assertNull
import static extension org.osate.testsupport.AssertHelper.assertError

@RunWith(XtextRunner)
@InjectWith(ErrorModelInjectorProvider)
class Issue2128Test extends XtextTest {
@Inject
extension ValidationTestHelper

@Inject
TestHelper<AadlPackage> testHelper

extension AssertHelper assertHelper = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(
URI.createFileURI("dummy.emv2")).get(AssertHelper)

@Test
def void testScoping() {
val issue2128Scoping = '''
package issue_2128_scoping
public
abstract a1
features
fg1: feature group fgt1;
end a1;
abstract implementation a1.i
internal features
event_source_1: event;
annex EMV2 {**
component error behavior
detections
detection1: all -[access]-> fg1.fg2.fg3.port3 !;
end component;
**};
end a1.i;
feature group fgt1
features
port1: in out data port;
fg2: feature group fgt2;
end fgt1;
feature group fgt2
features
port2: in out data port;
fg3: feature group fgt3;
end fgt2;
feature group fgt3
features
port3: in out data port;
end fgt3;
end issue_2128_scoping;
'''
val reference = ErrorModelPackage.eINSTANCE.reportingPortReference_Element
testHelper.parseString(issue2128Scoping) => [
assertNoIssues
"issue_2128_scoping".assertEquals(name)
publicSection.ownedClassifiers.get(1) => [
"a1.i".assertEquals(name)
val defaultSubclause = ownedAnnexSubclauses.head as DefaultAnnexSubclause
(defaultSubclause.parsedAnnexSubclause as ErrorModelSubclause).errorDetections.head => [
"detection1".assertEquals(name)
detectionReportingPort => [
"port3".assertEquals(element.name)
assertScope(reference, #["port3"])
previous => [
"fg3".assertEquals(element.name)
assertScope(reference, #["port2", "fg3"])
previous => [
"fg2".assertEquals(element.name)
assertScope(reference, #["port1", "fg2"])
previous => [
"fg1".assertEquals(element.name)
assertScope(reference, #["fg1", "event_source_1"])
previous.assertNull
]
]
]
]
]
]
]
}

@Test
def void testValidation() {
val issue2128Validation = '''
package issue_2128_validation
public
abstract a1
features
abstract_feature_1: feature;
port1: in out data port;
data_access_1: provides data access;
fg1: feature group fgt1;
end a1;
abstract implementation a1.i
internal features
event_source_1: event;
annex EMV2 {**
component error behavior
detections
--Valid
detection1: all -[access]-> abstract_feature_1 !;
detection2: all -[access]-> port1 !;
detection3: all -[access]-> event_source_1 !;
detection4: all -[access]-> fg1.abstract_feature_2 !;
detection5: all -[access]-> fg1.port2 !;
--Invalid
detection6: all -[access]-> fg1 !;
detection7: all -[access]-> data_access_1 !;
detection8: all -[access]-> fg1.fg2 !;
detection9: all -[access]-> fg1.data_access_2 !;
end component;
**};
end a1.i;
feature group fgt1
features
abstract_feature_2: feature;
port2: in out data port;
data_access_2: provides data access;
fg2: feature group;
end fgt1;
end issue_2128_validation;
'''
val testFileResult = issues = testHelper.testString(issue2128Validation)
val issueCollection = new FluentIssueCollection(testFileResult.resource, newArrayList, newArrayList)
testFileResult.resource.contents.head as AadlPackage => [
"issue_2128_validation".assertEquals(name)
publicSection.ownedClassifiers.get(1) => [
"a1.i".assertEquals(name)
(ownedAnnexSubclauses.head as DefaultAnnexSubclause).parsedAnnexSubclause as ErrorModelSubclause => [
errorDetections.get(5) => [
"detection6".assertEquals(name)
detectionReportingPort.assertError(testFileResult.issues, issueCollection,
"'fg1' is not a port, abstract feature, or internal feature.")
]
errorDetections.get(6) => [
"detection7".assertEquals(name)
detectionReportingPort.assertError(testFileResult.issues, issueCollection,
"'data_access_1' is not a port, abstract feature, or internal feature.")
]
errorDetections.get(7) => [
"detection8".assertEquals(name)
detectionReportingPort.assertError(testFileResult.issues, issueCollection,
"'fg2' is not a port, abstract feature, or internal feature.")
]
errorDetections.get(8) => [
"detection9".assertEquals(name)
detectionReportingPort.assertError(testFileResult.issues, issueCollection,
"'data_access_2' is not a port, abstract feature, or internal feature.")
]
]
]
]
issueCollection.sizeIs(testFileResult.issues.size)
assertConstraints(issueCollection)
}
}
Expand Up @@ -616,11 +616,14 @@ public void completeErrorDetection_Condition(EObject model, Assignment assignmen
completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
public void completeErrorDetection_DetectionReportingPort(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor);
completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
public void completeErrorDetection_ErrorCode(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
public void completeReportingPortReference_Element(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor);
}
public void completeErrorCodeValue_IntValue(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
Expand Down Expand Up @@ -901,6 +904,9 @@ public void complete_OutgoingPropagationCondition(EObject model, RuleCall ruleCa
public void complete_ErrorDetection(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
public void complete_ReportingPortReference(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
public void complete_ErrorCodeValue(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
Expand Down
Expand Up @@ -284,6 +284,8 @@ protected String getRuleName(AbstractElement element) {
put(grammarAccess.getErrorDetectionAccess().getGroup_0(), "rule__ErrorDetection__Group_0__0");
put(grammarAccess.getErrorDetectionAccess().getGroup_1_0(), "rule__ErrorDetection__Group_1_0__0");
put(grammarAccess.getErrorDetectionAccess().getGroup_7(), "rule__ErrorDetection__Group_7__0");
put(grammarAccess.getReportingPortReferenceAccess().getGroup(), "rule__ReportingPortReference__Group__0");
put(grammarAccess.getReportingPortReferenceAccess().getGroup_1(), "rule__ReportingPortReference__Group_1__0");
put(grammarAccess.getErrorStateToModeMappingAccess().getGroup(), "rule__ErrorStateToModeMapping__Group__0");
put(grammarAccess.getErrorStateToModeMappingAccess().getGroup_5(), "rule__ErrorStateToModeMapping__Group_5__0");
put(grammarAccess.getCompositeStateAccess().getGroup(), "rule__CompositeState__Group__0");
Expand Down Expand Up @@ -621,6 +623,8 @@ protected String getRuleName(AbstractElement element) {
put(grammarAccess.getErrorDetectionAccess().getConditionAssignment_3(), "rule__ErrorDetection__ConditionAssignment_3");
put(grammarAccess.getErrorDetectionAccess().getDetectionReportingPortAssignment_5(), "rule__ErrorDetection__DetectionReportingPortAssignment_5");
put(grammarAccess.getErrorDetectionAccess().getErrorCodeAssignment_7_1(), "rule__ErrorDetection__ErrorCodeAssignment_7_1");
put(grammarAccess.getReportingPortReferenceAccess().getElementAssignment_0(), "rule__ReportingPortReference__ElementAssignment_0");
put(grammarAccess.getReportingPortReferenceAccess().getElementAssignment_1_2(), "rule__ReportingPortReference__ElementAssignment_1_2");
put(grammarAccess.getErrorCodeValueAccess().getIntValueAssignment_0(), "rule__ErrorCodeValue__IntValueAssignment_0");
put(grammarAccess.getErrorCodeValueAccess().getConstantAssignment_1(), "rule__ErrorCodeValue__ConstantAssignment_1");
put(grammarAccess.getErrorCodeValueAccess().getEnumLiteralAssignment_2(), "rule__ErrorCodeValue__EnumLiteralAssignment_2");
Expand Down

0 comments on commit 39504e3

Please sign in to comment.