package Ġuk . gov . just ice . digital . as sess ments . services Ċ Ċ import Ġio . mock k . every Ċ import Ġio . mock k . junit 5 . Mock K Extension Ċ import Ġio . mock k . just Run Ċ import Ġio . mock k . mock k Ċ import Ġio . mock k . verify Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . DisplayName Ċ import Ġorg . junit . jupiter . api . Nested Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . extension . Extend With Ċ import Ġuk . gov . just ice . digital . as sess ments . api . Update Assessment Episode Dto Ċ import Ġuk . gov . just ice . digital . as sess ments . jpa . entities . Assessment Schema Code Ċ import Ġuk . gov . just ice . digital . as sess ments . jpa . entities . as sess ments . Answers Ċ import Ġuk . gov . just ice . digital . as sess ments . jpa . entities . as sess ments . Assessment Entity Ċ import Ġuk . gov . just ice . digital . as sess ments . jpa . entities . as sess ments . Assessment Episode Entity Ċ import Ġuk . gov . just ice . digital . as sess ments . jpa . entities . as sess ments . Author Entity Ċ import Ġuk . gov . just ice . digital . as sess ments . jpa . entities . as sess ments . Subject Entity Ċ import Ġuk . gov . just ice . digital . as sess ments . jpa . entities . ref data . Answer Schema Entity Ċ import Ġuk . gov . just ice . digital . as sess ments . jpa . entities . ref data . Answer Schema Group Entity Ċ import Ġuk . gov . just ice . digital . as sess ments . jpa . entities . ref data . O AS ys Mapping Entity Ċ import Ġuk . gov . just ice . digital . as sess ments . jpa . entities . ref data . O as ys Assessment Type Ċ import Ġuk . gov . just ice . digital . as sess ments . jpa . entities . ref data . Question Schema Entity Ċ import Ġuk . gov . just ice . digital . as sess ments . jpa . repositories . as sess ments . Assessment Repository Ċ import Ġuk . gov . just ice . digital . as sess ments . jpa . repositories . as sess ments . Episode Repository Ċ import Ġuk . gov . just ice . digital . as sess ments . rest client . Assessment Update RestClient Ċ import Ġuk . gov . just ice . digital . as sess ments . rest client . assessment update api . Update Assessment Answers Response Dto Ċ import Ġuk . gov . just ice . digital . as sess ments . rest client . assessment update api . ValidationError Dto Ċ import Ġuk . gov . just ice . digital . as sess ments . services . dto . Assessment Episode Update Errors Ċ import Ġuk . gov . just ice . digital . as sess ments . services . dto . O as ys Answer Ċ import Ġuk . gov . just ice . digital . as sess ments . services . dto . O as ys Answers Ċ import Ġuk . gov . just ice . digital . as sess ments . test utils . Verify Ċ import Ġjava . time . LocalDate Ċ import Ġjava . time . LocalDateTime Ċ import Ġjava . util . UUID Ċ Ċ @ Extend With ( Mock K Extension :: class ) Ċ @ DisplayName (" Assessment ĠService ĠO AS ys ĠTests ") Ċ class ĠAssessment Update Service O AS ys Test Ġ{ ĊĠ Ġprivate Ġval Ġassessment Repository : ĠAssessment Repository Ġ= Ġmock k () ĊĠ Ġprivate Ġval Ġepisode Repository : ĠEp isode Repository Ġ= Ġmock k () ĊĠ Ġprivate Ġval Ġquestion Service : ĠQuestion Service Ġ= Ġmock k () ĊĠ Ġprivate Ġval Ġassessment Update RestClient : ĠAssessment Update RestClient Ġ= Ġmock k () ĊĠ Ġprivate Ġval Ġrisk Predict ors Service : ĠR isk Predict ors Service Ġ= Ġmock k () ĊĠ Ġprivate Ġval Ġassessment Schema Service : ĠAssessment Schema Service Ġ= Ġmock k () ĊĠ Ġprivate Ġval Ġo as ys Assessment Update Service : ĠO as ys Assessment Update Service Ġ= Ġmock k () ĊĠ Ġprivate Ġval Ġassessment Service : ĠAssessment Service Ġ= Ġmock k () ĊĠ Ġprivate Ġval Ġauthor Service : ĠAuthor Service Ġ= Ġmock k () ĊĠ Ġprivate Ġval Ġaudit Service : ĠAudit Service Ġ= Ġmock k () ĊĠ Ġprivate Ġval Ġtelemetry Service : ĠTe lemetry Service Ġ= Ġmock k () ĊĊĠ Ġprivate Ġval Ġassess ments Update Service Ġ= ĠAssessment Update Service ( ĊĠĠĠ Ġassessment Repository , ĊĠĠĠ Ġepisode Repository , ĊĠĠĠ Ġquestion Service , ĊĠĠĠ Ġrisk Predict ors Service , ĊĠĠĠ Ġo as ys Assessment Update Service , ĊĠĠĠ Ġassessment Service , ĊĠĠĠ Ġauthor Service , ĊĠĠĠ Ġaudit Service , ĊĠĠĠ Ġtelemetry Service ĊĠ Ġ) ĊĊĠ Ġprivate Ġval Ġassessment Id Ġ= Ġ 1 L ĊĠ Ġprivate Ġval Ġo as ys Assessment Type Ġ= ĠO as ys Assessment Type . SHORT _ FORM _ PS R ĊĠ Ġprivate Ġval Ġo as ys Set Pk Ġ= Ġ 1 L ĊĊĠ Ġprivate Ġval Ġepisode Id 1 Ġ= Ġ 1 L ĊĠ Ġprivate Ġval Ġepisode Id 2 Ġ= Ġ 2 L ĊĊĠ Ġprivate Ġval Ġepisode Uuid Ġ= ĠUUID . randomUUID () ĊĊĠ Ġprivate Ġval Ġexisting Question Code Ġ= Ġ" existing _ question _ code " ĊĊĠ Ġprivate Ġval Ġquestion Code 1 Ġ= Ġ" question _ code _ 1 " ĊĠ Ġprivate Ġval Ġquestion Code 2 Ġ= Ġ" question _ code _ 2 " ĊĠ Ġprivate Ġval Ġquestion Code 3 Ġ= Ġ" question _ code _ 3 " ĊĠ Ġprivate Ġval Ġanswer 1 Uuid Ġ= ĠUUID . randomUUID () ĊĠ Ġprivate Ġval Ġanswer 2 Uuid Ġ= ĠUUID . randomUUID () ĊĠ Ġprivate Ġval Ġanswer 3 Uuid Ġ= ĠUUID . randomUUID () ĊĊĠ Ġ@ BeforeEach ĊĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠ Ġevery Ġ{ Ġassessment Schema Service . to O as ys Assessment Type ( Assessment Schema Code . RO SH ) Ġ} Ġreturns ĠO as ys Assessment Type . SHORT _ FORM _ PS R ĊĠĠĠ Ġevery Ġ{ Ġassessment Schema Service . to O as ys Assessment Type ( Assessment Schema Code . R SR ) Ġ} Ġreturns ĠO as ys Assessment Type . SO METH ING _ IN _ O AS YS ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` map ĠO as ys Ġanswer Ġfrom Ġfree Ġtext Ġanswer `() Ġ{ ĊĠĠĠ Ġval Ġmapping Ġ= ĠO AS ys Mapping Entity ( ĊĠĠĠĠĠ Ġsection Code Ġ= Ġ" 1 ", ĊĠĠĠĠĠ Ġquestion Code Ġ= Ġ" R 1 . 3 ", ĊĠĠĠĠĠ Ġlogical Page Ġ= Ġ 1 , ĊĠĠĠĠĠ Ġfixed _ field Ġ= Ġfalse , ĊĠĠĠĠĠ Ġmapping Id Ġ= Ġ 1 , ĊĠĠĠĠĠ Ġquestion Schema Ġ= ĠQuestion Schema Entity ( question Schema Id Ġ= Ġ 1 , Ġquestion Code Ġ= Ġ" question _ code ") ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġresult Ġ= ĠO as ys Answers . map O as ys Answers ( mapping , ĠlistOf (" Free ĠText "), Ġ" rad ios ")[ 0 ] ĊĊĠĠĠ ĠassertThat ( result . answer ). isEqualTo (" Free ĠText ") ĊĠĠĠ ĠassertThat ( result . logical Page ). isEqualTo ( 1 ) ĊĠĠĠ ĠassertThat ( result . is Static ). isFalse ĊĠĠĠ ĠassertThat ( result . question Code ). isEqualTo (" R 1 . 3 ") ĊĠĠĠ ĠassertThat ( result . section Code ). isEqualTo (" 1 ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` map ĠO as ys Ġanswer Ġwith Ġcorrect Ġdate Ġformat `() Ġ{ ĊĠĠĠ Ġval Ġmapping Ġ= ĠO AS ys Mapping Entity ( ĊĠĠĠĠĠ Ġsection Code Ġ= Ġ" 1 ", ĊĠĠĠĠĠ Ġquestion Code Ġ= Ġ" R 1 . 3 ", ĊĠĠĠĠĠ Ġlogical Page Ġ= Ġ 1 , ĊĠĠĠĠĠ Ġfixed _ field Ġ= Ġfalse , ĊĠĠĠĠĠ Ġmapping Id Ġ= Ġ 1 , ĊĠĠĠĠĠ Ġquestion Schema Ġ= ĠQuestion Schema Entity ( question Schema Id Ġ= Ġ 1 , Ġquestion Code Ġ= Ġ" question _ code ") ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġresult Ġ= ĠO as ys Answers . map O as ys Answers ( mapping , ĠlistOf (" 1 9 7 5 - 0 1 - 2 0 T 0 0 : 0 0 : 0 0 . 0 0 0 Z "), Ġ" date ")[ 0 ] ĊĊĠĠĠ ĠassertThat ( result . answer ). isEqualTo (" 2 0 / 0 1 / 1 9 7 5 ") ĊĠĠĠ ĠassertThat ( result . logical Page ). isEqualTo ( 1 ) ĊĠĠĠ ĠassertThat ( result . is Static ). isFalse ĊĠĠĠ ĠassertThat ( result . question Code ). isEqualTo (" R 1 . 3 ") ĊĠĠĠ ĠassertThat ( result . section Code ). isEqualTo (" 1 ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` map ĠO as ys Ġanswers Ġfrom ĠAR N Ġquestions Ġand Ġanswers `() Ġ{ ĊĠĠĠ Ġval Ġanswers Ġ= Ġmutable Map Of ( ĊĠĠĠĠĠ Ġquestion Code 1 Ġto ĠlistOf (" some Ġfree Ġtext "), ĊĠĠĠĠĠ Ġquestion Code 2 Ġto ĠlistOf (" 1 9 7 5 - 0 1 - 2 0 T 0 0 : 0 0 : 0 0 . 0 0 0 Z "), ĊĠĠĠĠĠ Ġquestion Code 3 Ġto ĠlistOf (" not Ġmapped Ġto Ġo as ys "), ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġepisode Ġ= ĠAssessment Episode Entity ( ĊĠĠĠĠĠ Ġanswers Ġ= Ġanswers , ĊĠĠĠĠĠ Ġcreated Date Ġ= ĠLocalDateTime . now (), ĊĠĠĠĠĠ Ġassessment Schema Code Ġ= ĠAssessment Schema Code . RO SH , ĊĠĠĠĠĠ Ġauthor Ġ= ĠAuthor Entity ( userId Ġ= Ġ" 1 ", ĠuserName Ġ= Ġ" USER ", Ġuser Auth Source Ġ= Ġ" source ", Ġuser FullName Ġ= Ġ" full Ġname "), ĊĠĠĠĠĠ Ġassessment Ġ= ĠAssessment Entity () ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġquestions Ġ= ĠQuestion Schema Entities ( ĊĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠ Ġmake Question ( 1 , Ġquestion Code 1 , Ġ" freet ext ", Ġnull , Ġ" section 1 ", Ġ 1 , Ġ" name "), ĊĠĠĠĠĠĠĠ Ġmake Question ( 2 , Ġquestion Code 2 , Ġ" date ", Ġnull , Ġ" section 1 ", Ġ 1 , Ġ" dob "), ĊĠĠĠĠĠĠĠ Ġmake Question ( 3 , Ġquestion Code 3 ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġo as ys Answers Ġ= ĠO as ys Answers . from ( ĊĠĠĠĠĠ Ġepisode , ĊĠĠĠĠĠ Ġobject Ġ: ĠO as ys Answers . Companion . Mapping Provider Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun ĠgetAll Questions (): ĠQuestion Schema Entities Ġ= Ġquestions ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġget Table Questions ( table Code : ĠString ): ĠQuestion Schema Entities Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġthrow ĠRuntimeException (" Should Ġnot Ġbe Ġcalled ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĊĠĠĠ ĠassertThat ( o as ys Answers ). has Size ( 2 ) ĊĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" section 1 ", Ġ 1 , Ġ" name ", Ġ" some Ġfree Ġtext ")) ĊĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" section 1 ", Ġ 1 , Ġ" dob ", Ġ" 2 0 / 0 1 / 1 9 7 5 ")) ĊĠ Ġ} ĊĊĠ Ġ@ Nested ĊĠ Ġ@ DisplayName (" map ĠO as ys Ġanswers Ġfrom ĠAR N Ġquestions Ġand Ġanswers Ġwith Ġchildren ") ĊĠ Ġinner Ġclass ĠWith Children Ġ{ ĊĠĠĠ Ġprivate Ġval Ġtable Question Ġ= Ġ" table _ question " ĊĠĠĠ Ġprivate Ġval Ġchild Question 1 Ġ= Ġ" child _ question _ one " ĊĠĠĠ Ġprivate Ġval Ġchild Question 2 Ġ= Ġ" child _ question _ two " ĊĊĠĠĠ Ġprivate Ġval Ġchild Name Question Ġ= ĊĠĠĠĠĠ Ġmake Question ( 1 0 , Ġchild Question 1 , Ġ" freet ext ", Ġnull , Ġ" children ", Ġnull , Ġ" child name ") ĊĠĠĠ Ġprivate Ġval Ġchild Address Question Ġ= ĊĠĠĠĠĠ Ġmake Question ( 1 1 , Ġchild Question 2 , Ġ" freet ext ", Ġnull , Ġ" children ", Ġnull , Ġ" child address ") ĊĊĠĠĠ Ġval Ġall Questions Ġ= ĠQuestion Schema Entities ( ĊĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠ Ġmake Question ( 1 , Ġquestion Code 1 , Ġ" freet ext ", Ġnull , Ġ" section 1 ", Ġ 1 , Ġ" name "), ĊĠĠĠĠĠĠĠ Ġmake Question ( 2 , Ġquestion Code 2 , Ġ" date ", Ġnull , Ġ" section 1 ", Ġ 1 , Ġ" dob "), ĊĠĠĠĠĠĠĠ Ġmake Question ( 3 , Ġquestion Code 3 ), ĊĠĠĠĠĠĠĠ Ġmake Question ( 4 , Ġtable Question , Ġ" table : children _ at _ risk "), ĊĠĠĠĠĠĠĠ Ġchild Name Question , ĊĠĠĠĠĠĠĠ Ġchild Address Question ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġchild Table Questions Ġ= ĠQuestion Schema Entities ( ĊĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠ Ġchild Name Question , ĊĠĠĠĠĠĠĠ Ġchild Address Question ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġprivate Ġval Ġtest Mapper Ġ= Ġobject Ġ: ĠO as ys Answers . Companion . Mapping Provider Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun ĠgetAll Questions (): ĠQuestion Schema Entities Ġ= Ġall Questions ĊĠĠĠĠĠ Ġoverride Ġfun Ġget Table Questions ( table Code : ĠString ): ĠQuestion Schema Entities Ġ= ĊĠĠĠĠĠĠĠ Ġif Ġ( table Code Ġ== Ġ" children _ at _ risk ") ĊĠĠĠĠĠĠĠĠĠ Ġchild Table Questions ĊĠĠĠĠĠĠĠ Ġelse ĊĠĠĠĠĠĠĠĠĠ Ġthrow ĠRuntimeException (" Should Ġonly Ġbe Ġcalled Ġfor Ġchildren _ at _ risk Ġtable ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` with Ġone Ġchild `() Ġ{ ĊĠĠĠĠĠ Ġval Ġanswers Ġ= Ġmutable Map Of ( ĊĠĠĠĠĠĠĠ Ġquestion Code 1 Ġto ĠlistOf (" some Ġfree Ġtext "), ĊĠĠĠĠĠĠĠ Ġquestion Code 2 Ġto ĠlistOf (" 1 9 7 5 - 0 1 - 2 0 T 0 0 : 0 0 : 0 0 . 0 0 0 Z "), ĊĠĠĠĠĠĠĠ Ġquestion Code 3 Ġto ĠlistOf (" not Ġmapped Ġto Ġo as ys "), ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġval Ġtables Ġ= Ġmutable Map Of ( ĊĠĠĠĠĠĠĠ Ġ" children _ at _ risk " Ġto Ġmutable ListOf ( ĊĠĠĠĠĠĠĠĠĠ Ġmap Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchild Question 1 Ġto ĠlistOf (" child Ġname "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchild Question 2 Ġto ĠlistOf (" child Ġaddress "), ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġval Ġepisode Ġ= ĠAssessment Episode Entity ( ĊĠĠĠĠĠĠĠ Ġanswers Ġ= Ġanswers , ĊĠĠĠĠĠĠĠ Ġcreated Date Ġ= ĠLocalDateTime . now (), ĊĠĠĠĠĠĠĠ Ġassessment Schema Code Ġ= ĠAssessment Schema Code . RO SH , ĊĠĠĠĠĠĠĠ Ġtables Ġ= Ġtables , ĊĠĠĠĠĠĠĠ Ġauthor Ġ= ĠAuthor Entity ( userId Ġ= Ġ" 1 ", ĠuserName Ġ= Ġ" USER ", Ġuser Auth Source Ġ= Ġ" source ", Ġuser FullName Ġ= Ġ" full Ġname "), ĊĠĠĠĠĠĠĠ Ġassessment Ġ= ĠAssessment Entity () ĊĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġval Ġo as ys Answers Ġ= ĠO as ys Answers . from ( episode , Ġtest Mapper ) ĊĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). has Size ( 4 ) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" section 1 ", Ġ 1 , Ġ" name ", Ġ" some Ġfree Ġtext ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" section 1 ", Ġ 1 , Ġ" dob ", Ġ" 2 0 / 0 1 / 1 9 7 5 ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" children ", Ġ 0 , Ġ" child name ", Ġ" child Ġname ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" children ", Ġ 0 , Ġ" child address ", Ġ" child Ġaddress ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` with Ġmultiple Ġchildren `() Ġ{ ĊĠĠĠĠĠ Ġval Ġanswers Ġ= Ġmutable Map Of ( ĊĠĠĠĠĠĠĠ Ġquestion Code 1 Ġto ĠlistOf (" some Ġfree Ġtext "), ĊĠĠĠĠĠĠĠ Ġquestion Code 2 Ġto ĠlistOf (" 1 9 7 5 - 0 1 - 2 0 T 0 0 : 0 0 : 0 0 . 0 0 0 Z "), ĊĠĠĠĠĠĠĠ Ġquestion Code 3 Ġto ĠlistOf (" not Ġmapped Ġto Ġo as ys "), ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġval Ġtables Ġ= Ġmutable Map Of ( ĊĠĠĠĠĠĠĠ Ġ" children _ at _ risk " Ġto Ġmutable ListOf ( ĊĠĠĠĠĠĠĠĠĠ Ġmap Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchild Question 1 Ġto ĠlistOf (" name 1 "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchild Question 2 Ġto ĠlistOf (" address 1 "), ĊĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠ Ġmap Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchild Question 1 Ġto ĠlistOf (" name 2 "), ĊĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠ Ġmap Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchild Question 1 Ġto ĠlistOf (" name 3 "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchild Question 2 Ġto ĠlistOf (" address 3 "), ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġval Ġepisode Ġ= ĠAssessment Episode Entity ( ĊĠĠĠĠĠĠĠ Ġanswers Ġ= Ġanswers , ĊĠĠĠĠĠĠĠ Ġcreated Date Ġ= ĠLocalDateTime . now (), ĊĠĠĠĠĠĠĠ Ġassessment Schema Code Ġ= ĠAssessment Schema Code . RO SH , ĊĠĠĠĠĠĠĠ Ġtables Ġ= Ġtables , ĊĠĠĠĠĠĠĠ Ġauthor Ġ= ĠAuthor Entity ( userId Ġ= Ġ" 1 ", ĠuserName Ġ= Ġ" USER ", Ġuser Auth Source Ġ= Ġ" source ", Ġuser FullName Ġ= Ġ" full Ġname "), ĊĠĠĠĠĠĠĠ Ġassessment Ġ= ĠAssessment Entity () ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġval Ġo as ys Answers Ġ= ĠO as ys Answers . from ( episode , Ġtest Mapper ) ĊĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). has Size ( 7 ) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" section 1 ", Ġ 1 , Ġ" name ", Ġ" some Ġfree Ġtext ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" section 1 ", Ġ 1 , Ġ" dob ", Ġ" 2 0 / 0 1 / 1 9 7 5 ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" children ", Ġ 0 , Ġ" child name ", Ġ" name 1 ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" children ", Ġ 0 , Ġ" child address ", Ġ" address 1 ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" children ", Ġ 1 , Ġ" child name ", Ġ" name 2 ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" children ", Ġ 2 , Ġ" child name ", Ġ" name 3 ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" children ", Ġ 2 , Ġ" child address ", Ġ" address 3 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` with Ġmultiple Ġchildren Ġwith Ġmulti - value Ġanswer `() Ġ{ ĊĠĠĠĠĠ Ġval Ġanswers Ġ= Ġmutable Map Of ( ĊĠĠĠĠĠĠĠ Ġquestion Code 1 Ġto ĠlistOf (" some Ġfree Ġtext "), ĊĠĠĠĠĠĠĠ Ġquestion Code 2 Ġto ĠlistOf (" 1 9 7 5 - 0 1 - 2 0 T 0 0 : 0 0 : 0 0 . 0 0 0 Z "), ĊĠĠĠĠĠĠĠ Ġquestion Code 3 Ġto ĠlistOf (" not Ġmapped Ġto Ġo as ys "), ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġval Ġtables Ġ= Ġmutable Map Of ( ĊĠĠĠĠĠĠĠ Ġ" children _ at _ risk " Ġto Ġmutable ListOf ( ĊĠĠĠĠĠĠĠĠĠ Ġmap Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchild Question 1 Ġto ĠlistOf (" name 1 "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchild Question 2 Ġto ĠlistOf (" address 1 "), ĊĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠ Ġmap Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchild Question 1 Ġto ĠlistOf (" name 2 "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchild Question 2 Ġto ĠlistOf (" address 2 a ", Ġ" address 2 b "), ĊĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠ Ġmap Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchild Question 1 Ġto ĠlistOf (" name 3 "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchild Question 2 Ġto ĠlistOf (" address 3 "), ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġval Ġepisode Ġ= ĠAssessment Episode Entity ( ĊĠĠĠĠĠĠĠ Ġanswers Ġ= Ġanswers , ĊĠĠĠĠĠĠĠ Ġcreated Date Ġ= ĠLocalDateTime . now (), ĊĠĠĠĠĠĠĠ Ġassessment Schema Code Ġ= ĠAssessment Schema Code . RO SH , ĊĠĠĠĠĠĠĠ Ġtables Ġ= Ġtables , ĊĠĠĠĠĠĠĠ Ġauthor Ġ= ĠAuthor Entity ( userId Ġ= Ġ" 1 ", ĠuserName Ġ= Ġ" USER ", Ġuser Auth Source Ġ= Ġ" source ", Ġuser FullName Ġ= Ġ" full Ġname "), ĊĠĠĠĠĠĠĠ Ġassessment Ġ= ĠAssessment Entity () ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġval Ġo as ys Answers Ġ= ĠO as ys Answers . from ( episode , Ġtest Mapper ) ĊĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). has Size ( 9 ) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" section 1 ", Ġ 1 , Ġ" name ", Ġ" some Ġfree Ġtext ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" section 1 ", Ġ 1 , Ġ" dob ", Ġ" 2 0 / 0 1 / 1 9 7 5 ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" children ", Ġ 0 , Ġ" child name ", Ġ" name 1 ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" children ", Ġ 0 , Ġ" child address ", Ġ" address 1 ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" children ", Ġ 1 , Ġ" child name ", Ġ" name 2 ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" children ", Ġ 1 , Ġ" child address ", Ġ" address 2 a ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" children ", Ġ 1 , Ġ" child address ", Ġ" address 2 b ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" children ", Ġ 2 , Ġ" child name ", Ġ" name 3 ")) ĊĠĠĠĠĠ ĠassertThat ( o as ys Answers ). contains ( O as ys Answer (" children ", Ġ 2 , Ġ" child address ", Ġ" address 3 ")) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` returns Ġvalidation Ġerrors Ġfrom ĠO AS ys `() Ġ{ ĊĠĠĠ Ġval Ġquestion Ġ= Ġmake Question ( 9 , Ġexisting Question Code , Ġ" freet ext ", Ġnull , Ġ" section 1 ", Ġnull , Ġ" Q 1 ") ĊĠĠĠ Ġevery Ġ{ Ġquestion Service . getAll Questions () Ġ} Ġreturns ĠQuestion Schema Entities ( listOf ( question )) ĊĠĠĠ Ġjust Run Ġ{ Ġaudit Service . create Audit Event ( any (), Ġany (), Ġany (), Ġany (), Ġany (), Ġany ()) Ġ} ĊĠĠĠ Ġjust Run Ġ{ ĊĠĠĠĠĠ Ġtelemetry Service . track Assessment Event ( ĊĠĠĠĠĠĠĠ ĠTe lemetry EventType . AS SESS MENT _ RE ALLOC ATED , ĊĠĠĠĠĠĠĠ Ġany (), ĊĠĠĠĠĠĠĠ Ġany (), ĊĠĠĠĠĠĠĠ Ġany (), ĊĠĠĠĠĠĠĠ Ġany (), ĊĠĠĠĠĠĠĠ Ġany () ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġassessment Ġ= Ġassessment Entity With O as ys Off ender ( ĊĠĠĠĠĠ Ġmutable Map Of ( ĊĠĠĠĠĠĠĠ Ġexisting Question Code Ġto ĠlistOf (" free Ġtext ", Ġ" fruit Ġloops ", Ġ" bis cu its ") ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġassessment Episode Ġ= ĠAssessment Episode Entity ( ĊĠĠĠĠĠ Ġepisode Id Ġ= Ġepisode Id 1 , ĊĠĠĠĠĠ Ġassessment Schema Code Ġ= ĠAssessment Schema Code . RO SH , ĊĠĠĠĠĠ Ġcreated Date Ġ= ĠLocalDateTime . now (), ĊĠĠĠĠĠ Ġo as ys Set Pk Ġ= Ġo as ys Set Pk , ĊĠĠĠĠĠ Ġassessment Ġ= Ġassessment , ĊĠĠĠĠĠ Ġauthor Ġ= ĠAuthor Entity ( userId Ġ= Ġ" 1 ", ĠuserName Ġ= Ġ" USER ", Ġuser Auth Source Ġ= Ġ" source ", Ġuser FullName Ġ= Ġ" full Ġname "), ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġevery Ġ{ ĊĠĠĠĠĠ Ġo as ys Assessment Update Service . update O AS ys Assessment ( ĊĠĠĠĠĠĠĠ Ġassessment Episode , ĊĠĠĠĠĠĠĠ Ġany () ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ġreturns ĠAssessment Episode Update Errors ( ĊĠĠĠĠĠ Ġanswer Errors Ġ= Ġmutable Map Of ( existing Question Code Ġto Ġmutable ListOf (" NO ")) ĊĠĠĠ Ġ) ĊĠĠĠ Ġevery Ġ{ Ġassessment Repository . save ( any ()) Ġ} Ġreturns Ġnull Ġ// Ġshould Ġsave Ġwhen Ġerrors ? ĊĠĠĠ Ġevery Ġ{ Ġquestion Service . getAll Section Questions For Questions ( any ()) Ġ} Ġreturns ĠQuestion Schema Entities ( questions List Ġ= Ġempty List ()) ĊĊĠĠĠ Ġval Ġo as ys Error Ġ= ĠUpdate Assessment Answers Response Dto ( ĊĠĠĠĠĠĠ 7 7 7 7 , ĊĠĠĠĠĠ Ġset Of ( ĊĠĠĠĠĠĠĠ ĠValidationError Dto ( ĊĠĠĠĠĠĠĠĠĠ Ġ" section 1 ", ĊĠĠĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠĠĠ Ġ" Q 1 ", ĊĠĠĠĠĠĠĠĠĠ Ġ" O OPS ", ĊĠĠĠĠĠĠĠĠĠ Ġ" NO ", ĊĠĠĠĠĠĠĠĠĠ Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠĠĠ Ġevery Ġ{ ĊĠĠĠĠĠ Ġassessment Update RestClient . update Assessment ( ĊĠĠĠĠĠĠĠ Ġany (), ĊĠĠĠĠĠĠĠ Ġo as ys Assessment Type , ĊĠĠĠĠĠĠĠ Ġo as ys Set Pk , ĊĠĠĠĠĠĠĠ Ġany () ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ġreturns Ġo as ys Error ĊĠĠĠ Ġ// ĠChrist , Ġwhat Ġa Ġlot Ġof Ġset Ġup ĊĊĠĠĠ Ġval Ġauthor Ġ= ĠAuthor Entity ( userId Ġ= Ġ" 1 ", ĠuserName Ġ= Ġ" USER ", Ġuser Auth Source Ġ= Ġ" source ", Ġuser FullName Ġ= Ġ" full Ġname ") ĊĠĠĠ Ġevery Ġ{ Ġauthor Service . get OrCreate Author () Ġ} Ġreturns Ġauthor ĊĊĠĠĠ Ġ// ĠApply Ġthe Ġupdate ĊĠĠĠ Ġval Ġupdated Answers Ġ= ĠUpdate Assessment Episode Dto ( ĊĠĠĠĠĠ Ġmap Of ( existing Question Code Ġto ĠlistOf (" fruit Ġloops ", Ġ" cust ard ")) ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġepisode Dto Ġ= Ġassess ments Update Service . update Episode ( assessment Episode , Ġupdated Answers ) ĊĊĠĠĠ Ġ// ĠUpdated Ġanswers Ġin Ġreturned ĠD TO ĊĠĠĠ ĠassertThat ( episode Dto . answers ). has Size ( 1 ) ĊĠĠĠ ĠVerify . multi Answers ( ĊĠĠĠĠĠ Ġepisode Dto . answers [ existing Question Code ] !! , ĊĠĠĠĠĠ Ġ" fruit Ġloops ", ĊĠĠĠĠĠ Ġ" cust ard " ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ// ĠBut Ġalso Ġerrors ! ĊĠĠĠ ĠassertThat ( episode Dto . errors ). has Size ( 1 ) ĊĠĠĠ Ġwith ( episode Dto . errors ! ![ existing Question Code ] !! ) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( size ). isEqualTo ( 1 ) ĊĠĠĠĠĠ ĠassertThat ( this ). contains (" NO ") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` update Ġepisode Ġcalls Ġupdate O AS ys Assessment Ġwith Ġthe Ġupdated Ġanswers `() Ġ{ ĊĠĠĠ Ġval Ġassessment Episode Ġ= Ġsetup Episode () ĊĠĠĠ Ġjust Run Ġ{ Ġaudit Service . create Audit Event ( any (), Ġany (), Ġany (), Ġany (), Ġany (), Ġany ()) Ġ} ĊĠĠĠ Ġjust Run Ġ{ ĊĠĠĠĠĠ Ġtelemetry Service . track Assessment Event ( ĊĠĠĠĠĠĠĠ ĠTe lemetry EventType . AS SESS MENT _ RE ALLOC ATED , ĊĠĠĠĠĠĠĠ Ġany (), ĊĠĠĠĠĠĠĠ Ġany (), ĊĠĠĠĠĠĠĠ Ġany (), ĊĠĠĠĠĠĠĠ Ġany (), ĊĠĠĠĠĠĠĠ Ġany () ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġevery Ġ{ Ġquestion Service . getAll Section Questions For Questions ( listOf ( question Code 1 )) Ġ} Ġreturns Ġsetup Section Question Codes () ĊĊĠĠĠ Ġval Ġupdate Ġ= ĠUpdate Assessment Episode Dto ( answers Ġ= Ġmap Of ( question Code 1 Ġto ĠlistOf (" Updated "))) ĊĠĠĠ Ġevery Ġ{ ĊĠĠĠĠĠ Ġo as ys Assessment Update Service . update O AS ys Assessment ( assessment Episode , Ġupdate . answers ) ĊĠĠĠ Ġ} Ġreturns ĠAssessment Episode Update Errors () ĊĠĠĠ Ġevery Ġ{ Ġquestion Service . getAll Questions () Ġ} Ġreturns Ġsetup Question Codes () ĊĠĠĠ Ġevery Ġ{ Ġassessment Repository . save ( any ()) Ġ} Ġreturns Ġmock k () ĊĠĠĠ Ġval Ġauthor Ġ= ĠAuthor Entity ( userId Ġ= Ġ" 1 ", ĠuserName Ġ= Ġ" USER ", Ġuser Auth Source Ġ= Ġ" source ", Ġuser FullName Ġ= Ġ" full Ġname ") ĊĠĠĠ Ġevery Ġ{ Ġauthor Service . get OrCreate Author () Ġ} Ġreturns Ġauthor ĊĊĠĠĠ Ġval Ġupdated Episode Ġ= Ġassess ments Update Service . update Episode ( assessment Episode , Ġupdate ) ĊĊĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ ĊĠĠĠĠĠ Ġo as ys Assessment Update Service . update O AS ys Assessment ( ĊĠĠĠĠĠĠĠ Ġassessment Episode , ĊĠĠĠĠĠĠĠ Ġupdate . answers , ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġwith ( updated Episode . answers ) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( map Ġ{ Ġit . key Ġ}). contains Only Once ( question Code 1 , Ġquestion Code 2 ) ĊĠĠĠĠĠ ĠassertThat ( map Ġ{ Ġit . value Ġ}). contains ( ĊĠĠĠĠĠĠĠ ĠlistOf (" Updated "), ĊĠĠĠĠĠĠĠ ĠlistOf (" 1 9 7 5 - 0 1 - 2 0 T 0 0 : 0 0 : 0 0 . 0 0 0 Z "), ĊĠĠĠĠĠĠĠ ĠlistOf (" not Ġmapped Ġto Ġo as ys "), ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġsetup Question Codes (): ĠQuestion Schema Entities Ġ{ ĊĠĠĠ Ġval Ġdummy Ġ= ĠAnswer Schema Group Entity ( answer Schema Id Ġ= Ġ 9 9 ) ĊĊĠĠĠ Ġval Ġyes Ġ= ĊĠĠĠĠĠ ĠAnswer Schema Entity ( answer Schema Id Ġ= Ġ 1 , Ġanswer Schema Uuid Ġ= Ġanswer 1 Uuid , Ġvalue Ġ= Ġ" YES ", Ġanswer Schema Group Ġ= Ġdummy ) ĊĠĠĠ Ġval Ġmaybe Ġ= ĊĠĠĠĠĠ ĠAnswer Schema Entity ( answer Schema Id Ġ= Ġ 2 , Ġanswer Schema Uuid Ġ= Ġanswer 2 Uuid , Ġvalue Ġ= Ġ" MAYBE ", Ġanswer Schema Group Ġ= Ġdummy ) ĊĠĠĠ Ġval Ġno Ġ= ĊĠĠĠĠĠ ĠAnswer Schema Entity ( answer Schema Id Ġ= Ġ 3 , Ġanswer Schema Uuid Ġ= Ġanswer 3 Uuid , Ġvalue Ġ= Ġ" NO ", Ġanswer Schema Group Ġ= Ġdummy ) ĊĊĠĠĠ Ġval Ġgroup 1 Ġ= ĠAnswer Schema Group Entity ( answer Schema Id Ġ= Ġ 1 , Ġanswer Schema Entities Ġ= ĠlistOf ( yes )) ĊĠĠĠ Ġval Ġgroup 2 Ġ= ĠAnswer Schema Group Entity ( answer Schema Id Ġ= Ġ 2 , Ġanswer Schema Entities Ġ= ĠlistOf ( maybe , Ġno )) ĊĊĠĠĠ Ġreturn ĠQuestion Schema Entities ( ĊĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠ Ġmake Question ( 1 , Ġ" Q 1 ", Ġ" checkbox ", Ġgroup 1 ), ĊĠĠĠĠĠĠĠ Ġmake Question ( 2 , Ġ" Q 2 ", Ġ" radio ", Ġgroup 2 ), ĊĠĠĠĠĠĠĠ Ġmake Question ( 3 , Ġ" Q 3 ") ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġsetup Section Question Codes (): ĠQuestion Schema Entities Ġ{ ĊĠĠĠ Ġval Ġdummy Ġ= ĠAnswer Schema Group Entity ( answer Schema Id Ġ= Ġ 9 9 ) ĊĊĠĠĠ Ġval Ġyes Ġ= ĊĠĠĠĠĠ ĠAnswer Schema Entity ( answer Schema Id Ġ= Ġ 1 , Ġanswer Schema Uuid Ġ= Ġanswer 1 Uuid , Ġvalue Ġ= Ġ" YES ", Ġanswer Schema Group Ġ= Ġdummy ) ĊĠĠĠ Ġval Ġmaybe Ġ= ĊĠĠĠĠĠ ĠAnswer Schema Entity ( answer Schema Id Ġ= Ġ 2 , Ġanswer Schema Uuid Ġ= Ġanswer 2 Uuid , Ġvalue Ġ= Ġ" MAYBE ", Ġanswer Schema Group Ġ= Ġdummy ) ĊĠĠĠ Ġval Ġno Ġ= ĊĠĠĠĠĠ ĠAnswer Schema Entity ( answer Schema Id Ġ= Ġ 3 , Ġanswer Schema Uuid Ġ= Ġanswer 3 Uuid , Ġvalue Ġ= Ġ" NO ", Ġanswer Schema Group Ġ= Ġdummy ) ĊĊĠĠĠ Ġval Ġgroup 1 Ġ= ĠAnswer Schema Group Entity ( answer Schema Id Ġ= Ġ 1 , Ġanswer Schema Entities Ġ= ĠlistOf ( yes )) ĊĠĠĠ Ġval Ġgroup 2 Ġ= ĠAnswer Schema Group Entity ( answer Schema Id Ġ= Ġ 2 , Ġanswer Schema Entities Ġ= ĠlistOf ( maybe , Ġno )) ĊĊĠĠĠ Ġreturn ĠQuestion Schema Entities ( ĊĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠ Ġmake Question ( 1 , Ġ" Q 1 ", Ġ" checkbox ", Ġgroup 1 , Ġ" section 1 ", Ġ 1 , Ġ" o as ys Q 1 "), ĊĠĠĠĠĠĠĠ Ġmake Question ( 2 , Ġ" Q 2 ", Ġ" radio ", Ġgroup 2 , Ġ" section 1 ", Ġ 1 , Ġ" o as ys Q 2 ") ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġmake Question ( ĊĠĠĠ Ġquestion Schema Id : ĠLong , ĊĠĠĠ Ġquestion Code : ĠString , ĊĠĠĠ Ġanswer Type : ĠString Ġ= Ġ" freet ext ", ĊĠĠĠ Ġanswer Schema Group : ĠAnswer Schema Group Entity ? Ġ= Ġnull , ĊĠĠĠ Ġo as ys Section Code : ĠString ? Ġ= Ġnull , ĊĠĠĠ Ġo as ys Logical Page : ĠLong ? Ġ= Ġnull , ĊĠĠĠ Ġo as ys Question Code : ĠString ? Ġ= Ġnull , ĊĠ Ġ): ĠQuestion Schema Entity Ġ{ ĊĠĠĠ Ġval Ġo a Sys Mappings Ġ= Ġmutable ListOf < O AS ys Mapping Entity >() ĊĠĠĠ Ġval Ġquestion Ġ= ĠQuestion Schema Entity ( ĊĠĠĠĠĠ Ġquestion Schema Id Ġ= Ġquestion Schema Id , ĊĠĠĠĠĠ Ġquestion Schema Uuid Ġ= ĠUUID . randomUUID (), ĊĠĠĠĠĠ Ġquestion Code Ġ= Ġquestion Code , ĊĠĠĠĠĠ Ġanswer Type Ġ= Ġanswer Type , ĊĠĠĠĠĠ Ġanswer Schema Group Ġ= Ġanswer Schema Group , ĊĠĠĠĠĠ Ġo as ys Mappings Ġ= Ġo a Sys Mappings ĊĠĠĠ Ġ) ĊĠĠĠ Ġif Ġ( o as ys Section Code Ġ!= Ġnull ) ĊĠĠĠĠĠ Ġo a Sys Mappings . add ( ĊĠĠĠĠĠĠĠ ĠO AS ys Mapping Entity ( ĊĠĠĠĠĠĠĠĠĠ Ġmapping Id Ġ= Ġquestion Schema Id , ĊĠĠĠĠĠĠĠĠĠ Ġsection Code Ġ= Ġo as ys Section Code , ĊĠĠĠĠĠĠĠĠĠ Ġlogical Page Ġ= Ġo as ys Logical Page , ĊĠĠĠĠĠĠĠĠĠ Ġquestion Code Ġ= Ġo as ys Question Code !! , ĊĠĠĠĠĠĠĠĠĠ Ġquestion Schema Ġ= Ġquestion ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġreturn Ġquestion ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġassessment Entity With O as ys Off ender ( answers : ĠAn swers ): ĠAssessment Entity Ġ{ ĊĠĠĠ Ġval Ġsubject Ġ= ĠSubject Entity ( ĊĠĠĠĠĠ Ġo as ys Off ender Pk Ġ= Ġ 9 9 9 9 , ĊĠĠĠĠĠ Ġdate OfBirth Ġ= ĠLocalDate . of ( 1 9 8 9 , Ġ 1 , Ġ 1 ), ĊĠĠĠĠĠ Ġcr n Ġ= Ġ" X 1 3 4 5 " ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġepisode s Ġ= Ġmutable ListOf < Assessment Episode Entity >() ĊĠĠĠ Ġval Ġassessment Ġ= ĠAssessment Entity ( ĊĠĠĠĠĠ Ġassessment Id Ġ= Ġassessment Id , ĊĠĠĠĠĠ Ġepisode s Ġ= Ġepisode s , ĊĠĠĠĠĠ Ġsubject Ġ= Ġsubject ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġepisode s . add ( ĊĠĠĠĠĠ ĠAssessment Episode Entity ( ĊĠĠĠĠĠĠĠ Ġepisode Uuid Ġ= Ġepisode Uuid , ĊĠĠĠĠĠĠĠ Ġepisode Id Ġ= Ġepisode Id 2 , ĊĠĠĠĠĠĠĠ Ġassessment Ġ= Ġassessment , ĊĠĠĠĠĠĠĠ Ġcreated Date Ġ= ĠLocalDateTime . now (), ĊĠĠĠĠĠĠĠ Ġassessment Schema Code Ġ= ĠAssessment Schema Code . RO SH , ĊĠĠĠĠĠĠĠ Ġchange Reason Ġ= Ġ" Change Ġof ĠC ir cs Ġ 2 ", ĊĠĠĠĠĠĠĠ Ġo as ys Set Pk Ġ= Ġ 7 7 7 7 , ĊĠĠĠĠĠĠĠ Ġanswers Ġ= Ġanswers , ĊĠĠĠĠĠĠĠ Ġauthor Ġ= ĠAuthor Entity ( userId Ġ= Ġ" 1 ", ĠuserName Ġ= Ġ" USER ", Ġuser Auth Source Ġ= Ġ" source ", Ġuser FullName Ġ= Ġ" full Ġname "), ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġreturn Ġassessment ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġsetup Episode (): ĠAssessment Episode Entity Ġ{ ĊĠĠĠ Ġval Ġanswers Ġ= Ġmutable Map Of ( ĊĠĠĠĠĠ Ġquestion Code 1 Ġto ĠlistOf (" some Ġfree Ġtext "), ĊĠĠĠĠĠ Ġquestion Code 2 Ġto ĠlistOf (" 1 9 7 5 - 0 1 - 2 0 T 0 0 : 0 0 : 0 0 . 0 0 0 Z "), ĊĠĠĠĠĠ Ġquestion Code 3 Ġto ĠlistOf (" not Ġmapped Ġto Ġo as ys "), ĊĠĠĠ Ġ) ĊĠĠĠ Ġreturn ĠAssessment Episode Entity ( ĊĠĠĠĠĠ Ġepisode Id Ġ= Ġepisode Id 1 , ĊĠĠĠĠĠ Ġassessment Schema Code Ġ= ĠAssessment Schema Code . RO SH , ĊĠĠĠĠĠ Ġo as ys Set Pk Ġ= Ġo as ys Set Pk , ĊĠĠĠĠĠ Ġanswers Ġ= Ġanswers , ĊĠĠĠĠĠ Ġcreated Date Ġ= ĠLocalDateTime . now (), ĊĠĠĠĠĠ Ġassessment Ġ= ĠAssessment Entity ( ĊĠĠĠĠĠĠĠ Ġsubject Ġ= ĊĠĠĠĠĠĠĠ ĠSubject Entity ( ĊĠĠĠĠĠĠĠĠĠ Ġo as ys Off ender Pk Ġ= Ġ 1 , ĊĠĠĠĠĠĠĠĠĠ Ġsubject Uuid Ġ= ĠUUID . randomUUID (), ĊĠĠĠĠĠĠĠĠĠ Ġdate OfBirth Ġ= ĠLocalDate . of ( 1 9 8 9 , Ġ 1 , Ġ 1 ), ĊĠĠĠĠĠĠĠĠĠ Ġcr n Ġ= Ġ" X 1 3 4 5 " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ), ĊĠĠĠĠĠ Ġauthor Ġ= ĠAuthor Entity ( userId Ġ= Ġ" 1 ", ĠuserName Ġ= Ġ" USER ", Ġuser Auth Source Ġ= Ġ" source ", Ġuser FullName Ġ= Ġ" full Ġname "), ĊĠĠĠ Ġ) ĊĠ Ġ} Ċ } Ċ