package Ġdev . number 6 . db Ċ Ċ import Ġassert k . assertThat Ċ import Ġassert k . assertions . isEmpty Ċ import Ġassert k . assertions . isEqualTo Ċ import Ġassert k . assertions . isIn Ċ import Ġcom . amazonaws . services . dynamodb v 2 . data modeling . D ynamoDB Mapper Ċ import Ġcom . amazonaws . services . dynamodb v 2 . data modeling . D ynamoDB Mapper Config Ċ import Ġcom . amazonaws . services . dynamodb v 2 . data modeling . D ynamoDB Mapper Config . TableName Override Ċ import Ġdev . number 6 . db . adapt or . Database Service Configuration Adaptor Ċ import Ġdev . number 6 . db . adapt or . D ynamo Basic Database Adaptor Ċ import Ġdev . number 6 . db . model . Channel Comp reh ension Summary Ċ import Ġio . mock k . every Ċ import Ġio . mock k . junit 5 . Mock K Extension Ċ import Ġio . mock k . mock k Ċ import Ġio . mock k . slot Ċ import Ġio . mock k . verify Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . extension . Extend With Ċ import Ġuk . org . fy od or . generators . RD G Ċ import Ġuk . org . fy od or . range . Range Ċ import Ġjava . time . LocalDate ĊĊ Ċ @ Extend With ( Mock K Extension :: class ) Ċ internal Ġclass ĠD ynamo Basic Database Adaptor Test Ġ{ ĊĠĠĠ Ġprivate Ġval Ġmapper Ġ= Ġmock k < D ynamoDB Mapper >( relax Unit Fun Ġ= Ġtrue ) ĊĠĠĠ Ġprivate Ġval Ġd ynamoDB Mapper Config Ġ= Ġmock k < D ynamoDB Mapper Config >() ĊĠĠĠ Ġprivate Ġval Ġdb Config Ġ= Ġmock k < Database Service Configuration Adaptor >() ĊĠĠĠ Ġprivate Ġval Ġtest ee Ġ= ĠD ynamo Basic Database Adaptor ( mapper , Ġdb Config ) ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠtableName Override Ġ= ĠTable Name Override ( OVERRIDE _ TABLE _ NAME ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġd ynamoDB Mapper Config . tableName Override Ġ} Ġreturns ĠtableName Override ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġdb Config . d ynamoDB Mapper Config Ġ} Ġreturns Ġd ynamoDB Mapper Config ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsaves Comp reh ension Summary () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġchannel Names Ġ= ĠR DG . list ( RD G . string ( 2 0 ), Ġ 1 ). next () ĊĠĠĠĠĠĠĠ Ġval Ġcompreh ension Date Ġ= ĠLocalDate . now () ĊĠĠĠĠĠĠĠ Ġval Ġconfig Slot Ġ= Ġslot < D ynamoDB Mapper Config >() ĊĠĠĠĠĠĠĠ Ġval Ġsummary Slot Ġ= Ġslot < Channel Comp reh ension Summary >() ĊĠĠĠĠĠĠĠ Ġtest ee . createNew Summary For Channels ( channel Names , Ġcompreh ension Date ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġmapper . save ( capture ( summary Slot ), Ġcapture ( config Slot )) Ġ} ĊĠĠĠĠĠĠĠ ĠassertThat ( summary Slot . captured . channel Name ). isEqualTo ( channel Names [ 0 ]) ĊĠĠĠĠĠĠĠ ĠassertThat ( summary Slot . captured . comp reh ension Date ). isEqualTo ( comp reh ension Date ) ĊĠĠĠĠĠĠĠ ĠassertThat ( config Slot . captured . tableName Override . tableName ). isEqualTo ( OVERRIDE _ TABLE _ NAME ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsaves Comp reh ension Summary ForEach Channel () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġchannel Names Ġ= ĠR DG . list ( RD G . string (), ĠRange . closed ( 3 , Ġ 2 0 )). next (). to Mutable List () ĊĠĠĠĠĠĠĠ Ġval Ġcompreh ension Date Ġ= ĠLocalDate . now () ĊĠĠĠĠĠĠĠ Ġval Ġconfig Slot Ġ= Ġmutable ListOf < D ynamoDB Mapper Config >() ĊĠĠĠĠĠĠĠ Ġval Ġsummary Slot Ġ= Ġmutable ListOf < Channel Comp reh ension Summary >() ĊĠĠĠĠĠĠĠ Ġtest ee . createNew Summary For Channels ( channel Names , Ġcompreh ension Date ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġchannel Names . size ) Ġ{ Ġmapper . save ( capture ( summary Slot ), Ġcapture ( config Slot )) Ġ} ĊĠĠĠĠĠĠĠ Ġsummary Slot . forEach Ġ{ Ġc Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( c . comp reh ension Date ). isEqualTo ( comp reh ension Date ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( c . channel Name ). isIn (* channel Names . to Typed Array ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchannel Names . remove ( c . channel Name ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertThat ( channel Names ). isEmpty () ĊĠĠĠĠĠĠĠ Ġconfig Slot . forEach Ġ{ Ġc Ġ-> ĠassertThat ( c . tableName Override . tableName ). isEqualTo ( OVERRIDE _ TABLE _ NAME ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠOVER RIDE _ TABLE _ NAME Ġ= Ġ" Override TableName " ĊĠĠĠ Ġ} Ċ }