package Ġcom . tt ul ka . e commerce . shipping . delivery . jdbc Ċ Ċ import Ġcom . tt ul ka . e commerce . common . events . Event Publisher Ċ import Ġcom . tt ul ka . e commerce . shipping . delivery .* Ċ import Ġcom . tt ul ka . e commerce . shipping . delivery . jdbc . config . Delivery Jdbc Config Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . assert All Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . autoconfigure . jdbc . Jdbc Test Ċ import Ġorg . springframework . boot . test . mock . mockito . Mock Bean Ċ import Ġorg . springframework . test . context . Context Configuration Ċ import Ġorg . springframework . test . context . jdbc . Sql Ċ Ċ @ Jdbc Test Ċ @ Context Configuration ( classes Ġ= Ġ[ Delivery Jdbc Config :: class ]) Ċ @ Sql ( statements Ġ= Ġ[" INSERT ĠINTO Ġdeliver ies ĠVALUES " Ġ+ ĊĠĠĠĠĠĠĠ Ġ" (' 0 0 0 1 0 1 ', Ġ' 1 0 0 1 ', Ġ' Test ĠPerson A ', Ġ' Place Ġ 1 '), " Ġ+ ĊĠĠĠĠĠĠĠ Ġ" (' 0 0 0 1 0 2 ', Ġ' 1 0 0 2 ', Ġ' Test ĠPerson B ', Ġ' Place Ġ 2 '); ", Ġ" INSERT ĠINTO Ġdis patched _ deliver ies ĠVALUES Ġ(' 0 0 0 1 0 2 '); "]) Ċ internal Ġclass ĠFind Del iv eries Test ( ĊĠĠĠĠĠĠĠ Ġ@ Autowired Ġval Ġfind Del iv eries : ĠFind Del iv eries ) Ġ{ ĊĊĠĠĠ Ġ@ Mock Bean ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġevent Publisher : ĠEvent Publisher ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġall _ deliver ies _ are _ found () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdeliver ies Ġ= Ġfind Del iv eries . all (). toList (). sorted By Ġ{ Ġit . id (). value () Ġ} ĊĠĠĠĠĠĠĠ Ġassert All ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ{ ĠassertThat ( deliver ies ). has Size GreaterThan OrEqualTo ( 2 ) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ{ ĠassertThat ( deliver ies [ 0 ]. id ()). isEqualTo ( Delivery Id (" 0 0 0 1 0 1 ")) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ{ ĠassertThat ( deliver ies [ 0 ]. orderId ()). isEqualTo ( OrderId (" 1 0 0 1 ")) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ{ ĠassertThat ( deliver ies [ 1 ]. id ()). isEqualTo ( Delivery Id (" 0 0 0 1 0 2 ")) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ{ ĠassertThat ( deliver ies [ 1 ]. orderId ()). isEqualTo ( OrderId (" 1 0 0 2 ")) Ġ} ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelivery _ is _ found _ by _ order _ id () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdelivery Ġ= Ġfind Del iv eries . by Order ( OrderId (" 1 0 0 1 ")) ĊĠĠĠĠĠĠĠ Ġassert All ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ{ ĠassertThat ( delivery . id ()). isEqualTo ( Delivery Id (" 0 0 0 1 0 1 ")) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ{ ĠassertThat ( delivery . orderId ()). isEqualTo ( OrderId (" 1 0 0 1 ")) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ{ ĠassertThat ( delivery . address ()). isEqualTo ( Address ( Person (" Test ĠPerson A "), ĠPlace (" Place Ġ 1 "))) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ{ ĠassertThat ( delivery . is Dis patched ). isFalse () Ġ} ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelivery _ is _ not _ found _ by _ order _ id () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdelivery Ġ= Ġfind Del iv eries . by Order ( OrderId (" does Ġnot Ġexist ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( delivery . id ()). isEqualTo ( Delivery Id ( 0 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġstatus _ is _ merged _ with _ events _ ledger () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdelivery Ġ= Ġfind Del iv eries . by Order ( OrderId (" 1 0 0 2 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( delivery . is Dis patched ). isTrue () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelivery _ for _ an _ order _ is _ prepared () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġis Prepared Ġ= Ġfind Del iv eries . is Prepared ( OrderId (" 1 0 0 1 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( is Prepared ). isTrue () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelivery _ for _ an _ order _ is _ not _ prepared () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġis Prepared Ġ= Ġfind Del iv eries . is Prepared ( OrderId (" WRONG ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( is Prepared ). isFalse () ĊĠĠĠ Ġ} Ċ } Ċ