Program: 9709
Project: 9709
Buggy source:
@Test public void optimisedTest(){
  try {
    SimpleLayout layout=new SimpleLayout();
    ConsoleAppender consoleAppender=new ConsoleAppender(layout);
    FileAppender fileAppender=new FileAppender(layout,"String_Node_Str",false);
    Logger logger=Logger.getRootLogger();
    logger.removeAllAppenders();
    logger.addAppender(consoleAppender);
    logger.addAppender(fileAppender);
    logger.setLevel(Level.OFF);
    Logger.getLogger(NBR.class).setLevel(Level.INFO);
  }
 catch (  IOException e1) {
    e1.printStackTrace();
  }
  HttpQuery.urlLimit=0;
  try {
    ExtractionDBCache cache=new ExtractionDBCache(CACHE_DIR);
    SparqlEndpoint endpoint=new SparqlEndpoint(new URL("String_Node_Str"),Collections.singletonList("String_Node_Str"),Collections.<String>emptyList());
    Set<String> predicateFilters=new HashSet<String>();
    predicateFilters.add("String_Node_Str");
    predicateFilters.add("String_Node_Str");
    ModelGenerator modelGen=new ModelGenerator(endpoint,predicateFilters,cache);
    QueryTreeFactory<String> treeFactory=new QueryTreeFactoryImpl();
    LGGGenerator<String> lggGen=new LGGGeneratorImpl<String>();
    NBR<String> nbrGen=new NBR<String>(endpoint,cache);
    String targetQuery="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
    ResultSet rs=SparqlQuery.convertJSONtoResultSet(cache.executeSelectQuery(endpoint,targetQuery));
    SortedSet<String> targetResources=new TreeSet<String>();
    QuerySolution qs;
    while (rs.hasNext()) {
      qs=rs.next();
      if (qs.get("String_Node_Str").isURIResource()) {
        targetResources.add(qs.get("String_Node_Str").asResource().getURI());
      }
    }
    List<QueryTree<String>> posTrees=new ArrayList<QueryTree<String>>();
    List<QueryTree<String>> negTrees=new ArrayList<QueryTree<String>>();
    List<String> knownResources=new ArrayList<String>();
    String uri="String_Node_Str";
    knownResources.add(uri);
    Model model=modelGen.createModel(uri,Strategy.CHUNKS,2);
    QueryTree<String> tree=treeFactory.getQueryTree(uri,model);
    tree=getFilteredTree(tree);
    posTrees.add(tree);
    uri="String_Node_Str";
    knownResources.add(uri);
    model=modelGen.createModel(uri,Strategy.CHUNKS,2);
    tree=treeFactory.getQueryTree(uri,model);
    tree=getFilteredTree(tree);
    posTrees.add(tree);
    uri="String_Node_Str";
    knownResources.add(uri);
    model=modelGen.createModel(uri,Strategy.CHUNKS,2);
    tree=treeFactory.getQueryTree(uri,model);
    tree=getFilteredTree(tree);
    negTrees.add(tree);
    QueryTree<String> lgg=lggGen.getLGG(posTrees);
    Example example=nbrGen.getQuestionOptimised(lgg,negTrees,knownResources);
    String learnedQuery=nbrGen.getQuery();
    while (!isEquivalentQuery(targetResources,learnedQuery,endpoint,cache)) {
      uri=example.getURI();
      knownResources.add(uri);
      model=modelGen.createModel(uri,Strategy.CHUNKS,2);
      tree=treeFactory.getQueryTree(uri,model);
      if (targetResources.contains(uri)) {
        System.out.println("String_Node_Str" + uri);
        posTrees.add(tree);
        lgg=lggGen.getLGG(posTrees);
      }
 else {
        System.out.println("String_Node_Str" + uri);
        negTrees.add(tree);
      }
      example=nbrGen.getQuestion(lgg,negTrees,knownResources);
      learnedQuery=nbrGen.getQuery();
    }
  }
 catch (  MalformedURLException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Test public void optimisedTest(){
  try {
    SimpleLayout layout=new SimpleLayout();
    ConsoleAppender consoleAppender=new ConsoleAppender(layout);
    FileAppender fileAppender=new FileAppender(layout,"String_Node_Str",false);
    Logger logger=Logger.getRootLogger();
    logger.removeAllAppenders();
    logger.addAppender(fileAppender);
    logger.setLevel(Level.OFF);
    Logger.getLogger(NBR.class).setLevel(Level.INFO);
  }
 catch (  IOException e1) {
    e1.printStackTrace();
  }
  HttpQuery.urlLimit=0;
  try {
    ExtractionDBCache cache=new ExtractionDBCache(CACHE_DIR);
    SparqlEndpoint endpoint=new SparqlEndpoint(new URL("String_Node_Str"),Collections.singletonList("String_Node_Str"),Collections.<String>emptyList());
    Set<String> predicateFilters=new HashSet<String>();
    predicateFilters.add("String_Node_Str");
    predicateFilters.add("String_Node_Str");
    ModelGenerator modelGen=new ModelGenerator(endpoint,predicateFilters,cache);
    QueryTreeFactory<String> treeFactory=new QueryTreeFactoryImpl();
    LGGGenerator<String> lggGen=new LGGGeneratorImpl<String>();
    NBR<String> nbrGen=new NBR<String>(endpoint,cache);
    String targetQuery="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
    ResultSet rs=SparqlQuery.convertJSONtoResultSet(cache.executeSelectQuery(endpoint,targetQuery));
    SortedSet<String> targetResources=new TreeSet<String>();
    QuerySolution qs;
    while (rs.hasNext()) {
      qs=rs.next();
      if (qs.get("String_Node_Str").isURIResource()) {
        targetResources.add(qs.get("String_Node_Str").asResource().getURI());
      }
    }
    List<QueryTree<String>> posTrees=new ArrayList<QueryTree<String>>();
    List<QueryTree<String>> negTrees=new ArrayList<QueryTree<String>>();
    List<String> knownResources=new ArrayList<String>();
    String uri="String_Node_Str";
    knownResources.add(uri);
    Model model=modelGen.createModel(uri,Strategy.CHUNKS,2);
    QueryTree<String> tree=treeFactory.getQueryTree(uri,model);
    tree=getFilteredTree(tree);
    posTrees.add(tree);
    uri="String_Node_Str";
    knownResources.add(uri);
    model=modelGen.createModel(uri,Strategy.CHUNKS,2);
    tree=treeFactory.getQueryTree(uri,model);
    tree=getFilteredTree(tree);
    posTrees.add(tree);
    uri="String_Node_Str";
    knownResources.add(uri);
    model=modelGen.createModel(uri,Strategy.CHUNKS,2);
    tree=treeFactory.getQueryTree(uri,model);
    tree=getFilteredTree(tree);
    negTrees.add(tree);
    QueryTree<String> lgg=lggGen.getLGG(posTrees);
    Example example=nbrGen.getQuestionOptimised(lgg,negTrees,knownResources);
    String learnedQuery=nbrGen.getQuery();
    while (!isEquivalentQuery(targetResources,learnedQuery,endpoint,cache)) {
      uri=example.getURI();
      knownResources.add(uri);
      model=modelGen.createModel(uri,Strategy.CHUNKS,2);
      tree=treeFactory.getQueryTree(uri,model);
      if (targetResources.contains(uri)) {
        System.out.println("String_Node_Str" + uri);
        posTrees.add(tree);
        lgg=lggGen.getLGG(posTrees);
      }
 else {
        System.out.println("String_Node_Str" + uri);
        negTrees.add(tree);
      }
      example=nbrGen.getQuestionOptimised(lgg,negTrees,knownResources);
      learnedQuery=nbrGen.getQuery();
    }
  }
 catch (  MalformedURLException e) {
    e.printStackTrace();
  }
}