@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()); }
@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()); }