1616
1717package org .oidc .msg .validator ;
1818
19+ import java .util .ArrayList ;
20+ import java .util .Arrays ;
21+
1922import org .junit .Assert ;
2023import org .junit .Before ;
2124import org .junit .Test ;
@@ -38,7 +41,13 @@ public void testPlainString() throws InvalidClaimException {
3841 }
3942
4043 @ Test (expected = InvalidClaimException .class )
41- public void testEmptyArray () throws InvalidClaimException {
44+ public void testEmptyArrayWithoutListsEnabled () throws InvalidClaimException {
45+ validator .validate (new String [0 ]);
46+ }
47+
48+ @ Test (expected = InvalidClaimException .class )
49+ public void testEmptyArrayWithListsEnabled () throws InvalidClaimException {
50+ validator = new ArrayClaimValidator (true );
4251 validator .validate (new String [0 ]);
4352 }
4453
@@ -53,5 +62,27 @@ public void testNonEmptyArray() throws InvalidClaimException {
5362 public void testEmptyString () throws InvalidClaimException {
5463 Assert .assertEquals ("" , validator .validate ("" ));
5564 }
65+
66+ @ Test (expected = InvalidClaimException .class )
67+ public void testListWithoutEnablingLists () throws InvalidClaimException {
68+ validator .validate (Arrays .asList ("string1" , "string2" ));
69+ }
70+
71+ @ Test (expected = InvalidClaimException .class )
72+ public void testEmptyListWithEnablingLists () throws InvalidClaimException {
73+ validator .validate (new ArrayList <>());
74+ }
75+
76+ @ Test (expected = InvalidClaimException .class )
77+ public void testInvalidListWithEnablingLists () throws InvalidClaimException {
78+ validator .validate (Arrays .asList (1 , 2 ));
79+ }
80+
81+ @ Test
82+ public void testListWithEnablingLists () throws InvalidClaimException {
83+ validator = new ArrayClaimValidator (true );
84+ Assert .assertEquals ("string" , validator .validate (Arrays .asList ("string" )));
85+ Assert .assertEquals ("string1 string2" , validator .validate (Arrays .asList ("string1 string2" )));
86+ }
5687
5788}
0 commit comments