package Ġnet . l ach lan m ck ee . fl ank ci . runner . domain . inter actor Ċ Ċ import Ġio . ktor . application .* Ċ import Ġio . ktor . response .* Ċ import Ġio . mock k .* Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġnet . l ach lan m ck ee . fl ank ci . core . data . datasource . remote . CI DataSource Ċ import Ġnet . l ach lan m ck ee . fl ank ci . core . data . entity . Build Type Ċ import Ġnet . l ach lan m ck ee . fl ank ci . core . data . entity . Build s Data Ċ import Ġnet . l ach lan m ck ee . fl ank ci . core . data . entity . Configuration Id Ċ import Ġnet . l ach lan m ck ee . fl ank ci . core . domain . mapper . Build s Mapper Ċ import Ġorg . junit . jupiter . api . After Each Ċ import Ġorg . junit . jupiter . api . Test Ċ Ċ class ĠTrigger Branches Interactor Test Ġ{ ĊĠ Ġprivate Ġval Ġci DataSource : ĠCI DataSource Ġ= Ġmock k () ĊĠ Ġprivate Ġval Ġbuilds Mapper : ĠBuilds Mapper Ġ= Ġmock k () ĊĠ Ġprivate Ġval Ġinter actor Ġ= ĠTrigger Branches Interactor ( ĊĠĠĠ Ġci DataSource , ĊĠĠĠ Ġbuilds Mapper ĊĠ Ġ) ĊĊĠ Ġprivate Ġval Ġapplication Call : ĠApplication Call Ġ= Ġmock k () ĊĊĠ Ġ@ After Each ĊĠ Ġfun Ġverify No More Interactions () Ġ{ ĊĠĠĠ Ġconfirm Verified ( ci DataSource , Ġbuilds Mapper , Ġapplication Call ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġgiven Get Build s Success And Mapping Success _ when Execute _ then Respond () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġco Every Ġ{ Ġci DataSource . get Build s ( Configuration Id (" config - id "), ĠBuild Type . AP K _ SOURCE ) Ġ} Ġreturns ĠResult . success ( ĊĠĠĠĠĠ Ġempty List () ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġbuilds Data Ġ= ĠBuilds Data ( emptyList (), Ġempty Map ()) ĊĠĠĠ Ġevery Ġ{ Ġbuilds Mapper . map Build s ( emptyList ()) Ġ} Ġreturns Ġbuilds Data ĊĊĠĠĠ Ġinter actor . execute ( application Call , ĠConfiguration Id (" config - id ")) ĊĊĠĠĠ Ġco Verify Sequence Ġ{ ĊĠĠĠĠĠ Ġci DataSource . get Build s ( Configuration Id (" config - id "), ĠBuild Type . AP K _ SOURCE ) ĊĠĠĠĠĠ Ġbuilds Mapper . map Build s ( emptyList ()) ĊĠĠĠĠĠ Ġapplication Call . respond ( builds Data ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġgiven Get Build s Success And Mapping Failure _ when Execute _ then DoNot Respond () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġco Every Ġ{ Ġci DataSource . get Build s ( Configuration Id (" config - id "), ĠBuild Type . AP K _ SOURCE ) Ġ} Ġreturns ĠResult . success ( ĊĠĠĠĠĠ Ġempty List () ĊĠĠĠ Ġ) ĊĠĠĠ Ġevery Ġ{ Ġbuilds Mapper . map Build s ( emptyList ()) Ġ} Ġthrows ĠRuntimeException () ĊĊĠĠĠ Ġinter actor . execute ( application Call , ĠConfiguration Id (" config - id ")) ĊĊĠĠĠ Ġco Verify Sequence Ġ{ ĊĠĠĠĠĠ Ġci DataSource . get Build s ( Configuration Id (" config - id "), ĠBuild Type . AP K _ SOURCE ) ĊĠĠĠĠĠ Ġbuilds Mapper . map Build s ( emptyList ()) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġgiven Get Build s Failure _ when Execute _ then DoNot Respond () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġco Every Ġ{ Ġci DataSource . get Build s ( Configuration Id (" config - id "), ĠBuild Type . AP K _ SOURCE ) Ġ} Ġreturns ĠResult . failure ( ĊĠĠĠĠĠ ĠRuntimeException () ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġinter actor . execute ( application Call , ĠConfiguration Id (" config - id ")) ĊĊĠĠĠ Ġco Verify Sequence Ġ{ ĊĠĠĠĠĠ Ġci DataSource . get Build s ( Configuration Id (" config - id "), ĠBuild Type . AP K _ SOURCE ) ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ