Source:
public void testChangeAuthenticatedUserIdentifier() { Response createSuperuser = UtilIT.createRandomUser(); String superuserUsername = UtilIT.getUsernameFromResponse(createSuperuser); String superuserApiToken = UtilIT.getApiTokenFromResponse(createSuperuser); Response toggleSuperuser = UtilIT.makeSuperUser(superuserUsername); toggleSuperuser.then().assertThat() .statusCode(OK.getStatusCode()); Response createUser = UtilIT.createRandomUser(); createUser.prettyPrint(); assertEquals(200, createUser.getStatusCode()); String usernameOfUser = UtilIT.getUsernameFromResponse(createUser); String newUsername = "newUser_" + UtilIT.getRandomString(4); Response changeAuthIdResponse = UtilIT.changeAuthenticatedUserIdentifier(usernameOfUser, newUsername, superuserApiToken); changeAuthIdResponse.prettyPrint(); changeAuthIdResponse.then().assertThat() .statusCode(OK.getStatusCode()); String newUsernameBad = ""; Response changeAuthIdResponseBad = UtilIT.changeAuthenticatedUserIdentifier(usernameOfUser, newUsernameBad, superuserApiToken); changeAuthIdResponseBad.prettyPrint(); changeAuthIdResponseBad.then().assertThat() .statusCode(BAD_REQUEST.getStatusCode()); String newUsernameBad2 = "z"; Response changeAuthIdResponseBad2 = UtilIT.changeAuthenticatedUserIdentifier(usernameOfUser, newUsernameBad2, superuserApiToken); changeAuthIdResponseBad2.prettyPrint(); changeAuthIdResponseBad2.then().assertThat() .statusCode(BAD_REQUEST.getStatusCode()); Response deleteUserToConvert = UtilIT.deleteUser(newUsername); assertEquals(200, deleteUserToConvert.getStatusCode()); Response deleteSuperuser = UtilIT.deleteUser(superuserUsername); assertEquals(200, deleteSuperuser.getStatusCode()); }

Target:
public void testChangeAuthenticatedUserIdentifier() { Response createSuperuser = UtilIT.createRandomUser(); String superuserUsername = UtilIT.getUsernameFromResponse(createSuperuser); String superuserApiToken = UtilIT.getApiTokenFromResponse(createSuperuser); Response toggleSuperuser = UtilIT.makeSuperUser(superuserUsername); toggleSuperuser.then().assertThat() .statusCode(OK.getStatusCode()); Response createUser = UtilIT.createRandomUser(); createUser.prettyPrint(); assertEquals(200, createUser.getStatusCode()); String usernameOfUser = UtilIT.getUsernameFromResponse(createUser); Response createUserForAlreadyExists = UtilIT.createRandomUser(); createUserForAlreadyExists.prettyPrint(); assertEquals(200, createUserForAlreadyExists.getStatusCode()); String usernameOfUserAlreadyExists = UtilIT.getUsernameFromResponse(createUserForAlreadyExists); String newUsername = "newUser_" + UtilIT.getRandomString(4); Response changeAuthIdResponse = UtilIT.changeAuthenticatedUserIdentifier(usernameOfUser, newUsername, superuserApiToken); changeAuthIdResponse.prettyPrint(); changeAuthIdResponse.then().assertThat() .statusCode(OK.getStatusCode()); Response changeAuthIdResponseBadAlreadyExists= UtilIT.changeAuthenticatedUserIdentifier(newUsername, usernameOfUserAlreadyExists, superuserApiToken); changeAuthIdResponseBadAlreadyExists.prettyPrint(); changeAuthIdResponseBadAlreadyExists.then().assertThat() .statusCode(BAD_REQUEST.getStatusCode()); String newUsernameBad = ""; Response changeAuthIdResponseBad = UtilIT.changeAuthenticatedUserIdentifier(newUsername, newUsernameBad, superuserApiToken); changeAuthIdResponseBad.prettyPrint(); changeAuthIdResponseBad.then().assertThat() .statusCode(NOT_FOUND.getStatusCode()); String newUsernameBad2 = "q"; Response changeAuthIdResponseBad2 = UtilIT.changeAuthenticatedUserIdentifier(newUsername, newUsernameBad2, superuserApiToken); changeAuthIdResponseBad2.prettyPrint(); changeAuthIdResponseBad2.then().assertThat() .statusCode(BAD_REQUEST.getStatusCode()); Response deleteUserToConvert = UtilIT.deleteUser(newUsername); assertEquals(200, deleteUserToConvert.getStatusCode()); Response deleteSuperuser = UtilIT.deleteUser(superuserUsername); assertEquals(200, deleteSuperuser.getStatusCode()); }