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);
}
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);
}
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);
}
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");
}
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");
}
Aggregations