package Ġchat . wil low . war ren . event . internal Ċ Ċ import Ġcom . n ha ar man . mockito _ kotlin . any Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġcom . n ha ar man . mockito _ kotlin . wh enever Ċ import Ġchat . wil low . k ale . IK ale Ċ import Ġchat . wil low . war ren . IL ine Source Ċ import Ġchat . wil low . war ren . event . I War ren EventDispatcher Ċ import Ġchat . wil low . war ren . event . Raw Incoming Line Event Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Mockito . never Ċ import Ġorg . mockito . Mockito . verify Ċ Ċ class ĠNew Line War ren Event Generator Tests Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġsut : ĠNew Line War ren Event Generator ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Queue : ĠI War ren Internal EventQueue ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock K ale : ĠIK ale ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Line Source : ĠI Line Source ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock War ren EventDispatcher : ĠI War ren EventDispatcher ĊĊĠĠĠ Ġ@ Before Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Queue Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġmock K ale Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġmock Line Source Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġmock War ren EventDispatcher Ġ= Ġmock () ĊĊĠĠĠĠĠĠĠ Ġsut Ġ= ĠNew Line War ren Event Generator ( mock Queue , Ġmock K ale , Ġmock Line Source , Ġtrue , Ġmock War ren EventDispatcher ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test Ġfun Ġtest _ run _ Line Available _ Adds NewLine Event To Queue () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġline Ġ= Ġ"" ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Line Source . nextLine ()). thenReturn ( line ). thenReturn ( null ) ĊĊĠĠĠĠĠĠĠ Ġsut . run () ĊĊĠĠĠĠĠĠĠ Ġverify ( mock Queue ). add ( NewLine Event ( line , Ġmock K ale )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test Ġfun Ġtest _ run _ Line Not Available _ Does Nothing With Queue () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Line Source . nextLine ()). thenReturn ( null ) ĊĊĠĠĠĠĠĠĠ Ġsut . run () ĊĊĠĠĠĠĠĠĠ Ġverify ( mock Queue , Ġnever ()). add ( any < I War ren Internal Event >()) ĊĠĠĠĠĠĠĠ Ġverify ( mock Queue , Ġnever ()). add ( any < () Ġ-> ĠUnit >()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test Ġfun Ġtest _ run _ Fire Incoming Line Event _ EventDispatcher F ires Correct Event () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġline Ġ= Ġ" test Ġline " ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Line Source . nextLine ()). thenReturn ( line ). thenReturn ( null ) ĊĊĠĠĠĠĠĠĠ Ġsut . run () ĊĊĠĠĠĠĠĠĠ Ġverify ( mock War ren EventDispatcher ). fire ( Raw Incoming Line Event ( line )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test Ġfun Ġtest _ run _ Dont Fire Incoming Line Event _ EventDispatcher F ires Correct Event () Ġ{ ĊĠĠĠĠĠĠĠ Ġsut Ġ= ĠNew Line War ren Event Generator ( mock Queue , Ġmock K ale , Ġmock Line Source , Ġfalse , Ġmock War ren EventDispatcher ) ĊĠĠĠĠĠĠĠ Ġval Ġline Ġ= Ġ" test Ġline " ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Line Source . nextLine ()). thenReturn ( line ). thenReturn ( null ) ĊĊĠĠĠĠĠĠĠ Ġsut . run () ĊĊĠĠĠĠĠĠĠ Ġverify ( mock War ren EventDispatcher , Ġnever ()). fire ( Raw Incoming Line Event ( line )) ĊĠĠĠ Ġ} Ċ Ċ }