コード例 #1
0
  public void generateAdmins(SC2BOADAO doa, int numberofusers) {

    for (int i = 0; i < numberofusers; i++) {
      User user = new User();
      user.setPassword("password 12345" + i);
      user.setUsername("Admin" + i);
      user.setEmail("admin" + i + "@google.com");
      user.addAuthority(new GrantedAuthorityImpl("ROLE_ADMIN"));
      doa.saveUser(user);
    }
  }
コード例 #2
0
  // public List<OnlineBuildOrder> getDefaultBuilds();
  @Test
  public void testUserBuildList() {

    SC2BOADAO doa = new SC2BOADAOSimpleDBImpl(true);
    DEBUG.d("wiping db clean");
    // delete all build orders
    doa.deleteAllOnlineBuildOrders();
    doa.deleteAllUsers();

    DEBUG.d("generating users");
    // add build order several build orders
    int numberofbuilds = 10;
    generateBuildOrders(doa, numberofbuilds);

    DEBUG.d("generating users");
    // adding new users
    int numberofusers = 10;
    generateUsers(doa, numberofusers);

    DEBUG.d("generating user with build list");
    List<OnlineBuildOrder> list = doa.getAllOnlineBuildOrders();
    System.out.println("number of builds: " + list.size());

    list = list.subList(0, list.size() / 2);
    System.out.println("trimmed number of builds: " + list.size());
    DEBUG.d("list of builds created created");
    User user = new User();
    user.setPassword("password 12345");
    user.setUsername("userwithbuilds");
    user.setEmail("*****@*****.**");
    user.setBuilds(OnlineBuildOrder.convertBuildsToIds(list));
    DEBUG.d("created user");
    doa.saveUser(user);
    DEBUG.d("saved user");

    User user2 = doa.getUserByEmail("*****@*****.**");

    DEBUG.d(
        "new user with builds: "
            + user2.getUsername()
            + " number of user builds: "
            + user2.getBuilds().size());
    assertTrue(user2.getBuilds().size() == list.size());
  }