package Ġcom . tt ul ka . e commerce . portal Ċ Ċ import Ġcom . tt ul ka . e commerce . common . events . Event Publisher Ċ import Ġcom . tt ul ka . e commerce . common . primitives . Money Ċ import Ġcom . tt ul ka . e commerce . common . primitives . Quantity Ċ import Ġcom . tt ul ka . e commerce . portal . Place Order From Cart . No Items To Order Exception Ċ import Ġcom . tt ul ka . e commerce . portal . config . Portal Config Ċ import Ġcom . tt ul ka . e commerce . sales . cart . Cart Ċ import Ġcom . tt ul ka . e commerce . sales . cart . item . Cart Item Ċ import Ġcom . tt ul ka . e commerce . sales . cart . item . ProductId Ċ import Ġcom . tt ul ka . e commerce . sales . cart . item . Title Ċ import Ġcom . tt ul ka . e commerce . shipping . delivery . Prepare Delivery Ċ import Ġcom . tt ul ka . e commerce . warehouse . Warehouse Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . assert Throws Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . mockito . Mockito . mock Ċ 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 . context . annotation . Component Scan Ċ import Ġorg . springframework . context . annotation . Configuration Ċ import Ġorg . springframework . test . context . Context Configuration Ċ import Ġorg . springframework . test . context . jdbc . Sql Ċ import Ġjava . util .* Ċ Ċ @ Jdbc Test Ċ @ Context Configuration ( classes Ġ= Ġ[ Portal Config :: class , ĠPlace Order From Cart Test . Services Test Config :: class ]) Ċ @ Sql ( statements Ġ= Ġ[" INSERT ĠINTO Ġproducts ĠVALUES Ġ(' 1 ', Ġ' Test Ġ 1 ', Ġ' Test ', Ġ 1 . 0 0 ), Ġ( 2 , Ġ' Test Ġ 2 ', Ġ' Test ', Ġ 2 . 0 0 ); "]) Ċ class ĠPlace Order From Cart Test ( ĊĠĠĠĠĠĠĠ Ġ@ Autowired Ġval Ġplace Order From Cart : ĠPlace Order From Cart ) Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġorder _ is _ placed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcart Ġ= Ġmock ( Cart :: class . java ) ĊĠĠĠĠĠĠĠ Ġval Ġcart Item Ġ= ĠCart Item ( ProductId (" TEST "), ĠTitle (" Test "), ĠMoney ( 1 f ), ĠQuantity ( 1 )) ĊĠĠĠĠĠĠĠ ĠMockito .` when `( cart . has Items ()). thenReturn ( true ) ĊĠĠĠĠĠĠĠ ĠMockito .` when `( cart . items ()). thenReturn ( listOf ( cart Item )) ĊĊĠĠĠĠĠĠĠ Ġplace Order From Cart . place Order ( UUID . randomUUID (), Ġcart ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġempty _ cart _ throws _ an _ exception () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThrows < No Items To Order Exception > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġplace Order From Cart . place Order ( UUID . randomUUID (), Ġmock ( Cart :: class . java )) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Configuration ĊĠĠĠ Ġ@ Component Scan (" com . tt ul ka . e commerce . sales ") ĊĠĠĠ Ġinternal Ġclass ĠServices Test Config Ġ{ ĊĠĠĠĠĠĠĠ Ġ@ Mock Bean ĊĠĠĠĠĠĠĠ Ġprivate Ġlateinit Ġvar Ġprepare Delivery : ĠPrepare Delivery ĊĊĠĠĠĠĠĠĠ Ġ@ Mock Bean ĊĠĠĠĠĠĠĠ Ġprivate Ġlateinit Ġvar Ġ Ġwarehouse : ĠW arehouse ĊĊĠĠĠĠĠĠĠ Ġ@ Mock Bean ĊĠĠĠĠĠĠĠ Ġprivate Ġlateinit Ġvar Ġ Ġevent Publisher : ĠEvent Publisher ĊĠĠĠ Ġ} Ċ } Ċ