@ -142,7 +142,7 @@ public class MockHttpServletRequestBuilder
@@ -142,7 +142,7 @@ public class MockHttpServletRequestBuilder
/ * *
* Add a request parameter to the { @link MockHttpServletRequest } .
* If called more than once , the new values are added .
* < p > If called more than once , new values get added to existing ones .
* @param name the parameter name
* @param values one or more values
* /
@ -152,10 +152,11 @@ public class MockHttpServletRequestBuilder
@@ -152,10 +152,11 @@ public class MockHttpServletRequestBuilder
}
/ * *
* Add request parameters to the { @link MockHttpServletRequest } for example
* such as when testing a form submission . If called more than once , the new
* values are added .
* Add a map of request parameters to the { @link MockHttpServletRequest } ,
* for example when testing a form submission .
* < p > If called more than once , new values get added to existing ones .
* @param params the parameters to add
* @since 4 . 2 . 4
* /
public MockHttpServletRequestBuilder params ( MultiValueMap < String , String > params ) {
for ( String name : params . keySet ( ) ) {
@ -300,7 +301,7 @@ public class MockHttpServletRequestBuilder
@@ -300,7 +301,7 @@ public class MockHttpServletRequestBuilder
* @param value the attribute value
* /
public MockHttpServletRequestBuilder requestAttr ( String name , Object value ) {
addAttribute ToMap ( this . attributes , name , value ) ;
addToMap ( this . attributes , name , value ) ;
return this ;
}
@ -310,7 +311,7 @@ public class MockHttpServletRequestBuilder
@@ -310,7 +311,7 @@ public class MockHttpServletRequestBuilder
* @param value the session attribute value
* /
public MockHttpServletRequestBuilder sessionAttr ( String name , Object value ) {
addAttribute ToMap ( this . sessionAttributes , name , value ) ;
addToMap ( this . sessionAttributes , name , value ) ;
return this ;
}
@ -332,7 +333,7 @@ public class MockHttpServletRequestBuilder
@@ -332,7 +333,7 @@ public class MockHttpServletRequestBuilder
* @param value the flash attribute value
* /
public MockHttpServletRequestBuilder flashAttr ( String name , Object value ) {
addAttribute ToMap ( this . flashAttributes , name , value ) ;
addToMap ( this . flashAttributes , name , value ) ;
return this ;
}
@ -712,19 +713,19 @@ public class MockHttpServletRequestBuilder
@@ -712,19 +713,19 @@ public class MockHttpServletRequestBuilder
return request ;
}
private static void addToMap ( Map < String , Object > map , String name , Object value ) {
Assert . hasLength ( name , "'name' must not be empty" ) ;
Assert . notNull ( value , "'value' must not be null" ) ;
map . put ( name , value ) ;
}
private static < T > void addToMultiValueMap ( MultiValueMap < String , T > map , String name , T [ ] values ) {
Assert . hasLength ( name , "'name' must not be empty" ) ;
Assert . notNull ( values , "'values' is required" ) ;
Assert . notEmpty ( values , "'values' must not be empty" ) ;
for ( T value : values ) {
map . add ( name , value ) ;
}
}
private static void addAttributeToMap ( Map < String , Object > map , String name , Object value ) {
Assert . hasLength ( name , "'name' must not be empty" ) ;
Assert . notNull ( value , "'value' must not be null" ) ;
map . put ( name , value ) ;
}
}