h1. YAKINDU Statechart Tools – Testcase 12 - Refactoring |_. Nr |_. Testname |_. Test Instructions |_. Postconditions |_. Status| | 12.1 | Group states into composite |
  1. Select all states.

  2. Right-click on one of the states, then select _Refactor → Group States Into Composite_.

  3. Rename the new composite state to *LightSwitch*.

| No errors occured. The states are wrapped in a composite state named *LightSwitch*. | %{color:red}open% | | 12.1.1 | Simulate |
  1. Save the statechart.

  2. Run the simulation.

| The behavior of the refactored model is equivalent to its behavior before refactoring. The composite state *LightSwitch* is active and highlighted (yellow). | %{color:red}open% | | 12.2 | Extract subdiagram |
  1. Right-click on the edge or on the title area of the *LightSwitch* composite state.

  2. In the context menu, select _Refactor → Extract Subdiagram_.

  3. Hover over the subdiagram decorator in the lower-right corner of the *LightSwitch* state.

  4. Click on the subdiagram decorator.

| No errors occur.

Subdiagram extraction leads to a normal-looking *LightSwitch* state, but with a subdiagram decorator in the lower left of state's box.

Hovering over that decorator shows a preview image of the subdiagram.

Clicking the decorator opens the subdiagram in a new editor tab.

| %{color:red}open% | | 12.2.1 | Undo & redo extracting subdiagram |
  1. Undo extraction by [Ctrl+Z].

  2. Redo extraction by [Ctrl+Y].

| The subdiagram extraction is reverted by [Ctrl+Z] and properly applied again by [Ctrl+Y].| %{color:red}open% | | 12.2.2 | Copy state with subdiagram |
  1. Select the subdiagram-containing composite state *LightSwitch*.

  2. Copy it to the clipboard using [Ctrl+C] resp. [Cmd+C] (Mac).

  3. Select the main region.

  4. Paste the copied state using [Ctrl+V] resp. [Cmd+V] (Mac).

  5. Hover over the subdiagram decorator in the lower-right corner of the *Copy_1_LightSwitch* state.

  6. Click on the subdiagram decorator.

|

The copied state's name is *Copy_1_LightSwitch*.

Hovering over the decorator of the copied state shows a preview image of the subdiagram.

Clicking on the decorator of the copied state opens the subdiagram in a new editor tab.

| %{color:red}open% | | 12.2.3 | Delete copy |
  1. Delete the previously created state *Copy_1_LightSwitch*.

  2. Save the statechart.

| No errors occured. | %{color:red}open% | | 12.2.4 | Simulate |
  1. Run the simulation.

| The behavior of the refactored model is equivalent to its behavior before refactoring. The *LightSwitch* state is highlighted. Transitions between *LightOff* and *LightOn* can be observed in the subdiagram editor tab mentioned in T12.2. | %{color:red}open% | | 12.3 | Inline subdiagram |
  1. Right-click on the edge or on the title area of the *LightSwitch* composite state.

  2. In the context menu, select _Refactor → Inline Subdiagram_.

| Same as in T12.1. | %{color:red}open% | | 12.3.1 | Simulate |
  1. Save the statechart.

  2. Run the simulation.

| The behavior of the refactored model is equivalent to its behavior before refactoring. | %{color:red}open% | | 12.4 | Prepare statechart |
  1. Delete the transition from *LightOn* to *LightOff*.

  2. Delete the local reactions of both states *LightOn* and *LightOff*.

  3. Create a second transition from *LightOff* to *LightOn*.

  4. Enter "@A.keypress / light = true@" as reaction for _both_ transitions from *LightOff* to *LightOn*.

| No error occurred. | %{color:red}open% | | 12.5 | Fold incoming actions |
  1. Right-click on the edge or on the title area of the *LightOn* state.

  2. Select _Refactoring → Fold Incoming Actions_.

| | %{color:red}open% | | 12.6 | Unfold entry actions |
  1. Right-click on the edge or on the title area of the *LightOn* state.

  2. Select _Refactoring → Unfold Entry Actions_.

| | %{color:red}open% | | 12.7 | Fold outgoing actions |
  1. Right-click on the edge or on the title area of the *LightOff* state.

  2. Select _Refactoring → Fold Outgoing Actions_.

| | %{color:red}open% | | 12.8 | Unfold exit actions |
  1. Right-click on the edge or on the title area of the *LightOff* state.

  2. Select _Refactoring → Unfold Exit Actions_.

| | %{color:red}open% | | 12.9 | Renaming |
  1. Double-click into the statechart's definition section.

  2. Right-click on the name of the _light_ variable declaration.

  3. In the context menu, select _Refactoring → Rename…_

  4. In the dialog box, enter "@lamp@" as the variable's new name.

  5. Click on _OK_.

| All occurrences of the variable name _light_ are replaced by _lamp_. | %{color:red}open% | | 12.10 | Disabled menu item |
  1. In one of the two transactions from *LightOff* to *LightOn*, change the reaction to "@A.keypress / lamp = false@". The reaction of the other transition remains at "@A.keypress / lamp = true@".

  2. Right-click on the edge or on the title area of the *LightOn* state.

| In the submenu of the context menu's _Refactor_ entry, the _Fold Incoming Action_ entry is disabled. | %{color:red}open% | | 12.11 | Disabled menu item |
  1. Right-click on the edge or on the title area of the *LightOff* state.

| In the submenu of the context menu's _Refactor_ entry, the _Fold Outgoing Action_ entry is disabled. | %{color:red}open% | | 12.12 | Toggle alignment |
  1. Create a new statechart model.

  2. Delete the *StateA* state that has been created.

  3. Add an orthogonal state (see the palette on the right).

  4. Ignore any errors.

  5. Right-click on the orthogonal state.

  6. In the context menu, select _Toggle Subregion Alignment_.

  7. Repeat the last action.

| | %{color:red}open% |