package Ġcom . github . ch ristop h pick l . k pot p our ri . common . process Ċ Ċ import Ġcom . github . ch ristop h pick l . k pot p our ri . common . KP otp our ri Exception Ċ import Ġcom . github . ch ristop h pick l . k pot p our ri . common . io . Io Ċ import Ġcom . github . ch ristop h pick l . k pot p our ri . test 4 k . assert Thrown Ċ import Ġcom . github . ch ristop h pick l . k pot p our ri . test 4 k . ham k rest _ matcher . contains Sub strings Ċ import Ġcom . nat pr y ce . ham k rest . assertion . assertThat Ċ import Ġcom . nat pr y ce . ham k rest . equalTo Ċ import Ġcom . nat pr y ce . ham k rest . isEmpty Ċ import Ġorg . testng . annotations . Test Ċ import Ġjava . io . IOException Ċ Ċ @ Test Ġclass ĠProcess Executer Impl Test Ġ{ ĊĊĠĠĠ Ġfun Ġ` execute Ġ- Ġecho Ġwith Ġargument Ġfoo , ĠShould Ġstdout Ġcont aint Ġecho Ġand Ġfoo `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġstdout Ġ= ĠIo . read From Std Out Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġreturn Code Ġ= ĠProcess Executer Impl . execute (" echo ", ĠlistOf (" Process Executer Impl Test ")) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( return Code , ĠequalTo ( 0 )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertThat ( stdout , Ġcontains Sub strings (" echo ", Ġ" Process Executer Impl Test ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġ` execute Ġ- Ġwhen Ġoutput Ġsupp ressed , ĠThen Ġshould Ġbe Ġempty `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġstdout Ġ= ĠIo . read From Std Out Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġreturn Code Ġ= ĠProcess Executer Impl . execute (" echo ", ĠlistOf (" foo "), ĠExecute Context ( suppress Output Ġ= Ġtrue )) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( return Code , ĠequalTo ( 0 )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĊĠĠĠĠĠĠĠ Ġval Ġstdout Without Log Ġ= Ġstdout . lines (). filter Ġ{ Ġ! it . contains ("[ TEST LOG ]") Ġ&& Ġ! it . isEmpty () Ġ} ĊĠĠĠĠĠĠĠ ĠassertThat ( stdout Without Log , ĠisEmpty ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġ` execute Ġ- Ġinvalid Ġcommand Ġshould Ġfail `() Ġ{ ĊĠĠĠĠĠĠĠ Ġassert Thrown < IOException >( expected Message Parts Ġ= ĠlistOf (" not _ valid ")) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠProcess Executer Impl . execute OrThrow (" not _ valid ", ĠlistOf ("")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġ` execute Ġ- Ġcommand Ġwhich Ġfails Ġshould Ġfail `() Ġ{ ĊĠĠĠĠĠĠĠ Ġassert Thrown < KP otp our ri Exception >( expected Message Parts Ġ= ĠlistOf (" Process Executer Impl Test ")) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠProcess Executer Impl . execute OrThrow (" ls ", ĠlistOf (" Process Executer Impl Test ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ } Ċ