package Ġcom . tt ul ka . e commerce . warehouse . jdbc Ċ Ċ import Ġcom . tt ul ka . e commerce . common . events . Event Publisher Ċ import Ġcom . tt ul ka . e commerce . warehouse . Amount Ċ import Ġcom . tt ul ka . e commerce . warehouse . In Stock Ċ import Ġcom . tt ul ka . e commerce . warehouse . ProductId Ċ import Ġcom . tt ul ka . e commerce . warehouse . Warehouse Ċ import Ġcom . tt ul ka . e commerce . warehouse . jdbc . config . Warehouse Jdbc Config Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . jupiter . api . Test Ċ 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 Ġ= Ġ[ Warehouse Jdbc Config :: class ]) Ċ @ Sql ( statements Ġ= Ġ[" INSERT ĠINTO Ġproducts _ in _ stock ĠVALUES Ġ(' test - 1 ', Ġ 1 2 3 ), Ġ(' test - 2 ', Ġ 3 2 1 ); "]) Ċ internal Ġclass ĠW arehouse Test ( ĊĠĠĠĠĠĠĠ Ġ@ Autowired Ġval Ġwarehouse : ĠW arehouse ) Ġ{ ĊĠĠĠĠĊĠĠĠ Ġ@ Mock Bean ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġevent Publisher : ĠEvent Publisher ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġleft _ in _ stock _ returned () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġin Stock Ġ= Ġwarehouse . left In Stock ( ProductId (" test - 1 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( in Stock ). isEqualTo ( In Stock ( Amount ( 1 2 3 ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġzero _ left _ in _ stock _ returned _ for _ an _ unknown _ product () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġin Stock Ġ= Ġwarehouse . left In Stock ( ProductId (" XXX ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( in Stock ). isEqualTo ( In Stock ( Amount . ZERO )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġproduct _ is _ put _ into _ stock () Ġ{ ĊĠĠĠĠĠĠĠ Ġwarehouse . put Into Stock ( ProductId (" test - xxx "), ĠAmount ( 1 2 3 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( warehouse . left In Stock ( ProductId (" test - xxx ")) ). isEqualTo ( In Stock ( Amount ( 1 2 3 ))) ĊĠĠĠ Ġ} Ċ }