Search in sources :

Example 46 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class TreeNamingServiceTest method setupNamingService.

@Before
public void setupNamingService() {
    statecharts = Collections.emptyList();
    try {
        statecharts = testModels.loadAllStatecharts();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    optimizer.inlineReactions(false);
    optimizer.inlineExitActions(false);
    optimizer.inlineEntryActions(true);
    optimizer.inlineEnterSequences(true);
    optimizer.inlineExitSequences(true);
    optimizer.inlineChoices(true);
    optimizer.inlineEntries(true);
    optimizer.inlineEnterRegion(true);
    optimizer.inlineExitRegion(true);
    // TODO: Why does PerformanceTest doesn't work?
    Statechart statecharttoRemove = null;
    for (Statechart sct : statecharts) {
        if (sct.getName().equals("PerformanceTest")) {
            statecharttoRemove = sct;
        }
    }
    statecharts.remove(statecharttoRemove);
}
Also used : Statechart(org.yakindu.sct.model.sgraph.Statechart) Before(org.junit.Before)

Example 47 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class TreeNamingServiceTest method statechartNamingRegressionTest.

/*
	 * This test will fail if any details of the naming algorithm are changed.
	 * It is safe to change these names to the new ones if the changes were
	 * expected.
	 */
@Test
public void statechartNamingRegressionTest() {
    Statechart toTest = getNamingServiceStatechart();
    List<String> names = new ArrayList<>();
    // these names are shorter than 15 characters because there are more
    // elements containing these names, e.g. state actions
    List<String> expectedNames = new ArrayList<>(Arrays.asList("mgn_SA", "mgn_StteB", "s_SA", "t_SA", "t_SA_AR_SA", "t_SA_AR_StB", "s_SA_AR_SA", "s_SA_AR_StB"));
    ExecutionFlow flow = optimizer.transform(sequencer.transform(toTest));
    executionflowNamingService.setMaxLength(15);
    executionflowNamingService.setSeparator('_');
    executionflowNamingService.initializeNamingService(flow);
    for (ExecutionState state : flow.getStates()) {
        String name = executionflowNamingService.getShortName(state);
        assertEquals(names.contains(name), false);
        names.add(name);
    }
    stringListsEqual(expectedNames, names);
}
Also used : ExecutionState(org.yakindu.sct.model.sexec.ExecutionState) ArrayList(java.util.ArrayList) ExecutionFlow(org.yakindu.sct.model.sexec.ExecutionFlow) Statechart(org.yakindu.sct.model.sgraph.Statechart) Test(org.junit.Test)

Example 48 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class ViewBasedRefactoringTest method testRefactoring.

protected void testRefactoring(String pathToInitialSct, String pathToExpectedSct, String contextElementName) {
    Statechart initial = models.loadStatechartFromResource(pathToInitialSct);
    TransactionalEditingDomainImpl.FactoryImpl.INSTANCE.createEditingDomain(initial.eResource().getResourceSet());
    View contextView = getViewForState(initial, contextElementName);
    AbstractRefactoring<View> refactoring = getRefactoring();
    refactoring.setContextObjects(Collections.singletonList(contextView));
    AbstractSCTResource initialRes = (AbstractSCTResource) initial.eResource();
    initialRes.setSerializerEnabled(true);
    refactoring.execute();
    initialRes.setSerializerEnabled(false);
    Statechart expected = models.loadStatechartFromResource(pathToExpectedSct);
    compareStatecharts(initial, expected);
}
Also used : AbstractSCTResource(org.yakindu.sct.model.sgraph.resource.AbstractSCTResource) Statechart(org.yakindu.sct.model.sgraph.Statechart) View(org.eclipse.gmf.runtime.notation.View)

Example 49 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class RenameRefactoringTest method testRenameMultiStatement.

@Test
public void testRenameMultiStatement() {
    Statechart initial = models.loadStatechartFromResource(RENAMING + "beforeMultiStatement.sct");
    Statechart expected = models.loadStatechartFromResource(RENAMING + "AfterMultiStatement.sct");
    // get element to rename
    InterfaceScope someInterface = null;
    EList<Scope> scopes = initial.getScopes();
    for (Scope scope : scopes) {
        if (scope instanceof InterfaceScope) {
            someInterface = (InterfaceScope) scope;
        }
    }
    testRenaming(initial, expected, someInterface.getVariables().get(0), "y");
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Statechart(org.yakindu.sct.model.sgraph.Statechart) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Test(org.junit.Test) RefactoringTest(org.yakindu.sct.refactoring.refactor.RefactoringTest)

Example 50 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class RenameRefactoringTest method testRenameEvent.

@Test
public void testRenameEvent() {
    Statechart initial = models.loadStatechartFromResource(RENAMING + INITIAL_STATECHART);
    Statechart expected = models.loadStatechartFromResource(RENAMING + "AfterRenamingEvent.sct");
    // get element to rename
    Event someEvent1 = null;
    EList<Scope> scopes = initial.getScopes();
    for (Scope scope : scopes) {
        if (scope instanceof InterfaceScope) {
            InterfaceScope iScope = (InterfaceScope) scope;
            for (Event event : iScope.getEvents()) {
                if (event.getName().equals("someEvent1")) {
                    someEvent1 = event;
                }
            }
        }
    }
    testRenaming(initial, expected, someEvent1, "someNewEventName");
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Statechart(org.yakindu.sct.model.sgraph.Statechart) Event(org.yakindu.base.types.Event) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Test(org.junit.Test) RefactoringTest(org.yakindu.sct.refactoring.refactor.RefactoringTest)

Aggregations

Statechart (org.yakindu.sct.model.sgraph.Statechart)132 Test (org.junit.Test)89 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)65 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)63 Region (org.yakindu.sct.model.sgraph.Region)59 State (org.yakindu.sct.model.sgraph.State)59 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)57 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)57 SGraphTestFactory._createState (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState)51 VariableDefinition (org.yakindu.sct.model.stext.stext.VariableDefinition)48 StextTestFactory._createInterfaceScope (org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope)48 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)47 StextTestFactory._createVariableDefinition (org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition)47 Sequence (org.yakindu.sct.model.sexec.Sequence)40 Entry (org.yakindu.sct.model.sgraph.Entry)30 SCTTestUtil.findState (org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.findState)29 SGraphTestFactory._createEntry (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createEntry)29 Reaction (org.yakindu.sct.model.sexec.Reaction)25 Scope (org.yakindu.sct.model.sgraph.Scope)25 EnterState (org.yakindu.sct.model.sexec.EnterState)21