package Ġorg . got son . kom ga . infrastructure . jooq Ċ Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . got son . kom ga . domain . model . Series Ċ import Ġorg . got son . kom ga . domain . model . Series Search Ċ import Ġorg . got son . kom ga . domain . model . make Library Ċ import Ġorg . got son . kom ga . domain . persistence . Library Repository Ċ import Ġorg . junit . jupiter . api . After All Ċ import Ġorg . junit . jupiter . api . After Each Ċ import Ġorg . junit . jupiter . api . Before All Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . extension . Extend With Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ import Ġorg . springframework . test . context . junit . jupiter . Spring Extension Ċ import Ġjava . net . URL Ċ import Ġjava . time . LocalDateTime Ċ Ċ @ Extend With ( Spring Extension :: class ) Ċ @ SpringBootTest Ċ class ĠSeries Dao Test ( ĊĠ Ġ@ Autowired Ġprivate Ġval Ġseries Dao : ĠSeries Dao , ĊĠ Ġ@ Autowired Ġprivate Ġval Ġlibrary Repository : ĠLibrary Repository Ċ ) Ġ{ ĊĊĠ Ġprivate Ġval Ġlibrary Ġ= Ġmake Library () ĊĊĠ Ġ@ Before All ĊĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠ Ġlibrary Repository . insert ( library ) ĊĠ Ġ} ĊĊĠ Ġ@ After Each ĊĠ Ġfun Ġdelete Series () Ġ{ ĊĠĠĠ Ġseries Dao . delete All () ĊĠĠĠ ĠassertThat ( series Dao . count ()). isEqualTo ( 0 ) ĊĠ Ġ} ĊĊĠ Ġ@ After All ĊĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠ Ġlibrary Repository . delete All () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` given Ġa Ġseries Ġwhen Ġinserting Ġthen Ġit Ġis Ġpersisted `() Ġ{ ĊĠĠĠ Ġval Ġnow Ġ= ĠLocalDateTime . now () ĊĠĠĠ Ġval Ġseries Ġ= ĠSeries ( ĊĠĠĠĠĠ Ġname Ġ= Ġ" Series ", ĊĠĠĠĠĠ Ġurl Ġ= ĠURL (" file :// series "), ĊĠĠĠĠĠ Ġfile LastModified Ġ= Ġnow , ĊĠĠĠĠĠ Ġlibrary Id Ġ= Ġlibrary . id ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġseries Dao . insert ( series ) ĊĠĠĠ Ġval Ġcreated Ġ= Ġseries Dao . findById OrNull ( series . id ) !! ĊĊĠĠĠ ĠassertThat ( created . id ). isNot EqualTo ( 0 ) ĊĠĠĠ ĠassertThat ( created . created Date ). is Close To ( now , Ġoffset ) ĊĠĠĠ ĠassertThat ( created . last ModifiedDate ). is Close To ( now , Ġoffset ) ĊĠĠĠ ĠassertThat ( created . name ). isEqualTo ( series . name ) ĊĠĠĠ ĠassertThat ( created . url ). isEqualTo ( series . url ) ĊĠĠĠ ĠassertThat ( created . file LastModified ). isEqualTo Ign oring Nan os ( series . file LastModified ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` given Ġa Ġseries Ġwhen Ġdeleting Ġthen Ġit Ġis Ġdeleted `() Ġ{ ĊĠĠĠ Ġval Ġseries Ġ= ĠSeries ( ĊĠĠĠĠĠ Ġname Ġ= Ġ" Series ", ĊĠĠĠĠĠ Ġurl Ġ= ĠURL (" file :// series "), ĊĠĠĠĠĠ Ġfile LastModified Ġ= ĠLocalDateTime . now (), ĊĠĠĠĠĠ Ġlibrary Id Ġ= Ġlibrary . id ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġseries Dao . insert ( series ) ĊĠĠĠ ĠassertThat ( series Dao . count ()). isEqualTo ( 1 ) ĊĊĠĠĠ Ġseries Dao . delete ( series . id ) ĊĊĠĠĠ ĠassertThat ( series Dao . count ()). isEqualTo ( 0 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` given Ġseries Ġwhen Ġdeleting Ġall Ġthen Ġall Ġare Ġdeleted `() Ġ{ ĊĠĠĠ Ġval Ġnow Ġ= ĠLocalDateTime . now () ĊĠĠĠ Ġval Ġseries Ġ= ĠSeries ( ĊĠĠĠĠĠ Ġname Ġ= Ġ" Series ", ĊĠĠĠĠĠ Ġurl Ġ= ĠURL (" file :// series "), ĊĠĠĠĠĠ Ġfile LastModified Ġ= Ġnow , ĊĠĠĠĠĠ Ġlibrary Id Ġ= Ġlibrary . id ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġseries 2 Ġ= ĠSeries ( ĊĠĠĠĠĠ Ġname Ġ= Ġ" Series 2 ", ĊĠĠĠĠĠ Ġurl Ġ= ĠURL (" file :// series 2 "), ĊĠĠĠĠĠ Ġfile LastModified Ġ= Ġnow , ĊĠĠĠĠĠ Ġlibrary Id Ġ= Ġlibrary . id ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġseries Dao . insert ( series ) ĊĠĠĠ Ġseries Dao . insert ( series 2 ) ĊĠĠĠ ĠassertThat ( series Dao . count ()). isEqualTo ( 2 ) ĊĊĠĠĠ Ġseries Dao . delete All () ĊĊĠĠĠ ĠassertThat ( series Dao . count ()). isEqualTo ( 0 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` given Ġseries Ġwhen Ġfinding Ġall Ġthen Ġall Ġare Ġreturned `() Ġ{ ĊĠĠĠ Ġval Ġnow Ġ= ĠLocalDateTime . now () ĊĠĠĠ Ġval Ġseries Ġ= ĠSeries ( ĊĠĠĠĠĠ Ġname Ġ= Ġ" Series ", ĊĠĠĠĠĠ Ġurl Ġ= ĠURL (" file :// series "), ĊĠĠĠĠĠ Ġfile LastModified Ġ= Ġnow , ĊĠĠĠĠĠ Ġlibrary Id Ġ= Ġlibrary . id ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġseries 2 Ġ= ĠSeries ( ĊĠĠĠĠĠ Ġname Ġ= Ġ" Series 2 ", ĊĠĠĠĠĠ Ġurl Ġ= ĠURL (" file :// series 2 "), ĊĠĠĠĠĠ Ġfile LastModified Ġ= Ġnow , ĊĠĠĠĠĠ Ġlibrary Id Ġ= Ġlibrary . id ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġseries Dao . insert ( series ) ĊĠĠĠ Ġseries Dao . insert ( series 2 ) ĊĊĠĠĠ Ġval Ġall Ġ= Ġseries Dao . findAll () ĊĊĠĠĠ ĠassertThat ( all ). has Size ( 2 ) ĊĠĠĠ ĠassertThat ( all . map Ġ{ Ġit . name Ġ}). contains Exactly In Any Order (" Series ", Ġ" Series 2 ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` given Ġexisting Ġseries Ġwhen Ġfinding Ġby Ġid Ġthen Ġseries Ġis Ġreturned `() Ġ{ ĊĠĠĠ Ġval Ġseries Ġ= ĠSeries ( ĊĠĠĠĠĠ Ġname Ġ= Ġ" Series ", ĊĠĠĠĠĠ Ġurl Ġ= ĠURL (" file :// series "), ĊĠĠĠĠĠ Ġfile LastModified Ġ= ĠLocalDateTime . now (), ĊĠĠĠĠĠ Ġlibrary Id Ġ= Ġlibrary . id ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġseries Dao . insert ( series ) ĊĊĠĠĠ Ġval Ġfound Ġ= Ġseries Dao . findById OrNull ( series . id ) ĊĊĠĠĠ ĠassertThat ( found ). isNotNull ĊĠĠĠ ĠassertThat ( found ?. name ). isEqualTo (" Series ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` given Ġnon - existing Ġseries Ġwhen Ġfinding Ġby Ġid Ġthen Ġnull Ġis Ġreturned `() Ġ{ ĊĠĠĠ Ġval Ġfound Ġ= Ġseries Dao . findById OrNull (" 1 2 8 7 7 4 6 ") ĊĊĠĠĠ ĠassertThat ( found ). isNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` given Ġexisting Ġseries Ġwhen Ġsearching Ġthen Ġresults Ġis Ġreturned `() Ġ{ ĊĠĠĠ Ġval Ġseries Ġ= ĠSeries ( ĊĠĠĠĠĠ Ġname Ġ= Ġ" Series ", ĊĠĠĠĠĠ Ġurl Ġ= ĠURL (" file :// series "), ĊĠĠĠĠĠ Ġfile LastModified Ġ= ĠLocalDateTime . now (), ĊĠĠĠĠĠ Ġlibrary Id Ġ= Ġlibrary . id ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġseries Dao . insert ( series ) ĊĊĠĠĠ Ġval Ġsearch Ġ= ĠSeries Search ( ĊĠĠĠĠĠ Ġlibrary Ids Ġ= ĠlistOf ( library . id ) ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġfound Ġ= Ġseries Dao . findAll ( search ) ĊĊĠĠĠ ĠassertThat ( found ). has Size ( 1 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` given Ġexisting Ġseries Ġwhen Ġfinding Ġby Ġlibrary Id Ġthen Ġseries Ġare Ġreturned `() Ġ{ ĊĠĠĠ Ġval Ġseries Ġ= ĠSeries ( ĊĠĠĠĠĠ Ġname Ġ= Ġ" Series ", ĊĠĠĠĠĠ Ġurl Ġ= ĠURL (" file :// series "), ĊĠĠĠĠĠ Ġfile LastModified Ġ= ĠLocalDateTime . now (), ĊĠĠĠĠĠ Ġlibrary Id Ġ= Ġlibrary . id ĊĠĠĠ Ġ) ĊĠĠĠ Ġseries Dao . insert ( series ) ĊĊĠĠĠ Ġval Ġfound Ġ= Ġseries Dao . findBy Library Id ( library . id ) ĊĊĠĠĠ ĠassertThat ( found ). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( found . first (). name ). isEqualTo (" Series ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` given Ġexisting Ġseries Ġwhen Ġfinding Ġby Ġother Ġlibrary Id Ġthen Ġempty Ġlist Ġis Ġreturned `() Ġ{ ĊĠĠĠ Ġval Ġseries Ġ= ĠSeries ( ĊĠĠĠĠĠ Ġname Ġ= Ġ" Series ", ĊĠĠĠĠĠ Ġurl Ġ= ĠURL (" file :// series "), ĊĠĠĠĠĠ Ġfile LastModified Ġ= ĠLocalDateTime . now (), ĊĠĠĠĠĠ Ġlibrary Id Ġ= Ġlibrary . id ĊĠĠĠ Ġ) ĊĠĠĠ Ġseries Dao . insert ( series ) ĊĊĠĠĠ Ġval Ġfound Ġ= Ġseries Dao . findBy Library Id ( library . id Ġ+ Ġ 1 ) ĊĊĠĠĠ ĠassertThat ( found ). has Size ( 0 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` given Ġexisting Ġseries Ġwhen Ġfinding Ġby Ġlibrary Id Ġand ĠUrl Ġnot Ġin Ġlist Ġthen Ġresults Ġare Ġreturned `() Ġ{ ĊĠĠĠ Ġval Ġseries Ġ= ĠSeries ( ĊĠĠĠĠĠ Ġname Ġ= Ġ" Series ", ĊĠĠĠĠĠ Ġurl Ġ= ĠURL (" file :// series "), ĊĠĠĠĠĠ Ġfile LastModified Ġ= ĠLocalDateTime . now (), ĊĠĠĠĠĠ Ġlibrary Id Ġ= Ġlibrary . id ĊĠĠĠ Ġ) ĊĠĠĠ Ġseries Dao . insert ( series ) ĊĊĠĠĠ Ġval Ġfound Ġ= Ġseries Dao . findBy Library Id And Url NotIn ( library . id , ĠlistOf ( URL (" file :// series 2 "))) ĊĠĠĠ Ġval Ġnot Found Ġ= Ġseries Dao . findBy Library Id And Url NotIn ( library . id , ĠlistOf ( URL (" file :// series "))) ĊĊĠĠĠ ĠassertThat ( found ). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( found . first (). name ). isEqualTo (" Series ") ĊĊĠĠĠ ĠassertThat ( not Found ). has Size ( 0 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` given Ġexisting Ġseries Ġwhen Ġfinding Ġby Ġlibrary Id Ġand ĠUrl Ġin Ġlist Ġthen Ġresults Ġare Ġreturned `() Ġ{ ĊĠĠĠ Ġval Ġseries Ġ= ĠSeries ( ĊĠĠĠĠĠ Ġname Ġ= Ġ" Series ", ĊĠĠĠĠĠ Ġurl Ġ= ĠURL (" file :// series "), ĊĠĠĠĠĠ Ġfile LastModified Ġ= ĠLocalDateTime . now (), ĊĠĠĠĠĠ Ġlibrary Id Ġ= Ġlibrary . id ĊĠĠĠ Ġ) ĊĠĠĠ Ġseries Dao . insert ( series ) ĊĊĠĠĠ Ġval Ġfound Ġ= Ġseries Dao . findBy Library Id And Url ( library . id , ĠURL (" file :// series ")) ĊĠĠĠ Ġval Ġnot Found 1 Ġ= Ġseries Dao . findBy Library Id And Url ( library . id , ĠURL (" file :// series 2 ")) ĊĠĠĠ Ġval Ġnot Found 2 Ġ= Ġseries Dao . findBy Library Id And Url ( library . id Ġ+ Ġ 1 , ĠURL (" file :// series ")) ĊĠĠĠ Ġval Ġnot Found 3 Ġ= Ġseries Dao . findBy Library Id And Url ( library . id Ġ+ Ġ 1 , ĠURL (" file :// series 2 ")) ĊĊĠĠĠ ĠassertThat ( found ). isNotNull ĊĠĠĠ ĠassertThat ( found ?. name ). isEqualTo (" Series ") ĊĊĠĠĠ ĠassertThat ( not Found 1 ). isNull () ĊĠĠĠ ĠassertThat ( not Found 2 ). isNull () ĊĠĠĠ ĠassertThat ( not Found 3 ). isNull () ĊĠ Ġ} Ċ } Ċ