コード例 #1
0
  /**
   * This method initiates and populates the hashmap reqs, with all requirements in the graph. There
   * are two types of requirements: Ordinary and Variable. All of them are fetched by calling
   * getReqTagKey for all the edges and vertexes in the graph The Ordinary requirements are directly
   * put into the reqs hashmap. The Variable requirements are used as a lookup in the list of all
   * the variable values returned by getAllVariableValues and the value matching the the Variable
   * requirement are splitted with colon and put as keys into the reqs hashmap. The value for each
   * entity in the reqs hashmap will be set to null, since no requirement are tested yet. Its never
   * needed to call this method more than once.
   */
  public void populateReqHashMap() {
    reqs = new HashMap<String, Boolean>();
    Hashtable<String, String> reqsVariables = getAllVariableValues();

    for (Edge edge : model.getEdges()) {
      String reqTag = edge.getReqTagKey();
      if (reqTag.length() == 0) continue;
      String[] tmp = reqTag.split(",");
      for (int i = 0; i < tmp.length; i++) {
        if (tmp[i].matches("[$][{].*[}]")) {
          String[] reqNames =
              reqsVariables.get(tmp[i].substring(2, tmp[i].length() - 1)).split(":");
          for (String reqVar : reqNames) this.reqs.put(reqVar, null);
        } else this.reqs.put(tmp[i], null);
      }
    }
    for (Vertex vertex : model.getVertices()) {
      String reqTag = vertex.getReqTagKey();
      if (reqTag.length() == 0) continue;
      String[] tmp = reqTag.split(",");
      for (int i = 0; i < tmp.length; i++) {
        if (tmp[i].matches("[$][{].*[}]")) {
          String savedReq = reqsVariables.get(tmp[i].substring(2, tmp[i].length() - 1));
          if (savedReq == null) continue;
          String[] reqNames = savedReq.split(":");
          for (String reqVar : reqNames) this.reqs.put(reqVar, null);
        } else this.reqs.put(tmp[i], null);
      }
    }
  }
コード例 #2
0
 public Vertex getStartVertex() {
   for (Vertex vertex : model.getVertices()) {
     if (vertex.getLabelKey().equals(Keywords.START_NODE)) {
       return vertex;
     }
   }
   return null;
 }
コード例 #3
0
 public Vector<Vertex> getUncoveredVertices() {
   Vector<Vertex> retur = new Vector<Vertex>();
   for (Vertex vertex : getAllVertices()) {
     if (vertex.getVisitedKey() <= 0) {
       retur.add(vertex);
     }
   }
   return retur;
 }
コード例 #4
0
 public void setAllUnvisited() {
   logger.debug("setAllUnvisited");
   reset();
   for (Vertex vertex : model.getVertices()) {
     vertex.setVisitedKey(0);
   }
   for (Edge edge : model.getEdges()) {
     edge.setVisitedKey(0);
   }
 }
コード例 #5
0
  private int getVertexCoverage(Collection<Vertex> modelItems) {
    int unique = 0;

    for (Vertex vertex : modelItems) {
      if (vertex.getVisitedKey() > 0) {
        unique++;
      }
    }
    return unique;
  }
コード例 #6
0
 public AbstractElement findElement(Integer index) {
   for (Vertex vertex : model.getVertices()) {
     if (vertex.getIndexKey().equals(index)) {
       return vertex;
     }
   }
   for (Edge edge : model.getEdges()) {
     if (edge.getIndexKey().equals(index)) {
       return edge;
     }
   }
   return null;
 }
コード例 #7
0
  public String getStatisticsVerbose() {
    String retur = "";
    String newLine = "\n";
    Vector<String> notCovered = new Vector<String>();

    for (Edge edge : model.getEdges()) {
      if (edge.getVisitedKey() <= 0) {
        notCovered.add("Edge not reached: " + edge + newLine);
      }
    }
    for (Vertex vertex : model.getVertices()) {
      if (vertex.getVisitedKey() <= 0) {
        notCovered.add("Vertex not reached: " + vertex + newLine);
      }
    }
    if (notCovered.size() > 0) {
      Collections.sort(notCovered);
      for (String string : notCovered) {
        retur += string;
      }
    }

    Iterator<Entry<String, Boolean>> it = reqs.entrySet().iterator();
    while (it.hasNext()) {
      Entry<String, Boolean> pairs = it.next();

      if (pairs.getValue() == null) {
        retur += "Requirement: " + pairs.getKey() + " is not tested." + newLine;
        continue;
      }
      if (pairs.getValue().booleanValue() == true) {
        retur += "Requirement: " + pairs.getKey() + " has passed." + newLine;
        continue;
      }
      if (pairs.getValue().booleanValue() == false) {
        retur += "Requirement: " + pairs.getKey() + " has failed." + newLine;
        continue;
      }
    }

    retur += getStatisticsString() + newLine;
    retur += "Execution time: " + ((System.currentTimeMillis() - start_time) / 1000) + " seconds";
    return retur;
  }
コード例 #8
0
 public String getCurrentVertexName() {
   return currentVertex.getLabelKey();
 }