package Ġfr . g ou v . cac em . mon it ore nv . infrastructure . api Ċ Ċ import Ġfr . g ou v . cac em . mon it ore nv . Meter Registry Configuration Ċ import Ġfr . g ou v . cac em . mon it ore nv . infrastructure . api . endpoints . Mission s Controller Ċ import Ġfr . g ou v . cac em . mon it ore nv . domain . entities . missions .* Ċ import Ġfr . g ou v . cac em . mon it ore nv . domain . use _ cases . crud . missions . Create Mission Ċ import Ġfr . g ou v . cac em . mon it ore nv . domain . use _ cases . crud . missions . Get Mission ById Ċ import Ġfr . g ou v . cac em . mon it ore nv . domain . use _ cases . crud . missions . Get Mission s Ċ import Ġfr . g ou v . cac em . mon it ore nv . domain . use _ cases . crud . missions . Update Mission Ċ import Ġfr . g ou v . cac em . mon it ore nv . infrastructure . api . adapters . inputs . Create OrUpdate Mission Data Input ĊĊ Ċ import Ġorg . hamcrest . Matchers . equalTo Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . extension . Extend With Ċ import Ġorg . mockito . BDD Mockito . any Ċ import Ġorg . mockito . BDD Mockito . given Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . autoconfigure . web . servlet . Web Mvc Test Ċ import Ġorg . springframework . boot . test . mock . mockito . Mock Bean Ċ import Ġorg . springframework . context . annotation . Import Ċ import Ġorg . springframework . http . MediaType Ċ import Ġorg . springframework . test . context . junit . jupiter . Spring Extension Ċ import Ġorg . springframework . test . web . servlet . MockMvc Ċ import Ġorg . springframework . test . web . servlet . result . MockMvc Result Matchers . json Path Ċ import Ġorg . springframework . test . web . servlet . result . MockMvc Result Matchers . status Ċ import Ġjava . time . Z onedDateTime Ċ import Ġorg . springframework . test . web . servlet . request . MockMvc Request Builders .* Ċ import Ġcom . fasterxml . jackson . databind . ObjectMapper ĊĊ Ċ @ Import ( Meter Registry Configuration :: class ) Ċ @ Extend With ( Spring Extension :: class ) Ċ @ Web Mvc Test ( value Ġ= Ġ[( Mission s Controller :: class )]) Ċ class ĠMis sion s Controller IT ests Ġ{ ĊĊĠ Ġ@ Autowired ĊĠ Ġprivate Ġlateinit Ġvar Ġmock Mvc : ĠMock Mvc ĊĊĠ Ġ@ Mock Bean ĊĠ Ġprivate Ġlateinit Ġvar Ġcreate Mission : ĠCreate Mission ĊĊĠ Ġ@ Mock Bean ĊĠ Ġprivate Ġlateinit Ġvar Ġget Mission s : ĠGet Mission s ĊĊĠ Ġ@ Mock Bean ĊĠ Ġprivate Ġlateinit Ġvar Ġget Mission ById : ĠGet Mission ById ĊĊĠ Ġ@ Mock Bean ĊĠ Ġprivate Ġlateinit Ġvar Ġupdate Mission : ĠUpdate Mission ĊĊĠ Ġ@ Autowired ĊĠ Ġprivate Ġlateinit Ġvar ĠobjectMapper : ĠObjectMapper ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` Should Ġcreate Ġa Ġnew Ġmission `() Ġ{ ĊĠĠĠ Ġ// ĠGiven ĊĠĠĠ Ġval Ġnew Mission Ġ= ĠMis sion Entity ( ĊĠĠĠĠĠ Ġid Ġ= Ġ 1 0 , ĊĠĠĠĠĠ Ġmission Type Ġ= ĠMis sion TypeEnum . LAND , ĊĠĠĠĠĠ Ġmission Status Ġ= Ġ" CLOSED ", ĊĠĠĠĠĠ Ġfac ade Ġ= Ġ" Out re - Mer ", ĊĠĠĠĠĠ Ġtheme Ġ= Ġ" CONTRO LE ", ĊĠĠĠĠĠ Ġobservations Ġ= Ġnull , ĊĠĠĠĠĠ Ġinput StartDate time Utc Ġ= ĠZ onedDateTime . parse (" 2 0 2 2 - 0 1 - 1 5 T 0 4 : 5 0 : 0 9 Z "), ĊĠĠĠĠĠ Ġinput EndDate time Utc Ġ= ĠZ onedDateTime . parse (" 2 0 2 2 - 0 1 - 2 3 T 2 0 : 2 9 : 0 3 Z ") ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġnew Mission Request Ġ= ĠCreate OrUpdate Mission Data Input ( ĊĠĠĠĠĠ Ġid Ġ= Ġ 1 0 , ĊĠĠĠĠĠ Ġmission Type Ġ= ĠMis sion TypeEnum . LAND , ĊĠĠĠĠĠ Ġmission Status Ġ= Ġ" CLOSED ", ĊĠĠĠĠĠ Ġfac ade Ġ= Ġ" Out re - Mer ", ĊĠĠĠĠĠ Ġtheme Ġ= Ġ" CONTRO LE ", ĊĠĠĠĠĠ Ġobservations Ġ= Ġnull , ĊĠĠĠĠĠ Ġinput StartDate time Utc Ġ= ĠZ onedDateTime . parse (" 2 0 2 2 - 0 1 - 1 5 T 0 4 : 5 0 : 0 9 Z "), ĊĠĠĠĠĠ Ġinput EndDate time Utc Ġ= ĠZ onedDateTime . parse (" 2 0 2 2 - 0 1 - 2 3 T 2 0 : 2 9 : 0 3 Z ") ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ// Ġgiven ( this . create Mission . execute ( any ())). willReturn ( new Mission ) ĊĠĠĠ Ġgiven ( this . create Mission . execute ( any ())). will Answer Ġ{ ĊĠĠĠĠĠ Ġprintln (" ======= MISSION ============ =") ĊĠĠĠĠĠ Ġprintln (" request Ġas Ġtext ") ĊĠĠĠĠĠ Ġprintln ( object Mapper . writeValue AsString ( new Mission Request )) ĊĠĠĠĠĠ Ġprintln (" new Mission Request . to Mission Entity ") ĊĠĠĠĠĠ Ġprintln ( new Mission Request . to Mission Entity ()) ĊĠĠĠĠĠ Ġprintln (" function Ġcalled Ġwith ") ĊĠĠĠĠĠ Ġprintln ( it ) ĊĠĠĠĠĠ Ġ// ĠError Ġparsing Ġdates Ġin Ġtests ĊĠĠĠĠĠ Ġ// Ġ 2 0 2 2 - 0 1 - 1 5 T 0 4 : 5 0 : 0 9 Z [ UTC ] Ġ( it ) Ġinstead Ġof Ġ 2 0 2 2 - 0 1 - 1 5 T 0 4 : 5 0 : 0 9 Z Ġ( request Body . to Mission Entity ()) ĊĠĠĠĠĠ Ġprint (" ================ === =") ĊĠĠĠĠĠ Ġreturn @ will Answer Ġnew Mission ĊĠĠĠ Ġ} ĊĠĠĠ Ġ// ĠWhen ĊĠĠĠ Ġmock Mvc . perform ( ĊĠĠĠĠĠ Ġput ("/ bff / v 1 / missions ") ĊĠĠĠĠĠ Ġ. content ( object Mapper . writeValue AsString ( new Mission Request )) ĊĠĠĠĠĠ Ġ. contentType ( MediaType . APPLICATION _ JSON ) ĊĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ// ĠThen ĊĠĠĠĠĠ Ġ. andExpect ( status (). is Ok ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` Should Ġget Ġall Ġmission s `() Ġ{ ĊĠĠĠ Ġ// ĠGiven ĊĠĠĠ Ġval Ġfirst Mission Ġ= ĠMis sion Entity ( ĊĠĠĠĠĠ Ġid Ġ= Ġ 1 0 , ĊĠĠĠĠĠ Ġmission Type Ġ= ĠMis sion TypeEnum . SE A , ĊĠĠĠĠĠ Ġmission Status Ġ= Ġ" CLOSED ", ĊĠĠĠĠĠ Ġfac ade Ġ= Ġ" Out re - Mer ", ĊĠĠĠĠĠ Ġtheme Ġ= Ġ" CONTRO LE ", ĊĠĠĠĠĠ Ġobservations Ġ= Ġnull , ĊĠĠĠĠĠ Ġinput StartDate time Utc Ġ= ĠZ onedDateTime . parse (" 2 0 2 2 - 0 1 - 1 5 T 0 4 : 5 0 : 0 9 Z "), ĊĠĠĠĠĠ Ġinput EndDate time Utc Ġ= ĠZ onedDateTime . parse (" 2 0 2 2 - 0 1 - 2 3 T 2 0 : 2 9 : 0 3 Z "), ĊĠĠĠ Ġ) ĊĠĠĠ Ġgiven ( this . get Mission s . execute ()). willReturn ( listOf ( first Mission )) ĊĊĠĠĠ Ġ// ĠWhen ĊĠĠĠ Ġmock Mvc . perform ( get ("/ bff / v 1 / missions ")) ĊĠĠĠĠĠ Ġ// ĠThen ĊĠĠĠĠĠ Ġ. andExpect ( status (). is Ok ) ĊĠĠĠĠĠ Ġ. andExpect ( json Path ("$ [ 0 ]. id ", ĠequalTo ( first Mission . id ))) ĊĠĠĠĠĠ Ġ. andExpect ( json Path ("$ [ 0 ]. mission Type ", ĠequalTo ( first Mission . mission Type . toString ()))) ĊĠĠĠĠĠ Ġ. andExpect ( json Path ("$ [ 0 ]. mission Status ", ĠequalTo ( first Mission . mission Status ))) ĊĠĠĠĠĠ Ġ. andExpect ( json Path ("$ [ 0 ]. facade ", ĠequalTo ( first Mission . facade ))) ĊĠĠĠĠĠ Ġ. andExpect ( json Path ("$ [ 0 ]. theme ", ĠequalTo ( first Mission . theme ))) ĊĠĠĠĠĠ Ġ. andExpect ( json Path ("$ [ 0 ]. input StartDate time Utc ", ĠequalTo ( first Mission . input StartDate time Utc . toString ()))) ĊĠĠĠĠĠ Ġ. andExpect ( json Path ("$ [ 0 ]. input EndDate time Utc ", ĠequalTo ( first Mission . input EndDate time Utc . toString ()))) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` Should Ġget Ġspecific Ġmission Ġwhen Ġrequested Ġby ĠId `() Ġ{ ĊĠĠĠ Ġ// ĠGiven ĊĠĠĠ Ġval Ġfirst Mission Ġ= ĠMis sion Entity ( ĊĠĠĠĠĠ Ġid Ġ= Ġ 1 0 , ĊĠĠĠĠĠ Ġmission Type Ġ= ĠMis sion TypeEnum . SE A , ĊĠĠĠĠĠ Ġmission Status Ġ= Ġ" CLOSED ", ĊĠĠĠĠĠ Ġfac ade Ġ= Ġ" Out re - Mer ", ĊĠĠĠĠĠ Ġtheme Ġ= Ġ" CONTRO LE ", ĊĠĠĠĠĠ Ġobservations Ġ= Ġnull , ĊĠĠĠĠĠ Ġinput StartDate time Utc Ġ= ĠZ onedDateTime . parse (" 2 0 2 2 - 0 1 - 1 5 T 0 4 : 5 0 : 0 9 Z "), ĊĠĠĠĠĠ Ġinput EndDate time Utc Ġ= ĠZ onedDateTime . parse (" 2 0 2 2 - 0 1 - 2 3 T 2 0 : 2 9 : 0 3 Z "), ĊĠĠĠ Ġ) ĊĠĠĠ Ġgiven ( this . get Mission ById . execute ( 0 )). willReturn ( first Mission ) ĊĊĠĠĠ Ġ// ĠWhen ĊĠĠĠ Ġmock Mvc . perform ( get ("/ bff / v 1 / missions / 0 ")) ĊĠĠĠĠĠ Ġ// ĠThen ĊĠĠĠĠĠ Ġ. andExpect ( status (). is Ok ) ĊĠĠĠĠĠ Ġ. andExpect ( json Path (" $. id ", ĠequalTo ( first Mission . id ))) ĊĠĠĠĠĠ Ġ. andExpect ( json Path (" $. mission Type ", ĠequalTo ( first Mission . mission Type . toString ()))) ĊĠĠĠĠĠ Ġ. andExpect ( json Path (" $. mission Status ", ĠequalTo ( first Mission . mission Status ))) ĊĠĠĠĠĠ Ġ. andExpect ( json Path (" $. facade ", ĠequalTo ( first Mission . facade ))) ĊĠĠĠĠĠ Ġ. andExpect ( json Path (" $. theme ", ĠequalTo ( first Mission . theme ))) ĊĠĠĠĠĠ Ġ. andExpect ( json Path (" $. input StartDate time Utc ", ĠequalTo ( first Mission . input StartDate time Utc . toString ()))) ĊĠĠĠĠĠ Ġ. andExpect ( json Path (" $. input EndDate time Utc ", ĠequalTo ( first Mission . input EndDate time Utc . toString ()))) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` Should Ġupdate Ġmission `() Ġ{ ĊĠĠĠ Ġ// ĠGiven ĊĠĠĠ Ġval Ġexpected Updated Mission Ġ= ĠMis sion Entity ( ĊĠĠĠĠĠ Ġid Ġ= Ġ 1 0 , ĊĠĠĠĠĠ Ġmission Type Ġ= ĠMis sion TypeEnum . LAND , ĊĠĠĠĠĠ Ġmission Status Ġ= Ġ" CLOSED ", ĊĠĠĠĠĠ Ġfac ade Ġ= Ġ" Out re - Mer ", ĊĠĠĠĠĠ Ġtheme Ġ= Ġ" CONTRO LE ", ĊĠĠĠĠĠ Ġobservations Ġ= Ġnull , ĊĠĠĠĠĠ Ġinput StartDate time Utc Ġ= ĠZ onedDateTime . parse (" 2 0 2 2 - 0 1 - 1 5 T 0 4 : 5 0 : 0 9 Z "), ĊĠĠĠĠĠ Ġinput EndDate time Utc Ġ= ĠZ onedDateTime . parse (" 2 0 2 2 - 0 1 - 2 3 T 2 0 : 2 9 : 0 3 Z ") ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġrequest Body Ġ= ĠCreate OrUpdate Mission Data Input ( ĊĠĠĠĠĠ Ġid Ġ= Ġ 1 0 , ĊĠĠĠĠĠ Ġmission Type Ġ= ĠMis sion TypeEnum . LAND , ĊĠĠĠĠĠ Ġmission Status Ġ= Ġ" CLOSED ", ĊĠĠĠĠĠ Ġfac ade Ġ= Ġ" Out re - Mer ", ĊĠĠĠĠĠ Ġtheme Ġ= Ġ" CONTRO LE ", ĊĠĠĠĠĠ Ġobservations Ġ= Ġnull , ĊĠĠĠĠĠ Ġinput StartDate time Utc Ġ= ĠZ onedDateTime . parse (" 2 0 2 2 - 0 1 - 1 5 T 0 4 : 5 0 : 0 9 Z "), ĊĠĠĠĠĠ Ġinput EndDate time Utc Ġ= ĠZ onedDateTime . parse (" 2 0 2 2 - 0 1 - 2 3 T 2 0 : 2 9 : 0 3 Z ") ĊĠĠĠ Ġ) Ċ // ĠĠĠ Ġgiven ( this . update Mission . execute ( request Body . to Mission Entity ())). willReturn ( expected Updated Mission ) ĊĠĠĠ Ġgiven ( this . update Mission . execute ( any ())). will Answer Ġ{ ĊĠĠĠĠĠ Ġprintln (" ======= MISSION ============ =") ĊĠĠĠĠĠ Ġprintln (" request Ġas Ġtext ") ĊĠĠĠĠĠ Ġprintln ( object Mapper . writeValue AsString ( request Body )) ĊĠĠĠĠĠ Ġprintln (" request Body . to Mission Entity ") ĊĠĠĠĠĠ Ġprintln ( request Body . to Mission Entity ()) ĊĠĠĠĠĠ Ġprintln (" function Ġcalled Ġwith ") ĊĠĠĠĠĠ Ġprintln ( it ) ĊĠĠĠĠĠ Ġ// ĠError Ġparsing Ġdates Ġin Ġtests ĊĠĠĠĠĠ Ġ// Ġ 2 0 2 2 - 0 1 - 1 5 T 0 4 : 5 0 : 0 9 Z [ UTC ] Ġ( it ) Ġinstead Ġof Ġ 2 0 2 2 - 0 1 - 1 5 T 0 4 : 5 0 : 0 9 Z Ġ( request Body . to Mission Entity ()) ĊĠĠĠĠĠ Ġprint (" ================ === =") ĊĠĠĠĠĠĠ Ġreturn @ will Answer Ġexpected Updated Mission ĊĠĠĠĠ Ġ} ĊĠĠĠ Ġ// ĠWhen ĊĠĠĠ Ġmock Mvc . perform ( ĊĠĠĠĠĠ Ġput ("/ bff / v 1 / missions / 0 ") ĊĠĠĠĠĠĠĠ Ġ. content ( object Mapper . writeValue AsString ( request Body )) ĊĠĠĠĠĠĠĠ Ġ. contentType ( MediaType . APPLICATION _ JSON ) ĊĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ// ĠThen ĊĠĠĠĠĠ Ġ. andExpect ( status (). is Ok ) ĊĠ Ġ} Ċ } Ċ