package Ġuk . gov . just ice . digital . h mp ps . h mp ps inter vention ss ervice . jpa . repository Ċ Ċ import Ġcom . microsoft . application insights . boot . dependencies . apache commons . lang 3 . Random StringUtils Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . jupiter . api . Nested Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . autoconfigure . orm . jpa . Test EntityManager Ċ import Ġorg . springframework . data . domain . Page Request Ċ import Ġuk . gov . just ice . digital . h mp ps . h mp ps inter vention ss ervice . jpa . entity . Auth User Ċ import Ġuk . gov . just ice . digital . h mp ps . h mp ps inter vention ss ervice . jpa . entity . EndOf Service Report Ċ import Ġuk . gov . just ice . digital . h mp ps . h mp ps inter vention ss ervice . jpa . entity . Ref erral Ċ import Ġuk . gov . just ice . digital . h mp ps . h mp ps inter vention ss ervice . jpa . entity . Ref erral Assignment Ċ import Ġuk . gov . just ice . digital . h mp ps . h mp ps inter vention ss ervice . jpa . entity . ServiceProvider Sent Ref erral Summary Ċ import Ġuk . gov . just ice . digital . h mp ps . h mp ps inter vention ss ervice . util . Auth User Factory Ċ import Ġuk . gov . just ice . digital . h mp ps . h mp ps inter vention ss ervice . util . Dynamic Framework Contract Factory Ċ import Ġuk . gov . just ice . digital . h mp ps . h mp ps inter vention ss ervice . util . EndOf Service Report Factory Ċ import Ġuk . gov . just ice . digital . h mp ps . h mp ps inter vention ss ervice . util . Inter vention Factory Ċ import Ġuk . gov . just ice . digital . h mp ps . h mp ps inter vention ss ervice . util . Ref erral Factory Ċ import Ġuk . gov . just ice . digital . h mp ps . h mp ps inter vention ss ervice . util . Repository Test Ċ import Ġuk . gov . just ice . digital . h mp ps . h mp ps inter vention ss ervice . util . ServiceProvider Factory Ċ import Ġuk . gov . just ice . digital . h mp ps . h mp ps inter vention ss ervice . util . Service User Factory Ċ import Ġjava . time . Instant Ċ import Ġjava . time . Offset DateTime Ċ import Ġjava . util . UUID Ċ import Ġjavax . transaction . Transactional Ċ Ċ @ Transactional Ċ @ Repository Test Ċ class ĠRef erral Repository Test Ġ@ Autowired Ġconstructor ( ĊĠ Ġval Ġentity Manager : ĠTest EntityManager , ĊĠ Ġval Ġend Of Service Report Repository : ĠEnd Of Service Report Repository , ĊĠ Ġval Ġref erral Repository : ĠRef erral Repository , ĊĠ Ġval Ġinter vention Repository : ĠInter vention Repository , ĊĠ Ġval Ġauth UserRepository : ĠAuth UserRepository , Ċ ) Ġ{ ĊĠ Ġprivate Ġval Ġauth User Factory Ġ= ĠAuth User Factory ( entityManager ) ĊĠ Ġprivate Ġval Ġref erral Factory Ġ= ĠRef erral Factory ( entityManager ) ĊĠ Ġprivate Ġval Ġdynamic Framework Contract Factory Ġ= ĠDynamic Framework Contract Factory ( entityManager ) ĊĠ Ġprivate Ġval Ġinter vention Factory Ġ= ĠInter vention Factory ( entityManager ) ĊĠ Ġprivate Ġval Ġservice Provider Factory Ġ= ĠService Provider Factory ( entityManager ) ĊĠ Ġprivate Ġval Ġservice User Factory Ġ= ĠService User Factory ( entityManager ) ĊĠ Ġprivate Ġval Ġend Of Service Report Ġ= ĠEnd Of Service Report Factory ( entityManager ) ĊĊĠ Ġ@ Nested ĊĠ Ġinner Ġclass ĠService Provider Selection Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` can Ġobtain Ġa Ġsingle Ġref erral Ġsummary Ġusing Ġprime Ġprovider `() Ġ{ ĊĠĠĠĠĠ Ġval Ġref erral With Prime Sp Ġ= Ġcreate Ref erral ( true ) ĊĠĠĠĠĠ Ġval Ġref erral With Another Prime Sp Ġ= Ġcreate Ref erral ( true ) ĊĊĠĠĠĠĠ Ġval Ġservice Provider Search Id Ġ= Ġref erral With Prime Sp . inter vention . dynamic Framework Contract . prime Provider . id ĊĠĠĠĠĠ Ġval Ġsummar ies Ġ= Ġref erral Repository . ref erral Summary For Service Providers ( listOf ( service Provider Search Id )) ĊĊĠĠĠĠĠ ĠassertThat ( sum maries . size ). isEqualTo ( 1 ) ĊĠĠĠĠĠ ĠassertThat ( contains ( sum maries , Ġexpected Summary ( ref erral With Prime Sp ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` can Ġobtain Ġa Ġsingle Ġref erral Ġsummary Ġusing Ġsub contract or Ġprovider `() Ġ{ ĊĠĠĠĠĠ Ġval Ġref erral With Sub Con Sp Ġ= Ġcreate Ref erral ( false ) ĊĠĠĠĠĠ Ġval Ġref erral With Another Sub Con Sp Ġ= Ġcreate Ref erral ( false ) ĊĊĠĠĠĠĠ Ġval Ġservice Provider Search Id Ġ= Ġref erral With Sub Con Sp . inter vention . dynamic Framework Contract . sub contract or Providers . first OrNull () !!. id ĊĠĠĠĠĠ Ġval Ġsummar ies Ġ= Ġref erral Repository . ref erral Summary For Service Providers ( listOf ( service Provider Search Id )) ĊĊĠĠĠĠĠ ĠassertThat ( sum maries . size ). isEqualTo ( 1 ) ĊĠĠĠĠĠ ĠassertThat ( contains ( sum maries , Ġexpected Summary ( ref erral With Sub Con Sp ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` can Ġobtain Ġa Ġmultiple Ġref erral Ġsummar ies Ġas Ġsub contract or Ġand Ġas Ġprime Ġprovider `() Ġ{ ĊĊĠĠĠĠĠ Ġval Ġref erral With Prime Sp Ġ= Ġcreate Ref erral ( true ) ĊĠĠĠĠĠ Ġval Ġref erral With Another Prime Sp Ġ= Ġcreate Ref erral ( true ) ĊĠĠĠĠĠ Ġval Ġref erral With Sub Con Sp Ġ= Ġcreate Ref erral ( false ) ĊĠĠĠĠĠ Ġval Ġref erral With Another Sub Con Sp Ġ= Ġcreate Ref erral ( false ) ĊĊĠĠĠĠĠ Ġval Ġservice Provider Search Ids Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ Ġref erral With Prime Sp . inter vention . dynamic Framework Contract . prime Provider . id , ĊĠĠĠĠĠĠĠ Ġref erral With Sub Con Sp . inter vention . dynamic Framework Contract . sub contract or Providers . first OrNull () !!. id ĊĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġval Ġsummar ies Ġ= Ġref erral Repository . ref erral Summary For Service Providers ( service Provider Search Ids ) ĊĊĠĠĠĠĠ ĠassertThat ( sum maries . size ). isEqualTo ( 2 ) ĊĠĠĠĠĠ ĠassertThat ( contains ( sum maries , Ġexpected Summary ( ref erral With Prime Sp ))) ĊĠĠĠĠĠ ĠassertThat ( contains ( sum maries , Ġexpected Summary ( ref erral With Sub Con Sp ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` cannot Ġobtain Ġa Ġsingle Ġref erral Ġsummary Ġwhen Ġprovider Ġdoesn 't Ġmatch `() Ġ{ ĊĊĠĠĠĠĠ Ġval Ġref erral With Prime Sp Ġ= Ġcreate Ref erral ( true ) ĊĠĠĠĠĠ Ġval Ġref erral With Sub Con Sp Ġ= Ġcreate Ref erral ( false ) ĊĊĠĠĠĠĠ Ġval Ġsummar ies Ġ= Ġref erral Repository . ref erral Summary For Service Providers ( listOf (" NON _ EXIST ENT _ SP ")) ĊĊĠĠĠĠĠ ĠassertThat ( sum maries . size ). isEqualTo ( 0 ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Nested ĊĠ Ġinner Ġclass ĠAssigned To Ref erral Selection Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` can Ġdetermine Ġassigned Ġuser Ġwhen Ġonly Ġone `() Ġ{ ĊĠĠĠĠĠ Ġval Ġref erral With Single Assign ee Ġ= Ġcreate Ref erral ( true , Ġ 1 ) ĊĊĠĠĠĠĠ Ġval Ġservice Provider Search Id Ġ= Ġref erral With Single Assign ee . inter vention . dynamic Framework Contract . prime Provider . id ĊĠĠĠĠĠ Ġval Ġsummar ies Ġ= Ġref erral Repository . ref erral Summary For Service Providers ( listOf ( service Provider Search Id )) ĊĊĠĠĠĠĠ ĠassertThat ( sum maries . size ). isEqualTo ( 1 ) ĊĠĠĠĠĠ ĠassertThat ( contains ( sum maries , Ġexpected Summary ( ref erral With Single Assign ee ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` can Ġdetermine Ġlatest Ġassigned Ġuser Ġwhen Ġchanged `() Ġ{ ĊĠĠĠĠĠ Ġval Ġref erral With Changed Assign ee Ġ= Ġcreate Ref erral ( true , Ġ 2 ) ĊĊĠĠĠĠĠ Ġval Ġservice Provider Search Id Ġ= Ġref erral With Changed Assign ee . inter vention . dynamic Framework Contract . prime Provider . id ĊĠĠĠĠĠ Ġval Ġsummar ies Ġ= Ġref erral Repository . ref erral Summary For Service Providers ( listOf ( service Provider Search Id )) ĊĊĠĠĠĠĠ ĠassertThat ( sum maries . size ). isEqualTo ( 1 ) ĊĠĠĠĠĠ ĠassertThat ( contains ( sum maries , Ġexpected Summary ( ref erral With Changed Assign ee ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` can Ġobtain Ġmultiple Ġref err als Ġwith Ġlatest Ġassigned `() Ġ{ ĊĠĠĠĠĠ Ġval Ġref erral With Changed Assign ee Ġ= Ġcreate Ref erral ( true , Ġ 2 ) ĊĠĠĠĠĠ Ġval Ġref erral With Multiple Changed Assign ee Ġ= Ġcreate Ref erral ( true , Ġ 1 0 ) ĊĊĠĠĠĠĠ Ġval Ġservice Provider Search Ids Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ Ġref erral With Changed Assign ee . inter vention . dynamic Framework Contract . prime Provider . id , ĊĠĠĠĠĠĠĠ Ġref erral With Multiple Changed Assign ee . inter vention . dynamic Framework Contract . prime Provider . id ĊĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġval Ġsummar ies Ġ= Ġref erral Repository . ref erral Summary For Service Providers ( service Provider Search Ids ) ĊĊĠĠĠĠĠ ĠassertThat ( sum maries . size ). isEqualTo ( 2 ) ĊĠĠĠĠĠ ĠassertThat ( contains ( sum maries , Ġexpected Summary ( ref erral With Changed Assign ee ))) ĊĠĠĠĠĠ ĠassertThat ( contains ( sum maries , Ġexpected Summary ( ref erral With Multiple Changed Assign ee ))) ĊĠĠĠĠĠ Ġsummar ies . contains ( expected Summary ( ref erral With Changed Assign ee )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` will Ġnot Ġexclude Ġref erral Ġwhen Ġnot Ġassigned `() Ġ{ ĊĠĠĠĠĠ Ġval Ġref erral With No Assign ee Ġ= Ġcreate Ref erral ( true , Ġ 0 ) ĊĊĠĠĠĠĠ Ġval Ġservice Provider Search Id Ġ= Ġref erral With No Assign ee . inter vention . dynamic Framework Contract . prime Provider . id ĊĠĠĠĠĠ Ġval Ġsummar ies Ġ= Ġref erral Repository . ref erral Summary For Service Providers ( listOf ( service Provider Search Id )) ĊĊĠĠĠĠĠ ĠassertThat ( sum maries . size ). isEqualTo ( 1 ) ĊĠĠĠĠĠ ĠassertThat ( sum maries [ 0 ]. assigned To UserName ). isNull () ĊĠĠĠĠĠ ĠassertThat ( contains ( sum maries , Ġexpected Summary ( ref erral With No Assign ee ))) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Nested ĊĠ Ġinner Ġclass ĠStatus Ex clusion Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` will Ġexclude Ġcancelled Ġref err als `() Ġ{ ĊĠĠĠĠĠ Ġval Ġref erral Ġ= Ġcreate Ended Ref erral ( ĊĠĠĠĠĠĠĠ Ġtrue , ĊĠĠĠĠĠĠĠ Ġend Requested At Ġ= ĠOffset DateTime . now (), ĊĠĠĠĠĠĠĠ Ġcon clude d At Ġ= ĠOffset DateTime . now (), ĊĠĠĠĠĠĠĠ Ġeos R Ġ= Ġnull , ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġval Ġservice Provider Search Id Ġ= Ġref erral . inter vention . dynamic Framework Contract . prime Provider . id ĊĠĠĠĠĠ Ġval Ġsummar ies Ġ= Ġref erral Repository . ref erral Summary For Service Providers ( listOf ( service Provider Search Id )) ĊĊĠĠĠĠĠ ĠassertThat ( sum maries . size ). isEqualTo ( 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` can Ġobtain Ġthose Ġrequested Ġto Ġbe Ġended Ġand Ġnot Ġcon clude d `() Ġ{ ĊĠĠĠĠĠ Ġval Ġref erral Ġ= Ġcreate Ended Ref erral ( ĊĠĠĠĠĠĠĠ Ġtrue , ĊĠĠĠĠĠĠĠ Ġend Requested At Ġ= ĠOffset DateTime . now (), ĊĠĠĠĠĠĠĠ Ġcon clude d At Ġ= Ġnull , ĊĠĠĠĠĠĠĠ Ġeos R Ġ= Ġnull , ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġval Ġservice Provider Search Id Ġ= Ġref erral . inter vention . dynamic Framework Contract . prime Provider . id ĊĠĠĠĠĠ Ġval Ġsummar ies Ġ= Ġref erral Repository . ref erral Summary For Service Providers ( listOf ( service Provider Search Id )) ĊĊĠĠĠĠĠ ĠassertThat ( sum maries . size ). isEqualTo ( 1 ) ĊĠĠĠĠĠ ĠassertThat ( contains ( sum maries , Ġexpected Summary ( ref erral ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` can Ġobtain Ġprem ature ly Ġor Ġcompletely Ġended Ġref erral `() Ġ{ ĊĠĠĠĠĠ Ġval Ġref erral Ġ= Ġcreate Ended Ref erral ( ĊĠĠĠĠĠĠĠ Ġtrue , ĊĠĠĠĠĠĠĠ Ġend Requested At Ġ= Ġnull , ĊĠĠĠĠĠĠĠ Ġcon clude d At Ġ= ĠOffset DateTime . now (), ĊĠĠĠĠĠĠĠ Ġeos R Ġ= Ġend Of Service Report . create (), ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġval Ġservice Provider Search Id Ġ= Ġref erral . inter vention . dynamic Framework Contract . prime Provider . id ĊĠĠĠĠĠ Ġval Ġsummar ies Ġ= Ġref erral Repository . ref erral Summary For Service Providers ( listOf ( service Provider Search Id )) ĊĊĠĠĠĠĠ ĠassertThat ( sum maries . size ). isEqualTo ( 1 ) ĊĠĠĠĠĠ ĠassertThat ( contains ( sum maries , Ġexpected Summary ( ref erral ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` will Ġexclude Ġref erral Ġif Ġdraft `() Ġ{ ĊĠĠĠĠĠ Ġval Ġref erral With No Assign ee Ġ= Ġcreate Draft Ref erral ( true ) ĊĊĠĠĠĠĠ Ġval Ġservice Provider Search Id Ġ= Ġref erral With No Assign ee . inter vention . dynamic Framework Contract . prime Provider . id ĊĠĠĠĠĠ Ġval Ġsummar ies Ġ= Ġref erral Repository . ref erral Summary For Service Providers ( listOf ( service Provider Search Id )) ĊĊĠĠĠĠĠ ĠassertThat ( sum maries . size ). isEqualTo ( 0 ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate Ref erral ( ĊĠĠĠ Ġas Prime : ĠBoolean , ĊĠĠĠ ĠnumberOf Assigned Users : ĠInt Ġ= Ġ 1 ĊĠ Ġ): ĠRef erral Ġ{ ĊĊĠĠĠ Ġval Ġassigned Users Ġ= Ġmutable ListOf < Auth User >(). apply Ġ{ ĊĠĠĠĠĠ Ġrepeat ( numberOf Assigned Users ) Ġ{ Ġthis . add ( element Ġ= Ġauth User Factory . create ( random ( 6 ), Ġrandom ( 5 ), Ġrandom ( 1 2 ))) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġservice Provider Ġ= Ġservice Provider Factory . create ( random ( 1 3 ), Ġrandom ( 1 4 )) ĊĠĠĠ Ġval Ġcontract Ġ= Ġwhen Ġ{ ĊĠĠĠĠĠ Ġas Prime Ġ-> Ġdynamic Framework Contract Factory . create ( prime Provider Ġ= Ġservice Provider , Ġcontract Reference Ġ= Ġrandom ( 1 0 )) ĊĠĠĠĠĠ Ġelse Ġ-> Ġdynamic Framework Contract Factory . create ( sub contract or Providers Ġ= Ġset Of ( service Provider ), Ġcontract Reference Ġ= Ġrandom ( 1 0 )) ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġinter vention Ġ= Ġinter vention Factory . create ( contract Ġ= Ġcontract ) ĊĠĠĠ Ġval Ġref erral Ġ= Ġref erral Factory . create Sent ( ĊĠĠĠĠĠ Ġinter vention Ġ= Ġinter vention , ĊĠĠĠĠĠ Ġassignments Ġ= Ġassigned Users . map Ġ{ ĠRef erral Assignment ( Offset DateTime . now (), Ġassigned By Ġ= Ġit , Ġassigned To Ġ= Ġit ) Ġ} ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġservice User Ġ= Ġservice User Factory . create ( random ( 1 5 ), Ġrandom ( 1 6 ), Ġref erral ) ĊĊĠĠĠ Ġreturn Ġentity Manager . refresh ( ref erral ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate Ended Ref erral ( ĊĠĠĠ Ġas Prime : ĠBoolean , ĊĠĠĠ Ġend Requested At : ĠOffset DateTime ? Ġ= Ġnull , ĊĠĠĠ Ġcon clude d At : ĠOffset DateTime ? Ġ= Ġnull , ĊĠĠĠ Ġeos R : ĠEnd Of Service Report ? Ġ= Ġnull , ĊĠ Ġ): ĠRef erral Ġ{ ĊĊĠĠĠ Ġval Ġuser Ġ= Ġauth User Factory . create ( random ( 6 ), Ġrandom ( 5 ), Ġrandom ( 1 2 )) ĊĠĠĠ Ġval Ġservice Provider Ġ= Ġservice Provider Factory . create ( random ( 1 3 ), Ġrandom ( 1 4 )) ĊĠĠĠ Ġval Ġcontract Ġ= Ġwhen Ġ{ ĊĠĠĠĠĠ Ġas Prime Ġ-> Ġdynamic Framework Contract Factory . create ( prime Provider Ġ= Ġservice Provider , Ġcontract Reference Ġ= Ġrandom ( 1 0 )) ĊĠĠĠĠĠ Ġelse Ġ-> Ġdynamic Framework Contract Factory . create ( sub contract or Providers Ġ= Ġset Of ( service Provider ), Ġcontract Reference Ġ= Ġrandom ( 1 0 )) ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġinter vention Ġ= Ġinter vention Factory . create ( contract Ġ= Ġcontract ) ĊĠĠĠ Ġval Ġref erral Ġ= Ġref erral Factory . create Ended ( ĊĠĠĠĠĠ Ġinter vention Ġ= Ġinter vention , ĊĠĠĠĠĠ Ġassignments Ġ= ĠlistOf ( Ref erral Assignment ( Offset DateTime . now (), Ġassigned By Ġ= Ġuser , Ġassigned To Ġ= Ġuser )), ĊĠĠĠĠĠ Ġend Requested At Ġ= Ġend Requested At , ĊĠĠĠĠĠ Ġcon clude d At Ġ= Ġcon clude d At , ĊĠĠĠĠĠ Ġend Of Service Report Ġ= Ġeos R ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġservice User Ġ= Ġservice User Factory . create ( random ( 1 5 ), Ġrandom ( 1 6 ), Ġref erral ) ĊĊĠĠĠ Ġreturn Ġentity Manager . refresh ( ref erral ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate Draft Ref erral ( ĊĠĠĠ Ġas Prime : ĠBoolean ĊĠ Ġ): ĠRef erral Ġ{ ĊĊĠĠĠ Ġval Ġservice Provider Ġ= Ġservice Provider Factory . create ( random ( 1 3 ), Ġrandom ( 1 4 )) ĊĠĠĠ Ġval Ġcontract Ġ= Ġwhen Ġ{ ĊĠĠĠĠĠ Ġas Prime Ġ-> Ġdynamic Framework Contract Factory . create ( prime Provider Ġ= Ġservice Provider , Ġcontract Reference Ġ= Ġrandom ( 1 0 )) ĊĠĠĠĠĠ Ġelse Ġ-> Ġdynamic Framework Contract Factory . create ( sub contract or Providers Ġ= Ġset Of ( service Provider ), Ġcontract Reference Ġ= Ġrandom ( 1 0 )) ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġinter vention Ġ= Ġinter vention Factory . create ( contract Ġ= Ġcontract ) ĊĠĠĠ Ġval Ġref erral Ġ= Ġref erral Factory . create Draft ( inter vention Ġ= Ġinter vention ) ĊĠĠĠ Ġval Ġservice User Ġ= Ġservice User Factory . create ( random ( 1 5 ), Ġrandom ( 1 6 ), Ġref erral ) ĊĊĠĠĠ Ġreturn Ġentity Manager . refresh ( ref erral ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġrandom ( length : ĠInt ): ĠString Ġ{ ĊĠĠĠ Ġreturn ĠRandom StringUtils . random Alphabet ic ( length ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcontains ( sum maries : ĠList < ServiceProvider Sent Ref erral Summary >, Ġsummary : ĠSummary ): ĠBoolean Ġ{ ĊĠĠĠ Ġreturn Ġsummar ies . any Ġ{ ĊĠĠĠĠĠ Ġit . ref erral Id Ġ== Ġsummary . ref erral Id . toString () Ġ&& ĊĠĠĠĠĠĠĠ Ġit . sent At Ġ== Ġsummary . sent At Ġ&& ĊĠĠĠĠĠĠĠ Ġit . reference Number Ġ== Ġsummary . reference Number Ġ&& ĊĠĠĠĠĠĠĠ Ġit . inter vention Title Ġ== Ġsummary . inter vention Title Ġ&& ĊĠĠĠĠĠĠĠ Ġit . dynamic Frame Work Contract Id Ġ== Ġsummary . dynamic Frame Work Contract Id Ġ&& ĊĠĠĠĠĠĠĠ Ġit . assigned To UserName Ġ== Ġsummary . assigned To UserName Ġ&& ĊĠĠĠĠĠĠĠ Ġit . service User FirstName Ġ== Ġsummary . service User FirstName Ġ&& ĊĠĠĠĠĠĠĠ Ġit . service User LastName Ġ== Ġsummary . service User LastName Ġ&& ĊĠĠĠĠĠĠĠ Ġit . end Of Service Report Id Ġ== Ġsummary . end Of Service Report Id ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġexpected Summary ( ref erral : ĠRef erral ) Ġ= ĊĠĠĠ ĠSummary ( ĊĠĠĠĠĠ Ġref erral . id . toString (), ĊĠĠĠĠĠ Ġref erral . sent At !!. to Instant (), ĊĠĠĠĠĠ Ġref erral . reference Number !! , ĊĠĠĠĠĠ Ġref erral . inter vention . title , ĊĠĠĠĠĠ Ġref erral . inter vention . dynamic Framework Contract . id . toString (), ĊĠĠĠĠĠ Ġref erral . current Assign ee ?. id , ĊĠĠĠĠĠ Ġref erral . service UserData !!. firstName , ĊĠĠĠĠĠ Ġref erral . service UserData !!. lastName , ĊĠĠĠĠĠ Ġref erral . end Of Service Report ?. id ĊĠĠĠ Ġ) ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` service Ġprovider Ġreport Ġsanity Ġcheck `() Ġ{ ĊĠĠĠ Ġval Ġref erral Ġ= Ġref erral Factory . create Sent () ĊĠĠĠ Ġref erral Factory . create Sent ( sent At Ġ= ĠOffset DateTime . now (). minus Hours ( 2 ), Ġinter vention Ġ= Ġref erral . inter vention ) ĊĊĠĠĠ Ġval Ġref err als Ġ= Ġref erral Repository . service Provider Report Ref err als ( ĊĠĠĠĠĠ ĠOffset DateTime . now (). minus Hours ( 1 ), ĊĠĠĠĠĠ ĠOffset DateTime . now (). plus Hours ( 1 ), ĊĠĠĠĠĠ Ġset Of ( ref erral . inter vention . dynamic Framework Contract ), ĊĠĠĠĠĠ ĠPage Request . of ( 0 , Ġ 5 ), ĊĠĠĠ Ġ) ĊĊĠĠĠ ĠassertThat ( ref err als . numberOf Elements ). isEqualTo ( 1 ) ĊĠ Ġ} Ċ } Ċ Ċ data Ġclass ĠSummary ( ĊĠ Ġoverride Ġval Ġref erral Id : ĠString , ĊĠ Ġoverride Ġval Ġsent At : ĠInstant , ĊĠ Ġoverride Ġval Ġreference Number : ĠString , ĊĠ Ġoverride Ġval Ġinter vention Title : ĠString , ĊĠ Ġoverride Ġval Ġdynamic Frame Work Contract Id : ĠString , ĊĠ Ġoverride Ġval Ġassigned To UserName : ĠString ?, ĊĠ Ġoverride Ġval Ġservice User FirstName : ĠString ?, ĊĠ Ġoverride Ġval Ġservice User LastName : ĠString ?, ĊĠ Ġoverride Ġval Ġend Of Service Report Id : ĠUUID ?, Ċ ) Ġ: ĠService Provider Sent Ref erral Summary Ċ