package Ġcom . test kn ight . checklist Generation Str ategies . leaf Str ategies . branch ing Statements Ċ Ċ import Ġcom . intellij . psi . Psi Switch Label Statement Ċ import Ġcom . intellij . psi . Psi Switch Labeled Rule Statement Ċ import Ġcom . intellij . psi . Psi Switch Statement Ċ import Ġcom . intellij . psi . util . Psi Tree Util Ċ import Ġcom . test kn ight . extensions . Test K night TestCase Ċ import Ġcom . test kn ight . models . testing Checklist . leaf Nodes . branch ing Statements . Switch Statement Checklist Node Ċ import Ġjunit . framework . TestCase Ċ import Ġorg . junit . Test Ċ Ċ internal Ġclass ĠSwitch Statement Checklist Generation Strategy Test Ġ: ĠTest K night TestCase () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġgeneration Strategy Ġ= ĠSwitch Statement Checklist Generation Strategy . create () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Simple Switch Statement () Ġ{ ĊĠĠĠĠĠĠĠ Ġget Basic Test Info ("/ Person . java ") ĊĊĠĠĠĠĠĠĠ Ġval Ġmethod Ġ= Ġget Method ByName (" comment On Age ") ĊĠĠĠĠĠĠĠ Ġval Ġswitch Ġ= ĠPsi Tree Util . find Child OfType ( method , ĠPsi Switch Statement :: class . java ) ĊĠĠĠĠĠĠĠ Ġval Ġswitch Labels Ġ= ĠPsi Tree Util . find Children OfType ( method , ĠPsi Switch Label Statement :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSwitch Statement Checklist Node (" Test Ġthis . age Ġis Ġ 1 0 ", Ġswitch Labels . elementAt ( 0 ) !! , Ġ" this . age ", Ġ" 1 0 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSwitch Statement Checklist Node (" Test Ġthis . age Ġis Ġ 2 0 ", Ġswitch Labels . elementAt ( 1 ) !! , Ġ" this . age ", Ġ" 2 0 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSwitch Statement Checklist Node (" Test Ġthis . age Ġis Ġ 3 0 ", Ġswitch Labels . elementAt ( 2 ) !! , Ġ" this . age ", Ġ" 3 0 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSwitch Statement Checklist Node (" Test Ġthis . age Ġis Ġ 4 0 ", Ġswitch Labels . elementAt ( 3 ) !! , Ġ" this . age ", Ġ" 4 0 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSwitch Statement Checklist Node ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Test Ġthis . age Ġis Ġdifferent Ġfrom Ġall Ġthe Ġswitch Ġcases ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġswitch Labels . elementAt ( 4 ) !! , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" this . age ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnull ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġactual Ġ= Ġgeneration Strategy . generate Checklist ( switch !! ) ĊĊĠĠĠĠĠĠĠ ĠTestCase . assertEquals ( expected , Ġactual ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Enhanced Switch Statement () Ġ{ ĊĠĠĠĠĠĠĠ Ġget Basic Test Info ("/ Person . java ") ĊĊĠĠĠĠĠĠĠ Ġval Ġmethod Ġ= Ġget Method ByName (" comment On Age En han ched ") ĊĠĠĠĠĠĠĠ Ġval Ġswitch Ġ= ĠPsi Tree Util . find Child OfType ( method , ĠPsi Switch Statement :: class . java ) ĊĠĠĠĠĠĠĠ Ġval Ġswitch Labels Ġ= ĠPsi Tree Util . find Children OfType ( method , ĠPsi Switch Label Statement :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSwitch Statement Checklist Node (" Test Ġthis . age Ġis Ġ 1 0 ", Ġswitch Labels . elementAt ( 0 ) !! , Ġ" this . age ", Ġ" 1 0 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSwitch Statement Checklist Node (" Test Ġthis . age Ġis Ġ 2 0 ", Ġswitch Labels . elementAt ( 0 ) !! , Ġ" this . age ", Ġ" 2 0 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSwitch Statement Checklist Node (" Test Ġthis . age Ġis Ġ 3 0 ", Ġswitch Labels . elementAt ( 1 ) !! , Ġ" this . age ", Ġ" 3 0 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSwitch Statement Checklist Node (" Test Ġthis . age Ġis Ġ 4 0 ", Ġswitch Labels . elementAt ( 2 ) !! , Ġ" this . age ", Ġ" 4 0 "), ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġactual Ġ= Ġgeneration Strategy . generate Checklist ( switch !! ) ĊĊĠĠĠĠĠĠĠ ĠTestCase . assertEquals ( expected , Ġactual ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Enhanced Switch Statement With Rules () Ġ{ ĊĠĠĠĠĠĠĠ Ġget Basic Test Info ("/ Person . java ") ĊĊĠĠĠĠĠĠĠ Ġval Ġmethod Ġ= Ġget Method ByName (" comment On Age En han ched With Rules ") ĊĠĠĠĠĠĠĠ Ġval Ġswitch Ġ= ĠPsi Tree Util . find Child OfType ( method , ĠPsi Switch Statement :: class . java ) ĊĠĠĠĠĠĠĠ Ġval Ġswitch Rules Ġ= ĠPsi Tree Util . find Children OfType ( method , ĠPsi Switch Labeled Rule Statement :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSwitch Statement Checklist Node (" Test Ġthis . age Ġis Ġ 1 0 ", Ġswitch Rules . elementAt ( 0 ) !! , Ġ" this . age ", Ġ" 1 0 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSwitch Statement Checklist Node (" Test Ġthis . age Ġis Ġ 2 0 ", Ġswitch Rules . elementAt ( 0 ) !! , Ġ" this . age ", Ġ" 2 0 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSwitch Statement Checklist Node (" Test Ġthis . age Ġis Ġ 3 0 ", Ġswitch Rules . elementAt ( 1 ) !! , Ġ" this . age ", Ġ" 3 0 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSwitch Statement Checklist Node (" Test Ġthis . age Ġis Ġ 4 0 ", Ġswitch Rules . elementAt ( 2 ) !! , Ġ" this . age ", Ġ" 4 0 "), ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġactual Ġ= Ġgeneration Strategy . generate Checklist ( switch !! ) ĊĊĠĠĠĠĠĠĠ ĠTestCase . assertEquals ( expected , Ġactual ) ĊĠĠĠ Ġ} Ċ } Ċ