/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 2 0 . ĠT ol gee Ċ Ġ*/ Ċ Ċ package Ġio . tol gee . component Ċ Ċ import Ġio . tol gee . d tos . request . validators . exceptions . ValidationException Ċ import Ġio . tol gee . testing . assertions . Assertions . assertThat Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ import Ġorg . springframework . test . context . testng . Abstract Test NG Spring Context Tests Ċ import Ġorg . testng . Assert . expect Throws Ċ import Ġorg . testng . annotations . Test Ċ import Ġjava . util .* Ċ Ċ @ SpringBootTest ( properties Ġ= Ġ[" tol gee . authentication . jwt Secret = this _ is _ dummy _ jwt _ secret "]) Ċ class ĠTimestamp Validation Test Ġ: ĠAbstract Test NG Spring Context Tests () Ġ{ ĊĊĠ Ġ@ set : Autowired ĊĠ Ġlateinit Ġvar Ġtimestamp Validation : ĠTimestamp Validation ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Check TimeStamp () Ġ{ ĊĠĠĠ Ġval Ġencrypted Ġ= Ġtimestamp Validation . encrypt TimeStamp ( Date (). time Ġ- Ġ 1 0 0 0 0 ) ĊĠĠĠ Ġexpect Throws ( ValidationException :: class . java ) Ġ{ ĊĠĠĠĠĠ Ġtimestamp Validation . check TimeStamp ( encrypted , Ġ 9 5 0 0 ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġtimestamp Validation . check TimeStamp ( encrypted , Ġ 1 0 5 0 0 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġis TimeStamp Valid () Ġ{ ĊĠĠĠ Ġval Ġencrypted Ġ= Ġtimestamp Validation . encrypt TimeStamp ( Date (). time Ġ- Ġ 1 0 0 0 0 ) ĊĠĠĠ ĠassertThat ( timestamp Validation . is TimeStamp Valid ( encrypted , Ġ 1 0 5 0 0 )). isTrue ĊĠĠĠ ĠassertThat ( timestamp Validation . is TimeStamp Valid ( encrypted , Ġ 2 0 5 0 0 )). isTrue ĊĠĠĠ ĠassertThat ( timestamp Validation . is TimeStamp Valid ( encrypted , Ġ 9 5 0 0 )). isFalse ĊĠĠĠ ĠassertThat ( timestamp Validation . is TimeStamp Valid ( encrypted , Ġ 1 0 0 0 )). isFalse ĊĠĠĠ ĠassertThat ( timestamp Validation . is TimeStamp Valid ( encrypted , Ġ 1 0 0 0 )). isFalse ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Encrypt TimeStamp () Ġ{ ĊĠĠĠ Ġval Ġencrypted Ġ= Ġtimestamp Validation . encrypt TimeStamp ( 1 6 0 8 3 0 0 7 9 6 ) ĊĠĠĠ ĠassertThat ( encrypted ). isEqualTo (" e 7 2 5 d 2 ccb 4 7 9 cf 3 af 6 ce 9 4 0 1 7 bd 7 ad 5 2 ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Decrypt TimeStamp () Ġ{ ĊĠĠĠ Ġval Ġtimestamp Ġ= Ġtimestamp Validation . decrypt TimeStamp (" e 7 2 5 d 2 ccb 4 7 9 cf 3 af 6 ce 9 4 0 1 7 bd 7 ad 5 2 ") ĊĠĠĠ ĠassertThat ( timestamp ). isEqualTo ( 1 6 0 8 3 0 0 7 9 6 ) ĊĠ Ġ} Ċ } Ċ