package Ġorg . be ck n . one . sandbox . b ap . client . order . policy . controllers Ċ Ċ import Ġcom . fasterxml . jackson . databind . ObjectMapper Ċ import Ġio . kot est . core . spec . style . Describe Spec Ċ import Ġio . kot est . matchers . shouldBe Ċ import Ġorg . be ck n . one . sandbox . b ap . client . shared . d tos . ClientContext Ċ import Ġorg . be ck n . one . sandbox . b ap . client . shared . d tos . Client Order Policy Response Ċ import Ġorg . be ck n . one . sandbox . b ap . client . shared . d tos . Client Order Policy Response Message Ċ import Ġorg . be ck n . one . sandbox . b ap . client . shared . d tos . Get Order Policy Dto Ċ import Ġorg . be ck n . one . sandbox . b ap . factories . Context Factory Ċ import Ġorg . be ck n . protocol . schemas . Protocol Descriptor Ċ import Ġorg . be ck n . protocol . schemas . Protocol Option Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . autoconfigure . web . servlet . Auto Configure MockMvc Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ import Ġorg . springframework . http . HttpHeaders Ċ import Ġorg . springframework . http . MediaType Ċ import Ġorg . springframework . test . context . Active Profiles Ċ import Ġorg . springframework . test . context . Test Property Source Ċ import Ġorg . springframework . test . web . servlet . MockMvc Ċ import Ġorg . springframework . test . web . servlet . request . MockMvc Request Builders . post Ċ import Ġorg . springframework . test . web . servlet . result . MockMvc Result Matchers . status Ċ Ċ @ SpringBootTest Ċ @ Auto Configure MockMvc Ċ @ Active Profiles ( value Ġ= Ġ[" test "]) Ċ @ Test Property Source ( locations Ġ= Ġ["/ application - test . yml "]) Ċ class ĠMock Get Order Policy Controller Spec Ġ@ Autowired Ġconstructor ( ĊĠ Ġval Ġmock Mvc : ĠMock Mvc , ĊĠ Ġval ĠobjectMapper : ĠObjectMapper , ĊĠ Ġval Ġcontext Factory : ĠContext Factory Ċ ) Ġ: ĠDescribe Spec () Ġ{ ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġdescribe (" Get ĠOrder ĠPolicy ") Ġ{ ĊĠĠĠĠĠ Ġit (" should Ġreturn Ġorder Ġpolicy ") Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠClient Context () ĊĊĠĠĠĠĠĠĠ Ġval Ġget Order Policy ResponseBody Ġ= Ġinvoke Get Order Policy Api ( context ) ĊĠĠĠĠĠĠĠĠĠ Ġ. andExpect ( status (). is Ok ) ĊĠĠĠĠĠĠĠĠĠ Ġ. andReturn () ĊĊĠĠĠĠĠĠĠ Ġval Ġget Order Policy Response Ġ= ĠobjectMapper . readValue ( ĊĠĠĠĠĠĠĠĠĠ Ġget Order Policy ResponseBody . response . content AsString , ĊĠĠĠĠĠĠĠĠĠ ĠClient Order Policy Response :: class . java ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġget Order Policy Response . message ĠshouldBe ĠClient Order Policy Response Message ( ĊĠĠĠĠĠĠĠĠĠ Ġcancellation Re asons Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠProtocol Option (" 1 ", Ġcancellation Policy ()), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠProtocol Option (" 2 ", Ġreturn Policy ()), ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġinvoke Get Order Policy Api ( context : ĠClient Context ) Ġ= Ġmock Mvc ĊĠĠĠ Ġ. perform ( ĊĠĠĠĠĠ Ġpost ("/ client / v 0 / get _ order _ policy ") ĊĠĠĠĠĠĠĠ Ġ. header ( HttpHeaders . CONTENT _ TYPE , ĠMediaType . APPLICATION _ JSON _ VALUE ) ĊĠĠĠĠĠĠĠ Ġ. content ( object Mapper . writeValue AsString ( Get Order Policy Dto ( context Ġ= Ġcontext ))) ĊĠĠĠ Ġ) ĊĊĠ Ġprivate Ġfun Ġcancellation Policy () Ġ= ĠProtocol Descriptor ( ĊĠĠĠ Ġname Ġ= Ġ" Cancellation ĠPolicy ", ĊĠĠĠ Ġcode Ġ= Ġ" C ancellable Ġwithin Ġa Ġday ", ĊĠĠĠ Ġshort Desc Ġ= Ġ" This Ġitem Ġis Ġcancell able Ġwith Ġa Ġday Ġof Ġthe Ġorder Ġbeing Ġplaced .", ĊĠĠĠ Ġlong Desc Ġ= Ġ" However Ġif Ġthere Ġis Ġa Ġdelay Ġin Ġdelivery Ġand Ġyou Ġwould Ġlike Ġto Ġcancel Ġthe Ġorder Ġafter Ġa Ġday Ġof Ġpl acing Ġthe Ġorder Ġthen Ġplease Ġcontact Ġthe Ġcustomer Ġsupport .", ĊĠ Ġ) ĊĊĠ Ġprivate Ġfun Ġreturn Policy () Ġ= ĠProtocol Descriptor ( ĊĠĠĠ Ġname Ġ= Ġ" Return ĠPolicy ", ĊĠĠĠ Ġcode Ġ= Ġ" Non - Return able ", ĊĠĠĠ Ġshort Desc Ġ= Ġ" This Ġitem Ġis Ġnon - return able Ġdue Ġto Ġthe Ġconsum able Ġnature Ġof Ġthe Ġproduct .", ĊĠĠĠ Ġlong Desc Ġ= Ġ" However , Ġin Ġthe Ġunlikely Ġevent Ġof Ġdam aged , Ġdefect ive Ġor Ġdifferent / wrong Ġitem Ġdelivered Ġto Ġyou , Ġwe Ġwill Ġprovide Ġa Ġfull Ġrefund Ġor Ġfree Ġreplacement Ġas Ġapplicable . ĠWe Ġmay Ġcontact Ġyou Ġto Ġas cert ain Ġthe Ġdamage Ġor Ġdefect Ġin Ġthe Ġproduct Ġprior Ġto Ġiss uing Ġrefund / replacement .", ĊĠ Ġ) ĊĊ Ċ } Ċ