@Test public void testMethodMap() { String fileName = "TinySample.java"; String filePath = "C:/Users/Christian Adriano/Documents/GitHub/crowd-debug-firefly/samples-discarded/sample/tiny/"; String fileContent = SourceFileReader.readFileToString(filePath + fileName); CodeSnippetFactory snippetFactory = new CodeSnippetFactory("TinySample.java", fileContent); Vector<CodeSnippet> list = snippetFactory.generateSnippetsForFile(); if ((list == null) || (list.size() != 2)) Assert.fail( "Null list of snippets or file does not match test data, actual size is: " + list.size()); else { QuestionFactory questionFactory = new QuestionFactory(); questionFactory.generateMicrotasks(list, "Bug report message", 0); Hashtable<Integer, Microtask> microtaskMap = questionFactory.getConcreteQuestions(); FileDebugSession fileDebuggingSession = new FileDebugSession("TinySample.java", fileContent, microtaskMap); // Persist data MicrotaskStorage memento = MicrotaskStorage.initializeSingleton(); ; memento.insert(fileName, fileDebuggingSession); // Generate the WorkerSession WorkerSessionFactory sessionFactory = new WorkerSessionFactory(10); HashMap<String, HashMap<String, ArrayList<Microtask>>> actualFileMethodMap = sessionFactory.getFileMethodMap(); HashMap<String, ArrayList<Microtask>> methodMap = actualFileMethodMap.get("TinySample.java"); Assert.assertNotNull(methodMap); ArrayList<Microtask> method1List = methodMap.get("TinySample"); if (method1List == null || method1List.size() != 4) Assert.fail( "List of microtasks for method TinySample is wrong, actual size is: " + method1List.size()); else { ArrayList<Microtask> method2List = methodMap.get("seedCounter"); if (method2List == null || method2List.size() != 7) Assert.fail( "List of microtasks for method seedCounter is wrong, actual size is: " + method2List.size()); else { Microtask mtask1 = method1List.get(0); Assert.assertEquals( "First Microtask (ID=" + mtask1.getID().toString() + ") of TinySample does not match", 0, mtask1.getID().toString().compareTo("0")); Microtask mtask2 = method2List.get(0); Assert.assertEquals( "First Microtask (ID=" + mtask2.getID().toString() + ") of seedCounter does not match", 0, mtask2.getID().toString().compareTo("4")); } } } }