protected CtType findClassUnderTest(CtType testClass) { String testClassName = testClass.getQualifiedName(); return AmplificationHelper.computeClassProvider(testClass) .stream() .filter(cl -> cl != null) .filter(cl -> cl != testClass) .filter(cl -> testClassName.contains(cl.getSimpleName())) .findFirst() .orElse(null); }
protected double getCoverageForMethod(Coverage coverage, CtType cl, CtMethod mth) { if (coverage == null) { return 0d; } String key = mth.getDeclaringType().getQualifiedName() + "_" + mth.getType().getQualifiedName() + "_" + mth.getSimpleName() + "(" + mth.getParameters() .stream() .map(param -> ((CtParameter) param).getType().getQualifiedName()) .collect(Collectors.joining(",")) + ")"; if (coverage.getMethodCoverage(key) != null) { return coverage.getMethodCoverage(key).coverage(); } else { key = cl.getQualifiedName() + "_" + mth.getType().getQualifiedName() + "_" + mth.getSimpleName() + "(" + mth.getParameters() .stream() .map(param -> ((CtParameter) param).getType().getQualifiedName()) .collect(Collectors.joining(",")) + ")"; if (coverage.getMethodCoverage(key) != null) { return coverage.getMethodCoverage(key).coverage(); } else { return 0d; } } }