public String getEdgeName(Edge edge) { if (edge.getParameterKey().isEmpty()) { return edge.getLabelKey(); } return edge.getLabelKey() + " " + edge.getParameterKey(); }
/** * 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); } } }
public Edge findEdge(String edgeName) { for (Edge edge : model.getEdges()) { if ((edge.getLabelKey()).equals(edgeName)) { return edge; } } return null; }
/** * This functions returns a list of edges, which has not yet been covered * * @return */ public Vector<Edge> getUncoveredEdges() { Vector<Edge> retur = new Vector<Edge>(); for (Edge edge : getAllEdges()) { if (edge.getVisitedKey() <= 0) { retur.add(edge); } } return retur; }
public void setAllUnvisited() { logger.debug("setAllUnvisited"); reset(); for (Vertex vertex : model.getVertices()) { vertex.setVisitedKey(0); } for (Edge edge : model.getEdges()) { edge.setVisitedKey(0); } }
private int getEdgeCoverage(Collection<Edge> modelItems) { int unique = 0; for (Edge edge : modelItems) { if (edge.getVisitedKey() > 0) { unique++; } } return unique; }
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; }
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; }
public String getLastEdgeName() { return lastEdge.getLabelKey(); }