Fork me on GitHub

CPD Results

The following document contains the results of PMD's CPD 7.17.0.

Duplications

File Line
org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java 486
org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java 520
PostDiscoveryFilter getIncludeCategoryFilter(List<String> categories, Optional<Class<?>> categoryClass) {

        return testDescriptor -> {
            Optional<MethodSource> methodSource = testDescriptor
                    .getSource()
                    .filter(testSource -> testSource instanceof MethodSource)
                    .map(testSource -> (MethodSource) testSource);
            boolean hasCategoryClass = false, hasCategoryMethod = false;
            if (methodSource.isPresent()) {
                if (categoryClass.isPresent()) {
                    hasCategoryMethod = hasCategoryAnnotationValue(
                                    methodSource.get().getJavaMethod(), categoryClass.orElse(null), categories)
                            || hasCategoryAnnotationValue(
                                    methodSource.get().getJavaClass(), categoryClass.orElse(null), categories);
                }
            }

            Optional<ClassSource> classSource = testDescriptor
                    .getSource()
                    .filter(testSource -> testSource instanceof ClassSource)
                    .map(testSource -> (ClassSource) testSource);
            if (classSource.isPresent()) {
                if (categoryClass.isPresent()) {
                    hasCategoryClass = hasCategoryAnnotationValue(
                            classSource.get().getJavaClass(), categoryClass.orElse(null), categories);
                }
            }

            return hasCategoryClass || hasCategoryMethod
                    ? FilterResult.included("Category found")
File Line
org/apache/maven/surefire/junitplatform/JUnit4ListenersAdapter.java 41
org/apache/maven/surefire/junitplatform/JUnit4ListenersAdapter.java 110
public void executionStarted(TestIdentifier testIdentifier) {
        listeners.forEach(runListener -> {
            try {
                Class<?> descriptionClass =
                        Thread.currentThread().getContextClassLoader().loadClass("org.junit.runner.Description");
                Method createTestDescription = descriptionClass.getMethod(
                        "createTestDescription", String.class, String.class, Annotation[].class);
                if (testIdentifier.getSource().isPresent()
                        && testIdentifier.getSource().get() instanceof ClassSource) {
                    String className = ((ClassSource) testIdentifier.getSource().get()).getClassName();
                    Class<?> classToRemove =
                            Thread.currentThread().getContextClassLoader().loadClass(className);
                    Object invoke = createTestDescription.invoke(
                            descriptionClass, classToRemove.getName(), testIdentifier.getDisplayName(), null);
                    runListener
                            .getClass()
                            .getMethod("testRunStarted", descriptionClass)
File Line
org/apache/maven/surefire/junitplatform/JUnit4ListenersAdapter.java 41
org/apache/maven/surefire/junitplatform/JUnit4ListenersAdapter.java 73
org/apache/maven/surefire/junitplatform/JUnit4ListenersAdapter.java 110
public void executionStarted(TestIdentifier testIdentifier) {
        listeners.forEach(runListener -> {
            try {
                Class<?> descriptionClass =
                        Thread.currentThread().getContextClassLoader().loadClass("org.junit.runner.Description");
                Method createTestDescription = descriptionClass.getMethod(
                        "createTestDescription", String.class, String.class, Annotation[].class);
                if (testIdentifier.getSource().isPresent()
                        && testIdentifier.getSource().get() instanceof ClassSource) {
                    String className = ((ClassSource) testIdentifier.getSource().get()).getClassName();
                    Class<?> classToRemove =
                            Thread.currentThread().getContextClassLoader().loadClass(className);
                    Object invoke = createTestDescription.invoke(
                            descriptionClass, classToRemove.getName(), testIdentifier.getDisplayName(), null);