@@ -156,11 +156,50 @@ public void shouldSetScope() throws Exception {
156156 }
157157
158158 @ Test
159- public void shouldThrowWithStateIsNull () throws Exception {
159+ public void shouldThrowWhenScopeIsNull () throws Exception {
160160 exception .expect (IllegalArgumentException .class );
161- exception .expectMessage ("'state ' cannot be null!" );
161+ exception .expectMessage ("'scope ' cannot be null!" );
162162 AuthorizeUrlBuilder .newInstance (DOMAIN , CLIENT_ID , REDIRECT_URI )
163- .withState (null );
163+ .withScope (null );
164+ }
165+
166+ @ Test
167+ public void shouldSetResponseType () throws Exception {
168+ String url = AuthorizeUrlBuilder .newInstance (DOMAIN , CLIENT_ID , REDIRECT_URI )
169+ .withResponseType ("token id_token" )
170+ .build ();
171+ assertThat (url , hasQueryParameter ("response_type" , "token id_token" ));
172+ }
173+
174+ @ Test
175+ public void shouldThrowWhenResponseTypeIsNull () throws Exception {
176+ exception .expect (IllegalArgumentException .class );
177+ exception .expectMessage ("'response type' cannot be null!" );
178+ AuthorizeUrlBuilder .newInstance (DOMAIN , CLIENT_ID , REDIRECT_URI )
179+ .withResponseType (null );
180+ }
181+
182+ @ Test
183+ public void shouldSetCustomParameter () throws Exception {
184+ String url = AuthorizeUrlBuilder .newInstance (DOMAIN , CLIENT_ID , REDIRECT_URI )
185+ .withParameter ("name" , "value" )
186+ .build ();
187+ assertThat (url , hasQueryParameter ("name" , "value" ));
164188 }
165189
190+ @ Test
191+ public void shouldThrowWhenCustomParameterNameIsNull () throws Exception {
192+ exception .expect (IllegalArgumentException .class );
193+ exception .expectMessage ("'name' cannot be null!" );
194+ AuthorizeUrlBuilder .newInstance (DOMAIN , CLIENT_ID , REDIRECT_URI )
195+ .withParameter (null , "value" );
196+ }
197+
198+ @ Test
199+ public void shouldThrowWhenCustomParameterValueIsNull () throws Exception {
200+ exception .expect (IllegalArgumentException .class );
201+ exception .expectMessage ("'value' cannot be null!" );
202+ AuthorizeUrlBuilder .newInstance (DOMAIN , CLIENT_ID , REDIRECT_URI )
203+ .withParameter ("name" , null );
204+ }
166205}
0 commit comments