Package org.springside.examples.showcase.data

Source Code of org.springside.examples.showcase.data.UserData

/*******************************************************************************
* Copyright (c) 2005, 2014 springside.github.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
*******************************************************************************/
package org.springside.examples.showcase.data;

import org.springside.examples.showcase.entity.Role;
import org.springside.examples.showcase.entity.User;
import org.springside.modules.test.data.RandomData;

/**
* 用户测试数据生成.
*
* @author calvin
*/
public class UserData {

  public static User randomUser() {
    String userName = RandomData.randomName("User");

    User user = new User();
    user.setLoginName(userName);
    user.setName(userName);
    user.setPlainPassword("123456");
    user.setEmail(userName + "@springside.org.cn");

    return user;
  }

  public static User randomUserWithAdminRole() {
    User user = UserData.randomUser();
    Role adminRole = UserData.adminRole();
    user.getRoleList().add(adminRole);
    return user;
  }

  public static Role adminRole() {
    Role role = new Role();
    role.setId(1L);
    role.setName("Admin");

    return role;
  }
}
TOP

Related Classes of org.springside.examples.showcase.data.UserData

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.