h1(#Test2). Yakindu SCT Testcase 11 - Operations

|_. Nr |_. Testname |_. Test Instructions |_. Postconditions |_. Status|
| 11.1 | Preparations | In the src folder, create a new Java source file Operations.java with following contents:<p>&emsp;@import java.io.IOException;@<br>&emsp;@public class Operations {@<p>&emsp;&emsp;@public long returnFive() {@<br>&emsp;&emsp;@return 5;@<br>&emsp;&emsp;@}@<p>&emsp;&emsp;@public long returnPlusFive(long i) {@<br>&emsp;&emsp;@return i+returnFive();@<br>&emsp;&emsp;@}@<p>&emsp;&emsp;@public long returnSum(long i, double d) {@<br>&emsp;&emsp;@return (long) (i + d);@<br>&emsp;&emsp;@}@<p>&emsp;&emsp;@public void throwUncheckedException() {@<br>&emsp;&emsp;@throw new RuntimeException("Runtime Exception in executed code");@<br>&emsp;&emsp;@}@<p>&emsp;&emsp;@public void throwCheckedException() throws IOException {@<br>&emsp;&emsp;@throw new IOException("IOException in executed code");@<br>&emsp;&emsp;@}@<br>&emsp;@}@<p>Right click on Staircase.sct.</p><p>In the context menu, select *Run as... → Run Configurations*.</p><p>In the Staircase run configuration, enter Operations as operation class.</p><p>Click *Apply*.</p><p>Click *Close*.</p><br></br><p>Open Staircase.sct and add the following to the internal scope:</p><p>&emsp;@operation returnFive():integer@<br>&emsp;@operation returnSum(param1 : integer, param2 : real ):integer@<br>&emsp;@operation returnPlusFive(param1 : integer) : integer@<br>&emsp;@operation throwUncheckedException(): void@<br>&emsp;@operation throwCheckedException():void@<br>&emsp;@operation unsupportedMethod():void@ | There are no error markers in the project. There are five warnings "Internal declaration is not used in statechart". | %{color:red}open% |
| 11.2 | Check operation proposals | Open Staircase.sct.<p>Edit transition from LightOn to LightOff and write "@/@".</p><p>Press CTRL + SPACE</p> <p>Choose & insert proposals</p><p>&emsp;"@returnFive():integer@"</p> <p>&emsp;"@returnPlusFive(param1:integer):integer@"</p><p>&emsp;"@returnSum(param1 : integer, param2 : real ):integer@"</p>| <p>Choosing the proposals result in the following insertions</p><p>&emsp;"@returnFive@"</p><p>&emsp;"@returnPlusFive()@" AND cursor between brackets</p><p>&emsp;"@returnSum()@" AND cursor between brackets</p> | %{color:red}open% |
| 11.3 | Calling a valid operation during statechat execution | Open Staircase.sct.<p>Edit transition from LightOn to LightOff and change the expression to <br>"@after returnFive() s@".</p><p>Run simulation.</p><p>Click keypress to transition to state LightOn.</p> | After 5 seconds the state transitions from LightOn to LightOff. | %{color:red}open% |
| 11.4 | CheckedException during execution | Open Staircase.sct.<p>Edit state LightOn.</p><p>Change expression to <br>"@entry / throwCheckedException()@".</p><p>Run simulation.</p><p>Click keypress to transition to state LightOn.</p> | A popup method informs the user that a IOException has occurred in the executed code and offers to relaunch or terminate the simulation. | %{color:red}open% |
| 11.5 | UncheckedException during execution | Open Staircase.sct.<p>Edit state LightOn.</p><p>Change expression to <br>"@entry / throwUncheckedException()@".</p><p>Run simulation.</p><p>Click keypress to transition to state LightOn.</p> | A popup method informs the user that a RuntimeException has occurred in the executed code and offers to relaunch or terminate the simulation. | %{color:red}open% |
| 11.6 | Calling invalid operation | Open Staircase.sct.<p>Edit transition from LightOn to LightOff and change the expression to <br>"@after returnFive s@", i.e. without the brackets.</p><p>Run simulation.</p><p>Click keypress to transition to state LightOn.</p> | After 5 seconds the state transitions from LightOn to LightOff. | %{color:red}open% |
| 11.7 | Calling another valid operation during statechat execution | Open Staircase.sct.<p>Edit transition from LightOn to LightOff and change the expression to <br>"@after returnSum(1, 4.1) s@".</p><p>Run simulation.</p><p>Click keypress to transition to state LightOn.</p> | After 5 seconds the state transitions from LightOn to LightOff. | %{color:red}open% |


