public RecommendationDataManager(List<Set<Integer>> userVisits) { trainingSet = new ArrayList<>(); validationSet = new ArrayList<>(); testSet = new ArrayList<>(); virtualSet = new HashSet<>(); for (int i = 0; i < Constants.ITEM_COUNT; i++) virtualSet.add(i); for (Set<Integer> visitedIds : userVisits) { currentSet = visitedIds; // %80 nini al trainingSet.add(getRandomlySet(80)); // kalan?n %50 si validationSet.add(getRandomlySet(50)); // kalan? al testSet.add(currentSet); } Helpers.dumpSetForGraph("Training Set", trainingSet); Helpers.dumpSetForGraph("Validation Set", validationSet); Helpers.dumpSetForGraph("Test Set", testSet); notVisitedTrainingSet = new ArrayList<>(); for (Set<Integer> visitedIds : trainingSet) { Set<Integer> newSet = new HashSet<>(); newSet.addAll(virtualSet); newSet.removeAll(visitedIds); notVisitedTrainingSet.add(newSet); } // bir item hangi userlar taraf?ndan clicklenmi? itemVisitorsMap = new HashMap<>(); for (int userId = 0; userId < Constants.ITEM_COUNT; userId++) { List<Integer> userList = new ArrayList<>(); for (int rowId = 0; rowId < trainingSet.size(); rowId++) for (Integer subSet : trainingSet.get(rowId)) if (subSet.equals(userId)) userList.add(rowId); itemVisitorsMap.put(userId, userList); } }
public boolean runTest() { ExceptionHandling.classNameToErrorKeyToThrow = new HashMap<String, String>(); testsRun = new LinkedList<String>(); Set<String> expectedTestsRun = new HashSet<String>(); // No restrictionsontests so they all run. expectedTestsRun.add("a44.a.test.UnitTester"); expectedTestsRun.add("a44.b.test.UnitTester"); expectedTestsRun.add("a44.c.test.UnitTester"); expectedTestsRun.add("a44.a.functiontest.FT"); expectedTestsRun.add("a44.b.functiontest.FT"); expectedTestsRun.add("a44.c.functiontest.FT"); expectedTestsRun.add("a44.a.loadtest.LT"); expectedTestsRun.add("a44.b.loadtest.LT"); expectedTestsRun.add("a44.c.loadtest.LT"); GrandTestAuto gta = Helpers.setupForZip(new File(Grandtestauto.test44_zip), true, true, true); assert gta.runAllTests(); // Sanity check. assert testsRun.size() == 9; assert testsRun.containsAll(expectedTestsRun); // Initial package set. expectedTestsRun = new HashSet<String>(); testsRun = new LinkedList<String>(); expectedTestsRun.add("a44.b.test.UnitTester"); expectedTestsRun.add("a44.c.test.UnitTester"); expectedTestsRun.add("a44.b.functiontest.FT"); expectedTestsRun.add("a44.c.functiontest.FT"); expectedTestsRun.add("a44.b.loadtest.LT"); expectedTestsRun.add("a44.c.loadtest.LT"); gta = Helpers.setupForZip( new File(Grandtestauto.test44_zip), true, true, true, "a44.b", null, null, false, false, null, null, null, null, null, null, null, null); assert gta.runAllTests(); // Sanity check. assert testsRun.size() == 6; assert testsRun.containsAll(expectedTestsRun); // Final package set. expectedTestsRun = new HashSet<String>(); testsRun = new LinkedList<String>(); expectedTestsRun.add("a44.a.test.UnitTester"); expectedTestsRun.add("a44.b.test.UnitTester"); expectedTestsRun.add("a44.a.functiontest.FT"); expectedTestsRun.add("a44.b.functiontest.FT"); expectedTestsRun.add("a44.a.loadtest.LT"); expectedTestsRun.add("a44.b.loadtest.LT"); gta = Helpers.setupForZip( new File(Grandtestauto.test44_zip), true, true, true, null, "a44.b.loadtest", null, false, false, null, null, null, null, null, null, null, null); assert gta.runAllTests(); // Sanity check. assert testsRun.size() == 6; assert testsRun.containsAll(expectedTestsRun); // Initial and final package set. expectedTestsRun = new HashSet<String>(); testsRun = new LinkedList<String>(); expectedTestsRun.add("a44.b.test.UnitTester"); expectedTestsRun.add("a44.b.functiontest.FT"); expectedTestsRun.add("a44.b.loadtest.LT"); gta = Helpers.setupForZip( new File(Grandtestauto.test44_zip), true, true, true, "a44.b", "a44.b.loadtest", null, false, false, null, null, null, null, null, null, null, null); assert gta.runAllTests(); // Sanity check. assert testsRun.size() == 3; assert testsRun.containsAll(expectedTestsRun); // Initial, final and single package set. expectedTestsRun = new HashSet<String>(); testsRun = new LinkedList<String>(); expectedTestsRun.add("a44.c.functiontest.FT"); gta = Helpers.setupForZip( new File(Grandtestauto.test44_zip), true, true, true, "a44.b", "a44.b.loadtest", "a44.c.functiontest", false, false, null, null, null, null, null, null, null, null); assert gta.runAllTests(); // Sanity check. assert testsRun.size() == 1; assert testsRun.containsAll(expectedTestsRun); return true; }