Created
February 22, 2013 02:08
-
-
Save jeffblack360/5010200 to your computer and use it in GitHub Desktop.
How to set "roles" in the createUser_shouldCreateANewUserWithRoles() @test method.
This file contains 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
/** | |
* @see UserController#createUser(SimpleObject,WebRequest) | |
* @throws Exception | |
* @verifies create a new user | |
*/ | |
@Test | |
public void createUser_shouldCreateANewUserWithRoles() throws Exception { | |
long originalCount = getAllCount(); | |
SimpleObject user = new SimpleObject(); | |
user.add("username", "test user"); | |
user.add("password", "Secret123"); | |
user.add("person", "da7f524f-27ce-4bb2-86d6-6d1d05312bd5"); | |
user.add("roles", new String[] {"3480cb6d-c291-46c8-8d3a-96dc33d199fb"}); | |
String json = new ObjectMapper().writeValueAsString(user); | |
MockHttpServletRequest req = request(RequestMethod.POST, getURI()); | |
req.setContent(json.getBytes()); | |
SimpleObject newUser = deserialize(handle(req)); | |
Util.log("Created User", newUser); | |
Assert.assertNotNull(PropertyUtils.getProperty(newUser, "uuid")); | |
Assert.assertEquals(originalCount + 1, getAllCount()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment