package Ġgraf . sem mel . val ium Ċ Ċ import Ġgraf . sem mel . val ium . validator . Validators Ċ import Ġorg . junit . Assert .* Ċ import Ġorg . junit . Test Ċ Ċ class ĠDefault Validators Test Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Length Validator () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Length Validator ( 4 ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Length Validator ( 0 ). validate ("")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Length Validator ( 4 ). validate ("")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Length Validator ( 4 ). validate (" 1 2 3 4 5 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest MaxLength Validator () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . MaxLength Validator ( 4 ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . MaxLength Validator ( 4 ). validate (" 1 2 3 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . MaxLength Validator ( 4 ). validate ("")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . MaxLength Validator ( 0 ). validate ("")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . MaxLength Validator ( 4 ). validate (" 1 2 3 4 5 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Min Length Validator () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Min Length Validator ( 4 ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Min Length Validator ( 4 ). validate (" 1 2 3 4 5 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Min Length Validator ( 0 ). validate ("")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Min Length Validator ( 4 ). validate (" 1 2 3 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Min Length Validator ( 4 ). validate ("")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Range Validator () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Range Validator ( 4 , Ġ 6 ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Range Validator ( 4 , Ġ 6 ). validate (" 1 2 3 4 5 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Range Validator ( 4 , Ġ 6 ). validate (" 1 2 3 4 5 6 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Range Validator ( 0 , Ġ 0 ). validate ("")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Range Validator ( 4 , Ġ 4 ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Range Validator ( 4 , Ġ 6 ). validate (" 1 2 3 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Range Validator ( 4 , Ġ 6 ). validate (" 1 2 3 4 5 6 7 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Range Validator ( 4 , Ġ 4 ). validate (" 1 2 3 4 5 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Range Validator ( 4 , Ġ 4 ). validate (" 1 2 3 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest NotBlank Validator () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . NotBlank Validator (). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . NotBlank Validator (). validate (" 1 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . NotBlank Validator (). validate (" Ġ 1 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . NotBlank Validator (). validate (" Ġ 1 Ġ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . NotBlank Validator (). validate (" 1 Ġ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . NotBlank Validator (). validate ("")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . NotBlank Validator (). validate (" Ġ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġstart sWith Validator () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . StartsWith Validator (" 1 "). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . StartsWith Validator (" "). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . StartsWith Validator (" 1 2 3 4 "). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . StartsWith Validator (). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . StartsWith Validator (" 1 2 3 4 "). validate ("")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . StartsWith Validator (" 1 2 3 4 "). validate (" 1 2 3 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . StartsWith Validator (" 1 "). validate (" 2 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġstarts Mot With Validator () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . StartsWith Validator (" 5 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . StartsWith Validator (" 1 2 3 4 5 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . StartsWith Validator (" 2 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . StartsWith Validator (" 2 ", Ġ" 3 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . StartsWith Validator (" 1 2 3 4 ", Ġmust Not Ġ= Ġtrue ). validate ("")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . StartsWith Validator (). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . StartsWith Validator (" 1 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . StartsWith Validator ("", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . StartsWith Validator (" 1 2 3 4 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . StartsWith Validator (" 1 2 3 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġend sWith Validator () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . EndsWith Validator (" 4 "). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . EndsWith Validator (" 3 4 "). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . EndsWith Validator (" "). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . EndsWith Validator (" 1 2 3 4 "). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . EndsWith Validator (). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . EndsWith Validator (" 1 2 3 4 "). validate ("")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . EndsWith Validator (" 1 2 3 4 "). validate (" 1 2 3 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . EndsWith Validator (" 1 "). validate (" 2 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġends Mot With Validator () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . EndsWith Validator (" 5 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . EndsWith Validator (" 1 2 3 4 5 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . EndsWith Validator (" 2 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . EndsWith Validator (" 2 ", Ġ" 3 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . EndsWith Validator (" 1 2 3 4 ", Ġmust Not Ġ= Ġtrue ). validate ("")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . EndsWith Validator (). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . EndsWith Validator (" 4 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . EndsWith Validator ("", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . EndsWith Validator (" 1 2 3 4 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . EndsWith Validator (" 2 3 4 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcontains With Validator () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Contains Validator (" 4 "). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Contains Validator (" 3 4 "). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Contains Validator (" "). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Contains Validator (" 1 2 3 4 "). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Contains Validator (). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Contains Validator (" 1 2 3 4 "). validate ("")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Contains Validator (" 1 2 3 4 "). validate (" 1 2 3 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Contains Validator (" 1 "). validate (" 2 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcontains Mot With Validator () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Contains Validator (" 5 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Contains Validator (" 2 2 2 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Contains Validator (" 1 3 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Contains Validator (" 2 2 ", Ġ" 0 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Contains Validator (" 1 2 3 4 ", Ġmust Not Ġ= Ġtrue ). validate ("")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Contains Validator (). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Contains Validator (" 4 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Contains Validator ("", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Contains Validator (" 1 2 3 4 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Contains Validator (" 2 3 ", Ġ" 4 ", Ġmust Not Ġ= Ġtrue ). validate (" 1 2 3 4 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Email Validator () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Email Validator (). validate (" h ans . zim mer @ m one se . com ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( Validators . Email Validator (). validate (" a @ b . c ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Email Validator (). validate ("")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Email Validator (). validate (" Ġ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Email Validator (). validate (" a ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Email Validator (). validate (" a . b ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Email Validator (). validate (" a @ b ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Email Validator (). validate (" a @ b .")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Email Validator (). validate (" a @. c ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Email Validator (). validate ("@ a . c ")) ĊĠĠĠĠĠĠĠ ĠassertFalse ( Validators . Email Validator (). validate (" a @@ b . c ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Illegal Arguments Exception () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcalls Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRunnable Ġ{ ĠassertFalse ( Validators . Min Length Validator (- 1 ). validate ("")) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRunnable Ġ{ ĠassertFalse ( Validators . MaxLength Validator (- 1 ). validate ("")) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRunnable Ġ{ ĠassertFalse ( Validators . Length Validator (- 1 ). validate ("")) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRunnable Ġ{ ĠassertFalse ( Validators . Range Validator (- 1 , Ġ 0 ). validate ("")) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRunnable Ġ{ ĠassertFalse ( Validators . Range Validator ( 0 , Ġ- 1 ). validate ("")) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRunnable Ġ{ ĠassertFalse ( Validators . Range Validator ( 4 , Ġ 3 ). validate ("")) Ġ} ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcalls . forEach Indexed Ġ{ Ġindex , Ġrunnable Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrunnable . run () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfail (" Expected Ġan ĠIllegalArgumentException Ġto Ġbe Ġthrown Ġfor Ġcall Ġnumber Ġ$ index ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( il legal ArgumentException : ĠIllegalArgumentException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }