### Question:
InstancesQueryHandler extends AbstractWorkerQueryHandler { public void setOutputFolder(String outputFolder) { this.outputFolder = outputFolder; } InstancesQueryHandler(List<Worker> workers);  InstancesQueryHandler(List<Worker> workers, String lang); @Override Model generateTripleStats(String taskID); void setOutputFolder(String outputFolder);  }### Answer:
@Test public void testQueryCreation() throws IOException { Connection con = new Connection(); con.setName("a"); con.setEndpoint("http: Worker worker = getWorker(con, 1, "1"); InstancesQueryHandler qh = new InstancesQueryHandler(Lists.newArrayList(worker)); qh.setOutputFolder(this.dir); Map<String, File[]> map = qh.generate(); int hashcode = org.aksw.iguana.cc.utils.FileUtils.getHashcodeFromFileContent(this.queriesFile.getAbsolutePath()); File f = new File(this.dir+File.separator+hashcode); assertTrue(f.isDirectory()); int expectedNoOfFiles = queryStr.length; assertEquals(expectedNoOfFiles, f.listFiles().length); HashSet<String> files = new HashSet<String>(); for(File queryFile : f.listFiles()){ int id = Integer.parseInt(queryFile.getName().replace("sparql", "").replace("update", "")); String actualQueryString =org.aksw.iguana.cc.utils.FileUtils.readLineAt(0, queryFile); assertEquals(queryStr[id], actualQueryString); files.add(queryFile.getAbsolutePath()); } for(File queryFile : map.get(this.queriesFile.getAbsolutePath())){ assertTrue(files.contains(queryFile.getAbsolutePath())); } assertEquals(files.size(), map.get(this.queriesFile.getAbsolutePath()).length); FileUtils.deleteDirectory(f); }
@Test public void testCaching() throws IOException { Connection con = new Connection(); con.setName("a"); con.setEndpoint("http: Worker worker = getWorker(con, 1, "1"); InstancesQueryHandler qh = new InstancesQueryHandler(Lists.newArrayList(worker)); qh.setOutputFolder(this.dir); Map<String, File[]> queries1 = qh.generate(); int hashcode = org.aksw.iguana.cc.utils.FileUtils.getHashcodeFromFileContent(this.queriesFile.getAbsolutePath()); File f = new File(this.dir+File.separator+hashcode); worker = getWorker(con, 12, "2"); qh = new InstancesQueryHandler(Lists.newArrayList(worker)); qh.setOutputFolder(this.dir); Map<String, File[]> queries2 = qh.generate(); HashSet<String> files = new HashSet<String>(); for(File queryFile : queries1.get(this.queriesFile.getAbsolutePath())){ files.add(queryFile.getAbsolutePath()); } for(File queryFile : queries2.get(this.queriesFile.getAbsolutePath())){ assertTrue(files.contains(queryFile.getAbsolutePath())); } assertEquals(files.size(), queries2.get(this.queriesFile.getAbsolutePath()).length); FileUtils.deleteDirectory(f); }