public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles) {
if (id == null) {
id = KeycloakModelUtils.generateId();
}
UserEntity entity = new UserEntity();
entity.setId(id);
entity.setUsername(username);
entity.setRealmId(realm.getId());
em.persist(entity);
em.flush();
UserModel userModel = new UserAdapter(realm, em, entity);
if (addDefaultRoles) {