Ejemplo n.º 1
0
  private void importArtifactsForJob(URIReference jobResource, Graph jobsGraph) {
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Importing artifacts for job " + jobResource.getURIText());
    }

    String artifactsPathFromRoot = jobArtifactsPath(jobResource, jobsGraph);

    for (String jobArtifactPath : unitTestArtifactPathsForJob(jobsGraph, jobResource)) {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(
            "Found artifact at pathFromArtifactRoot: "
                + artifactsPathFromRoot
                + " and artifactPath: "
                + jobArtifactPath);
      }

      for (File testSuiteXMLFile :
          getArtifactFilesOfType(artifactsPathFromRoot, jobArtifactPath, "xml")) {
        try {
          if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Trying to import " + testSuiteXMLFile);
          }
          importer.importFile(jobsGraph, jobResource, new FileInputStream(testSuiteXMLFile));
        } catch (FileNotFoundException e) {
          LOGGER.debug("Unable to find file: " + testSuiteXMLFile.toString());
        }
      }
    }
  }
Ejemplo n.º 2
0
  private String jobArtifactsPath(URIReference jobResource, Graph jobsGraph) {
    String selectArtifactRoot =
        GoOntology.URI_PREFIX
            + "prefix xsd: <http://www.w3.org/2001/XMLSchema#> "
            + "SELECT DISTINCT ?pathFromArtifactRoot WHERE { "
            + "<"
            + jobResource.getURIText()
            + "> cruise:hasArtifacts ?artifacts . "
            + "  ?artifacts a cruise:Artifacts . "
            + "  ?artifacts cruise:pathFromArtifactRoot ?pathFromArtifactRoot ."
            + "}";

    BoundVariables bv = jobsGraph.selectFirst(selectArtifactRoot);
    return (bv == null) ? null : bv.getString("pathFromArtifactRoot");
  }
Ejemplo n.º 3
0
  private List<String> unitTestArtifactPathsForJob(Graph graph, URIReference jobURI) {
    String selectArtifactPaths =
        GoOntology.URI_PREFIX
            + "prefix xsd: <http://www.w3.org/2001/XMLSchema#> "
            + "SELECT DISTINCT ?artifactPath WHERE { "
            + "<"
            + jobURI.getURIText()
            + "> cruise:hasArtifacts ?artifacts . "
            + "?artifacts a cruise:Artifacts . "
            + "?artifacts cruise:hasArtifact ?artifact . "
            + "?artifact cruise:artifactPath ?artifactPath . "
            + "?artifact cruise:artifactType 'unit'^^xsd:string "
            + "}";

    List<BoundVariables> bvs = graph.select(selectArtifactPaths);

    List<String> result = new ArrayList<>(bvs.size());
    for (BoundVariables bv : bvs) {
      result.add(bv.getString("artifactPath"));
    }
    return result;
  }