package Ġcom . github . k 0 z ka . finder 4 j . back track Ċ Ċ import Ġcom . n ha ar man . mockito _ kotlin . any Ċ import Ġcom . n ha ar man . mockito _ kotlin . eq Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġcom . n ha ar man . mockito _ kotlin . never Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify Ċ import Ġcom . n ha ar man . mockito _ kotlin . wh enever Ċ import Ġorg . junit . Test Ċ Ċ class ĠBack track Test Ġ{ ĊĊ ĉ private Ġvar Ġstate : ĠState Ġ= Ġmock () ĊĊ ĉ private Ġvar Ġend State : ĠState Ġ= Ġmock () ĊĊ ĉ private Ġvar Ġcomplete State : ĠState Ġ= Ġmock () ĊĊ ĉ private Ġvar Ġstep Factory : ĠStep Factory < Step < State >, ĠState > Ġ= Ġmock () ĊĊ ĉ private Ġvar Ġtermination Strategy : ĠTermin ation Strategy < State > Ġ= Ġmock () ĊĊ ĉ private Ġvar Ġlistener : ĠSolution Listener < State > Ġ= Ġmock () ĊĊ ĉ private Ġvar Ġstep : ĠStep < State > Ġ= Ġmock () ĊĊ ĉ @ Test Ċ ĉ fun Ġback track N os olution Short () Ġ{ Ċĉ ĉ wh enever ( termination Strategy . stop ( any ())) Ċĉĉĉ ĉ . thenReturn ( false ) Ċĉ ĉ wh enever ( step Factory . produce ( any ())) Ċĉĉĉ ĉ . thenReturn ( listOf ()) Ċĉ ĉ Back track . back track ( state , Ġstep Factory , Ġtermination Strategy , Ġlistener ) Ċĉ ĉ verify ( listener , Ġnever ()). on Solution ( Ċĉĉĉ ĉ any ()) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġback track Single Step To Complete () Ġ{ Ċĉ ĉ wh enever ( termination Strategy . stop ( eq ( state ))). thenReturn ( false ) Ċĉ ĉ wh enever ( termination Strategy . stop ( eq ( complete State ))). thenReturn ( true ) Ċĉ ĉ wh enever ( complete State . complete ). thenReturn ( true ) Ċĉ ĉ wh enever ( step Factory . produce ( eq ( state ))). thenReturn ( listOf ( step )) Ċĉ ĉ wh enever ( step . take ( eq ( state ))). thenReturn ( complete State ) Ċĉ ĉ Back track . back track ( state , Ġstep Factory , Ġtermination Strategy , Ġlistener ) Ċĉ ĉ verify ( listener , Ġnever ()). on Solution ( state ) Ċĉ ĉ verify ( listener ). on Solution ( complete State ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġback track Single Step Dead End () Ġ{ Ċĉ ĉ wh enever ( termination Strategy . stop ( any ())). thenReturn ( false ) Ċĉ ĉ wh enever ( step Factory . produce ( eq ( state ))). thenReturn ( listOf ( step )) Ċĉ ĉ wh enever ( step . take ( eq ( state ))). thenReturn ( end State ) Ċĉ ĉ Back track . back track ( state , Ġstep Factory , Ġtermination Strategy , Ġlistener ) Ċĉ ĉ verify ( step ). take ( state ) Ċĉ ĉ verify ( listener , Ġnever ()). on Solution ( Ċĉĉĉ ĉ any ()) Ċ ĉ } Ċ Ċ } Ċ