public Call(String classname, String methodName) { this.className = classname; this.methodName = methodName; approxHcode = computeApproximatedHashCode(); hcode = computeHashCode(); }
/** * <p> * getRootClassName * </p> * * @return a {@link java.lang.String} object. */ public String getRootClassName() { return context.get(0).getClassName(); }
/** * <p> * getRootMethodName * </p> * * @return a {@link java.lang.String} object. */ public String getRootMethodName() { return context.get(0).getMethodName(); }
/** * Constructor for public methods * * @param className * @param methodName */ public CallContext(String className, String methodName) { addJUnitExcludes(); List<Call> context = new ArrayList<Call>(); context.add(new Call(className, methodName)); this.context=context; hcode = this.context.hashCode(); }
/** {@inheritDoc} */ @Override public String toString() { if(context == null) return ""; StringBuilder builder = new StringBuilder(); for (Call call : context) { builder.append(call.toString()); builder.append(" "); } String tmp = builder.toString(); return tmp.trim(); }
public boolean oldMatches(CallContext other) { if (context.size() != other.context.size()) return false; if (other.hcode == hcode) return true; for (int i = 0; i < context.size(); i++) { Call call1 = context.get(i); Call call2 = other.context.get(i); if (!call1.matches(call2)) { return false; } } return false; } //A empty context matches with everything.
Call newCall = new Call(element.getClassName(), element.getMethodName()); boolean skip = false; if(context.size() >= 2) { // Need at least a sequence of three for this check to make sense Call previousCall1 = context.get(context.size() - 1); Call previousCall2 = context.get(context.size() - 2); if(previousCall1.equals(newCall) && previousCall2.equals(newCall)) { skip = true;
private void addPublicClassMethod(String className, String methodName, Set<CallContext> contexts){ List<Call> calls = new ArrayList<>(); Call call = new Call(className, methodName); calls.add(call); CallContext context = new CallContext(calls); if(publicMethods.contains(context)&&className.equals(this.className)) contexts.add(context); }
public Call(Call call) { this.className = call.className; this.methodName = call.methodName; approxHcode = computeApproximatedHashCode(); hcode = computeHashCode(); }
/** * computes and returns the call contexts of the specific method * * @param className * @param methodName * @return */ public Set<CallContext> getMethodEntryPoint(String className, String methodName) { Set<CallContext> contexts = new HashSet<>(); List<Call> cont = new ArrayList<>(); cont.add(new Call(className, methodName)); CallContext context = new CallContext(cont); if(publicMethods.contains(context)){ contexts.add(context); }else{ contexts.add(new CallContext()); } return contexts; }
private void countGoals(List<IBranchTestFitness> branchGoals) { int totalGoals = branchGoals.size(); int goalsInTarget = 0; for (IBranchTestFitness g : branchGoals) { boolean flag = true; for (Call call : g.getContext().getContext()) { if (!call.getClassName().equals(Properties.TARGET_CLASS)) { flag = false; break; } } if (flag) goalsInTarget++; } ClientServices.getInstance().getClientNode() .trackOutputVariable(RuntimeVariable.IBranchInitialGoals, totalGoals); ClientServices .getInstance() .getClientNode() .trackOutputVariable(RuntimeVariable.IBranchInitialGoalsInTargetClass, goalsInTarget); }
private Set<CallContext> convertIntoCallContext( Set<List<CallGraphEntry>> paths) { Set<CallContext> contexts = new HashSet<>(); // return only context that starts from the class under test for (List<CallGraphEntry> list : paths) { boolean insert = false; List<Call> cont = new ArrayList<>(); for (int i = list.size() - 1; i >= 0; i--) { if (!insert && list.get(i).getClassName().equals(className)) { insert = true; } if (insert) cont.add(new Call(list.get(i).getClassName(), list.get(i) .getMethodName())); } contexts.add(new CallContext(cont)); } return contexts; }