package Ġbr . com . gui ab ol so . connector . crypto graphy Ċ Ċ import Ġbr . com . gui ab ol so . connector . common . crypto graphy . Encrypted Data Ċ import Ġbr . com . gui ab ol so . connector . common . exception . De cryption Exception Ċ import Ġbr . com . gui ab ol so . connector . common . utils . decode Base 6 4 Ċ import Ġbr . com . gui ab ol so . connector . common . utils . encode Base 6 4 Ċ import Ġbr . com . gui ab ol so . connector . common . utils . to ByteBuffer Ċ import Ġcom . amazonaws . services . kms . AWS K MS Ċ import Ġcom . amazonaws . services . kms . model . AWS K MS Exception Ċ import Ġcom . amazonaws . services . kms . model . Decrypt Request Ċ import Ġcom . amazonaws . services . kms . model . Decrypt Result Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify Ċ import Ġcom . n ha ar man . mockito _ kotlin . wh enever Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . assertj . core . api . Assertions . assertThat Exception OfType Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ Ċ class ĠK MS Config Decrypt or Service Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġk ms Client : ĠAWS K MS ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġservice : ĠK MS Config Decrypt or Service ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġk ms Client Ġ= Ġmock () ĊĊĠĠĠĠĠĠĠ Ġservice Ġ= ĠK MS Config Decrypt or Service ( kms Client ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġdecrypt `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġencrypted Data Ġ= ĠEn crypted Data ( value Ġ= Ġ" some - encrypted - data ". toByteArray (). encode Base 6 4 ()) ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= Ġ" some - data ". toByteArray () ĊĊĠĠĠĠĠĠĠ Ġval Ġdecrypt Request Ġ= ĠDecrypt Request (). with C iph ertext Blob ( encrypted Data . value . decode Base 6 4 (). to ByteBuffer ()) ĊĊĠĠĠĠĠĠĠ Ġval Ġdecrypt Result : ĠDecrypt Result Ġ= Ġmock () ĊĊĠĠĠĠĠĠĠ Ġwhenever ( decrypt Result . plaintext ). thenReturn ( data . to ByteBuffer ()) ĊĠĠĠĠĠĠĠ Ġwhenever ( kms Client . decrypt ( decrypt Request )). thenReturn ( decrypt Result ) ĊĊĠĠĠĠĠĠĠ Ġval Ġactual Ġ= Ġservice . decrypt ( encrypted Data ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( actual . content ToString ()). isEqualTo ( data . content ToString ()) ĊĊĠĠĠĠĠĠĠ Ġverify ( kms Client ). decrypt ( decrypt Request ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġthrow Ġexception Ġwhen Ġtry Ġto Ġdecrypt Ġand Ġa ĠAWS K MS Exception Ġis Ġthrown `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġencrypted Data Ġ= ĠEn crypted Data ( value Ġ= Ġ" some - data ". toByteArray (). encode Base 6 4 ()) ĊĠĠĠĠĠĠĠ Ġval Ġdecrypt Request Ġ= ĠDecrypt Request (). with C iph ertext Blob ( encrypted Data . value . decode Base 6 4 (). to ByteBuffer ()) ĊĊĠĠĠĠĠĠĠ Ġwhenever ( kms Client . decrypt ( decrypt Request )). then Throw ( AWS K MS Exception (" some - message ")) ĊĊĠĠĠĠĠĠĠ ĠassertThat Exception OfType ( De cryption Exception :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. is Thrown By Ġ{ Ġservice . decrypt ( encrypted Data ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġverify ( kms Client ). decrypt ( decrypt Request ) ĊĠĠĠ Ġ} Ċ } Ċ