protected List<InputContext> getInputContexts(CtMethod method) { List<InputContext> inputContexts = new ArrayList<>(); List<CtStatement> statements = getAssertStatement(method); for (CtStatement stmt : statements) { Set<CtVariableReference> varRefs = new HashSet<>(); for (CtLocalVariable var : getLocalVarInScope(stmt)) { varRefs.add(method.getFactory().Code().createLocalVariableReference(var)); } inputContexts.add(new InputContext(varRefs)); } return inputContexts; }
public void reset(Coverage coverage, CtType testClass) { AmplificationHelper.reset(); literalsByMethod = new HashMap<>(); Set<CtType> codeFragmentsProvide = AmplificationHelper.computeClassProvider(testClass); List<Statement> codeFragmentsByClass = codeFragmentsProvide .stream() .flatMap( cl -> { List<CtStatement> list = Query.getElements(cl, new TypeFilter(CtStatement.class)); return list.stream(); }) .filter( stmt -> { try { return stmt.getParent() != null; } catch (Exception e) { return false; } }) .filter(stmt -> stmt.getParent() instanceof CtBlock) .filter(stmt -> !stmt.toString().startsWith("super")) .filter(stmt -> !stmt.toString().startsWith("this(")) .map(stmt -> new Statement(stmt)) .collect(Collectors.toList()); if (findClassUnderTest(testClass) != null) { coverageBycodeFragments = buildCodeFragmentFor(findClassUnderTest(testClass), coverage); } else { coverageBycodeFragments = new HashMap<>(); } Set<Integer> ids = new HashSet<>(); localVars = codeFragmentsByClass .stream() .filter(cf -> isValidCodeFragment(cf)) .filter(cf -> ids.add(cf.id())) .collect(Collectors.toList()); }