Created
November 5, 2013 00:53
-
-
Save dannyduc/7312036 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IntegrationTestUtil { | |
public static void addParameters(Object formObject, MockHttpServletRequest request) { | |
ObjectMapper mapper = new ObjectMapper(); | |
mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); | |
Map<String, Object> propertyValues = mapper.convertValue(formObject, Map.class); | |
Set<String> propertyNames = propertyValues.keySet(); | |
Iterator<String> nameIter = propertyNames.iterator(); | |
for (int index=0; index < propertyNames.size(); index++) { | |
String currentKey = nameIter.next(); | |
Object currentValue = propertyValues.get(currentKey); | |
request.setParameter(currentKey, currentValue.toString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment