public void generateBuildOrders(SC2BOADAO doa, int numberofbuilds) {

    for (int i = 0; i < numberofbuilds; i++) {
      OnlineBuildOrder buildorder = new OnlineBuildOrder();
      buildorder.setBuildName("testbuild " + i);
      buildorder.setBuildOrderInstructions("1 2 3 4 5 6" + i);
      buildorder.setRace("terran");

      doa.addOnlineBuildOrder(buildorder);
    }
  }
  @Test
  public void testSC2BOADOAOnlineBuildOrderFunctions() {
    SC2BOADAO doa = new SC2BOADAOSimpleDBImpl(true);

    // delete all build orders
    doa.deleteAllOnlineBuildOrders();

    // add build order several build orders
    int numberofbuilds = 10;
    generateBuildOrders(doa, numberofbuilds);

    // get all build orders
    List<OnlineBuildOrder> list = doa.getAllOnlineBuildOrders();
    System.out.println("list count: " + list.size());
    for (int i = 0; i < list.size(); i++) {
      System.out.println(
          "current build: " + list.get(i).getBuildName() + " id: " + list.get(i).getId());
    }

    // list = doa.getAllOnlineBuildOrders();
    int size = list.size();

    assertTrue(size == numberofbuilds);
    DEBUG.d("getting buildorders by id");
    for (int i = 0; i < list.size(); i++) {
      OnlineBuildOrder buildorder = doa.getOnlineBuildOrder(list.get(i).getId());
      System.out.println(
          "current buildorder: " + buildorder.getBuildName() + " id: " + buildorder.getId());
    }

    // delete all build orders
    doa.deleteAllOnlineBuildOrders();
    list = doa.getAllOnlineBuildOrders();
    size = list.size();

    assertTrue(size == 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());
  }