package Ġdev . vin ays he tty . state art . builder Ċ Ċ import Ġdev . vin ays he tty . state art . state machine builder . StateMachine Builder Ċ import Ġdev . vin ays he tty . state art . state machine builder . StateMachine Builder Impl Ċ import Ġorg . hamcrest . Core Matchers . equalTo Ċ import Ġorg . hamcrest . Matcher Assert . assertThat Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ Ċ internal Ġclass ĠState Machine Builder Impl Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġstate Machine Builder : ĠState Machine Builder ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġstate Machine Builder Ġ= ĠState Machine Builder Impl () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` state Ġmachine Ġwith Ġmultiple ĠStates `() Ġ{ ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add State (" solid ") ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add State (" liquid ") ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add State (" gas ") ĊĠĠĠĠĠĠĠ Ġval Ġstate Machine Ġ= Ġstate Machine Builder . build () ĊĠĠĠĠĠĠĠ ĠassertThat ( state Machine . states . size , ĠequalTo ( 3 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( state Machine . states . toList ()[ 0 ]. name , ĠequalTo (" solid ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( state Machine . states . toList ()[ 1 ]. name , ĠequalTo (" liquid ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( state Machine . states . toList ()[ 2 ]. name , ĠequalTo (" gas ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` empty ĠState Ġmachine `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġstate Machine Ġ= Ġstate Machine Builder . build () ĊĠĠĠĠĠĠĠ ĠassertThat ( state Machine . states . size , ĠequalTo ( 0 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` events Ġwithout Ġtransitions Ġhas Ġno Ġeffect Ġon Ġstate Ġmachine `() Ġ{ ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add State (" solid ") ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add Event (" me lt ") ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add Event (" v apor ize ") ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add Event (" cond ense ") ĊĠĠĠĠĠĠĠ Ġval Ġstate Machine Ġ= Ġstate Machine Builder . build () ĊĠĠĠĠĠĠĠ ĠassertThat ( state Machine . states . size , ĠequalTo ( 1 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( state Machine . states . toList ()[ 0 ]. name , ĠequalTo (" solid ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( state Machine . states . toList ()[ 0 ]. transitions . size , ĠequalTo ( 0 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` adding Ġtransitions Ġwithout Ġcurrent Ġevent Ġhas Ġno Ġeffect Ġon Ġstate Ġmachine `() Ġ{ ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add Transition To State (" liquid ") ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add Transition To State (" gas ") ĊĠĠĠĠĠĠĠ Ġval Ġstate Machine Ġ= Ġstate Machine Builder . build () ĊĠĠĠĠĠĠĠ ĠassertThat ( state Machine . states . size , ĠequalTo ( 0 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Transitions Ġare Ġadded Ġto Ġcurrent Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add State (" solid ") ĊĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add Event (" me lt ") ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add Transition To State (" liquid ") ĊĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add Event (" v apor ize ") ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add Transition To State (" gas ") ĊĊĠĠĠĠĠĠĠ Ġval Ġstate Machine Ġ= Ġstate Machine Builder . build () ĊĊĠĠĠĠĠĠĠ ĠassertThat ( state Machine . states . size , ĠequalTo ( 1 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( state Machine . states . toList ()[ 0 ]. name , ĠequalTo (" solid ")) ĊĠĠĠĠĠĠĠ Ġval Ġtransitions Ġ= Ġstate Machine . states . toList ()[ 0 ]. transitions . toList () ĊĠĠĠĠĠĠĠ ĠassertThat ( transitions . size , ĠequalTo ( 2 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( transitions [ 0 ]. event . eventName , ĠequalTo (" me lt ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( transitions [ 0 ]. next State , ĠequalTo (" liquid ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( transitions [ 1 ]. event . eventName , ĠequalTo (" v apor ize ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( transitions [ 1 ]. next State , ĠequalTo (" gas ")) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` add No Transition Ġis Ġtransition Ġwithin Ġsame Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add State (" solid ") ĊĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add Event (" freeze ") ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add No Transition () ĊĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add Event (" cool Ġdown ") ĊĠĠĠĠĠĠĠ Ġstate Machine Builder . add No Transition () ĊĊĠĠĠĠĠĠĠ Ġval Ġstate Machine Ġ= Ġstate Machine Builder . build () ĊĊĠĠĠĠĠĠĠ ĠassertThat ( state Machine . states . size , ĠequalTo ( 1 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( state Machine . states . toList ()[ 0 ]. name , ĠequalTo (" solid ")) ĊĠĠĠĠĠĠĠ Ġval Ġtransitions Ġ= Ġstate Machine . states . toList ()[ 0 ]. transitions . toList () ĊĠĠĠĠĠĠĠ ĠassertThat ( transitions . size , ĠequalTo ( 2 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( transitions [ 0 ]. event . eventName , ĠequalTo (" freeze ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( transitions [ 0 ]. next State , ĠequalTo (" solid ")) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( transitions [ 1 ]. event . eventName , ĠequalTo (" cool Ġdown ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( transitions [ 1 ]. next State , ĠequalTo (" solid ")) ĊĠĠĠ Ġ} Ċ }