package Ġcom . k ush k ip ag os . tests Ċ Ċ import Ġcom . k ush k ip ag os . k ush ki . Card Secure Validation Ċ import Ġcom . k ush k ip ag os . k ush ki . Secure Validation Ċ import Ġcom . k ush k ip ag os . tests . Helpers . build Secure Validation OTP Response Ċ import Ġcom . k ush k ip ag os . tests . Helpers . build Secure Validation Response Ċ import Ġorg . apache . commons . lang 3 . Random StringUtils Ċ import Ġorg . hamcrest . Core Matchers . equalTo Ċ import Ġorg . hamcrest . Matcher Assert . assertThat Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . rules . Expected Exception Ċ Ċ class ĠSecure Validation Test Ġ{ ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġexpected Exception : ĠExpected Exception Ġ= ĠExpected Exception . none () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return The Questions From The ResponseBody () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Questionnaire Code Ġ= Ġ" 2 " ĊĠĠĠĠĠĠĠ Ġval Ġresponse Body Ġ= Ġbuild Secure Validation Response (" 0 0 0 ", Ġ" Por Ġfavor , Ġcomplete Ġlas Ġpreg unt as ", Ġexpected Questionnaire Code ) ĊĠĠĠĠĠĠĠ Ġval Ġsecure Validation Ġ= ĠSecure Validation ( response Body ) ĊĠĠĠĠĠĠĠ ĠassertThat ( secure Validation . question naire Code , ĠequalTo ( expected Questionnaire Code )) ĊĠĠĠĠĠĠĠ ĠassertThat ( secure Validation . questions . length (), ĠequalTo ( 3 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return The Code From The ResponseBody () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Code Ġ= Ġ" 0 0 0 " ĊĠĠĠĠĠĠĠ Ġval Ġresponse Body Ġ= Ġbuild Secure Validation Response ( expected Code , Ġ" Some Ġerror Ġmessage ") ĊĠĠĠĠĠĠĠ Ġval Ġsecure Validation Ġ= ĠSecure Validation ( response Body ) ĊĠĠĠĠĠĠĠ ĠassertThat ( secure Validation . code , ĠequalTo ( expected Code )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return The Message From The ResponseBody () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Message Ġ= ĠRandom StringUtils . random Alphabet ic ( 1 5 ) ĊĠĠĠĠĠĠĠ Ġval Ġresponse Body Ġ= Ġbuild Secure Validation Response (" 1 2 3 ", Ġexpected Message ) ĊĠĠĠĠĠĠĠ Ġval Ġsecure Validation Ġ= ĠSecure Validation ( response Body ) ĊĠĠĠĠĠĠĠ ĠassertThat ( secure Validation . message , ĠequalTo ( expected Message )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return True When Secure Validation Is Successful () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Body Ġ= Ġbuild Secure Validation Response (" 0 0 0 ", ĠRandom StringUtils . random Alphabet ic ( 1 5 ), Ġ" asdf ") ĊĠĠĠĠĠĠĠ Ġval Ġsecure Validation Ġ= ĠSecure Validation ( response Body ) ĊĠĠĠĠĠĠĠ ĠassertThat ( secure Validation . is Successful , ĠequalTo ( true )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return False When Secure Validation IsNot Successful () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Body Ġ= Ġbuild Secure Validation Response (" 2 1 1 ", Ġ"") ĊĠĠĠĠĠĠĠ Ġval Ġsecure Validation Ġ= ĠSecure Validation ( response Body ) ĊĠĠĠĠĠĠĠ ĠassertThat ( secure Validation . is Successful , ĠequalTo ( false )) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return True When Secure OTP Validation Is Successful () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Body Ġ= Ġbuild Secure Validation OTP Response (" OTP 0 0 0 ") ĊĠĠĠĠĠĠĠ Ġval Ġsecure Validation Ġ= ĠCard Secure Validation ( response Body ) ĊĠĠĠĠĠĠĠ ĠassertThat ( secure Validation . is Successful , ĠequalTo ( true )) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return False When Secure OTP Validation IsNot Successful () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Body Ġ= Ġbuild Secure Validation OTP Response (" OTP 1 0 0 ") ĊĠĠĠĠĠĠĠ Ġval Ġsecure Validation Ġ= ĠCard Secure Validation ( response Body ) ĊĠĠĠĠĠĠĠ ĠassertThat ( secure Validation . is Successful , ĠequalTo ( false )) ĊĠĠĠ Ġ} @ Test ĊĠĠĠ Ġfun Ġshould Return False When Secure OTP Validation Throws Other Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Body Ġ= Ġbuild Secure Validation OTP Response (" some Ġerror ") ĊĠĠĠĠĠĠĠ Ġval Ġsecure Validation Ġ= ĠCard Secure Validation ( response Body ) ĊĠĠĠĠĠĠĠ ĠassertThat ( secure Validation . is Successful , ĠequalTo ( false )) ĊĠĠĠ Ġ} ĊĊ Ċ }