コード例 #1
0
  @Test
  public void testDefaultBuilds() {
    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 builds list  for default");
    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("setting default builds list");
    doa.setDefaultBuilds(list);
    DEBUG.d("getting default builds list");
    list = doa.getDefaultBuilds();
    DEBUG.d("total number of default builds: " + list.size());
  }
コード例 #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());
  }
コード例 #3
0
  // public void deleteUser (User user);//TODO
  // public void deleteAllUsers();
  // public User getUser (String username);
  // public void saveUser (User user);
  @Test
  public void testSC2BOADAOUserFunctions() {
    SC2BOADAO doa = new SC2BOADAOSimpleDBImpl(true);
    DEBUG.d("deleting all users");
    doa.deleteAllUsers();
    DEBUG.d("generating users");
    // addings newusers
    int numberofusers = 10;
    generateUsers(doa, numberofusers);
    DEBUG.d("getting all users users");
    List<User> list = doa.getUsers();
    System.out.println("list count: " + list.size());
    for (int i = 0; i < list.size(); i++) {
      System.out.println(
          "current user: "******" id: "
              + list.get(i).getId()
              + " pw: "
              + list.get(i).getPassword());
    }
    assertTrue(list.size() == numberofusers);
    DEBUG.d("getting users by email");
    for (int i = 0; i < list.size(); i++) {
      User requesteduser = doa.getUserByEmail(list.get(i).getEmail());
      System.out.println(
          "current user: "******" id: "
              + requesteduser.getId()
              + " pw: "
              + requesteduser.getPassword());
    }
    DEBUG.d("getting users by id");
    for (int i = 0; i < list.size(); i++) {
      User requesteduser = doa.getUserByID(list.get(i).getId());
      System.out.println(
          "current user: "******" id: "
              + requesteduser.getId()
              + " pw: "
              + requesteduser.getPassword());
    }
    DEBUG.d("test authorities");
    for (int i = 0; i < list.size(); i++) {
      User requesteduser = doa.getUserByID(list.get(i).getId());
      System.out.println(
          "current user: "******" Numb auths: "
              + requesteduser.getAuthorities().size());
    }

    /*DEBUG.d("deleting user");


    doa.deleteUser(list.get(0));
    list = doa.getUsers();
    assertTrue(list.size()==numberofusers);*/

    DEBUG.d("deleting all users");
    // cleanup
    doa.deleteAllUsers();
    list = doa.getUsers();
    assertTrue(list.size() == 0);
  }