package Ġevents ourcing . read models . student details Ċ Ċ import Ġarrow . core . None Ċ import Ġarrow . core . Option Ċ import Ġarrow . core . Some Ċ import Ġcom . n ha ar man . mock it ok otlin 2 .* Ċ import Ġevents ourcing . read models . Document Store Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . jupiter . api . Test Ċ Ċ internal Ġclass ĠStudent Details Read Model Test Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` given Ġa ĠStudent ĠDetails Ġread Ġmodel , Ġwhen ĠI Ġget Ġan Ġexisting Ġstudent Id , Ġthen Ġit Ġreturns Ġthe Ġstudent `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( sut , Ġstore ) Ġ= Ġgiven Read Model And Store () ĊĠĠĠĠĠĠĠ Ġval Ġa Student Ġ= ĠStudent Details (" ST UD ENT 0 0 1 ", Ġ" test @ ema . il ", Ġ" Full ĠName ", Ġ 2 L ) ĊĠĠĠĠĠĠĠ Ġwhenever ( store . get ( any ())). thenReturn ( ĠSome ( a Student ) Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ: ĠOption < Student Details > Ġ= Ġsut . get Student ById (" ST UD ENT 0 0 1 ") ĊĠĠĠĠĠĠĠ ĠassertThat ( result . or Null ()). isEqualTo ( a Student ) ĊĊĠĠĠĠĠĠĠ Ġverify ( store ). get ( eq (" ST UD ENT 0 0 1 ")) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( store ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` given Ġa ĠStudent ĠDetails Ġread Ġmodel , Ġwhen ĠI Ġget Ġa Ġnon Ġexisting Ġstudent Id , Ġthen Ġit Ġreturns Ġnull ` (){ ĊĠĠĠĠĠĠĠ Ġval Ġ( sut , Ġstore ) Ġ= Ġgiven Read Model And Store () ĊĠĠĠĠĠĠĠ Ġwhenever ( store . get ( any ())). thenReturn ( ĠNone Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ: ĠOption < Student Details > Ġ= Ġsut . get Student ById (" NOT - EXISTS ") ĊĠĠĠĠĠĠĠ ĠassertThat ( result ). isEqualTo ( None ) ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġprivate Ġfun Ġgiven Read Model And Store (): ĠPair < Student Details Read Model , ĠDocument Store < Student Details >> Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdatastore Ġ= Ġmock < Document Store < Student Details >>() ĊĠĠĠĠĠĠĠ Ġreturn ĠPair ( Student Details Read Model ( datastore ), Ġdatastore ) ĊĠĠĠ Ġ} Ċ } Ċ