use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class TreeNamingServiceTest method statechartNamingBaseTest.
@Test
public void statechartNamingBaseTest() {
Statechart toTest = getNamingServiceStatechart();
List<String> names = new ArrayList<>();
List<String> expectedNames = new ArrayList<>(Arrays.asList("main_region_StateA", "main_region_StateB", "second_region_StateA", "third_region_StateA", "second_region_StateA_AnotherRegion_StateA", "second_region_StateA_AnotherRegion_StateB", "third_region_StateA_AnotherRegion_StateA", "third_region_StateA_AnotherRegion_StateB"));
ExecutionFlow flow = optimizer.transform(sequencer.transform(toTest));
executionflowNamingService.setMaxLength(0);
executionflowNamingService.setSeparator('_');
executionflowNamingService.initializeNamingService(flow);
statechartNamingService.setMaxLength(0);
statechartNamingService.setSeparator('_');
statechartNamingService.initializeNamingService(toTest);
for (ExecutionState state : flow.getStates()) {
String name = executionflowNamingService.getShortName(state);
assertEquals(names.contains(name), false);
assertEquals(name, statechartNamingService.getShortName(state));
names.add(name);
}
stringListsEqual(expectedNames, names);
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class TreeNamingServiceTest method testDefaultNamingServiceState_NoDoubles.
@Test
public void testDefaultNamingServiceState_NoDoubles() {
for (Statechart statechart : statecharts) {
// Transform statechart
ExecutionFlow flow = sequencer.transform(statechart);
flow = optimizer.transform(flow);
List<String> names = new ArrayList<>();
executionflowNamingService.setMaxLength(15);
executionflowNamingService.setSeparator('_');
// Initialize naming services for statechart and ExecutionFlow
executionflowNamingService.initializeNamingService(flow);
for (ExecutionState state : flow.getStates()) {
String name = executionflowNamingService.getShortName(state);
assertEquals(names.contains(name), false);
names.add(name);
}
}
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class TreeNamingServiceTest method optimizerCombinationsTest.
@Test
public void optimizerCombinationsTest() {
Statechart toTest = null;
for (Statechart statechart : statecharts) {
if (statechart.getName().equals("DeepEntry")) {
toTest = statechart;
}
}
assertEquals(true, toTest != null);
ExecutionFlow flow = sequencer.transform(toTest);
executionflowNamingService.setMaxLength(0);
executionflowNamingService.setSeparator('_');
for (int i = 0; i < (1 << 9); i++) {
optimizer.inlineReactions((i & (1)) != 0);
optimizer.inlineExitActions((i & (1 << 1)) != 0);
optimizer.inlineEntryActions((i & (1 << 2)) != 0);
optimizer.inlineEnterSequences((i & (1 << 3)) != 0);
optimizer.inlineExitSequences((i & (1 << 4)) != 0);
optimizer.inlineChoices((i & (1 << 5)) != 0);
optimizer.inlineEntries((i & (1 << 6)) != 0);
optimizer.inlineEnterRegion((i & (1 << 7)) != 0);
optimizer.inlineExitRegion((i & (1 << 8)) != 0);
ExecutionFlow optimizedflow = optimizer.transform(flow);
List<String> names = new ArrayList<>();
executionflowNamingService.initializeNamingService(optimizedflow);
for (ExecutionState state : flow.getStates()) {
String name = executionflowNamingService.getShortName(state);
assertEquals(names.contains(name), false);
names.add(name);
}
}
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class TreeNamingServiceTest method nameLengthTest.
private void nameLengthTest(int maxLength) {
int num_statecharts = statecharts.size();
long cumulated_time = 0L;
for (Statechart statechart : statecharts) {
// Transform statechart
ExecutionFlow flow = sequencer.transform(statechart);
flow = optimizer.transform(flow);
List<String> names = new ArrayList<>();
executionflowNamingService.setMaxLength(maxLength);
executionflowNamingService.setSeparator('_');
long t0 = System.currentTimeMillis();
executionflowNamingService.initializeNamingService(flow);
cumulated_time += System.currentTimeMillis() - t0;
for (ExecutionState state : flow.getStates()) {
String name = executionflowNamingService.getShortName(state);
assertEquals(names.contains(name), false);
assertEquals(true, name.length() <= maxLength);
names.add(name);
}
}
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class TreeNamingServiceTest method getNamingServiceStatechart.
private Statechart getNamingServiceStatechart() {
Statechart toTest = null;
for (Statechart statechart : statecharts) {
if (statechart.getName().equals("namingTest")) {
toTest = statechart;
}
}
assertEquals(true, toTest != null);
return toTest;
}
Aggregations