<commit_before>package eu.ydp.empiria.player;

import java.lang.reflect.Method;
import java.util.Set;

import junit.framework.JUnit4TestAdapter;
import junit.framework.TestSuite;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.AllTests;
import org.reflections.Reflections;
import org.reflections.scanners.MethodAnnotationsScanner;
import org.reflections.scanners.Scanner;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.FilterBuilder;

import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;

import eu.ydp.gwtutil.junit.runners.ExMockRunner;

@RunWith(AllTests.class)
@SuppressWarnings("PMD")
public class JUnitTTestSuite {

	private final static Predicate<Class<?>> filterUnsupportedClazz = new Predicate<Class<?>>() {
		@Override
		public boolean apply(Class<?> clazz) {
			if (clazz.isAnnotationPresent(RunWith.class)) {
				if (clazz.getAnnotation(RunWith.class).value().isAssignableFrom(ExMockRunner.class)) {
					return false;
				}
			}
			return true;
		}
	};


	private final static Predicate<String> onlyMethodWithTestAnnotation = new Predicate<String>() {
		@Override
		public boolean apply(String name) {
			return name.contains("org.junit.Test");
		}
	};

	private final static Predicate<String> onlyClassEndsWithTest = new Predicate<String>() {
		@Override
		public boolean apply(String name) {
			return name.endsWith("Test.class");
		}
	};
	public static TestSuite suite() {
		TestSuite junitSuite = new TestSuite();
		Iterable<Class<?>> filteredClasses = Iterables.filter(getAllTestsClass(), filterUnsupportedClazz);
		for (Class<?> clazz :  filteredClasses) {
			JUnit4TestAdapter adapter = new JUnit4TestAdapter(clazz);
			junitSuite.addTest(adapter);
		}

		return junitSuite;
	}

	public static Set<Class<?>> getAllTestsClass() {

		ConfigurationBuilder inputFilterByName = new ConfigurationBuilder().filterInputsBy(new FilterBuilder().add(onlyClassEndsWithTest));
		Scanner methodFilterByTestAnnotation = new MethodAnnotationsScanner().filterResultsBy(onlyMethodWithTestAnnotation);

		Reflections reflections = new Reflections(inputFilterByName.
				 setUrls(ClasspathHelper.forPackage("eu.ydp.empiria"))
				.setScanners(new SubTypesScanner(), methodFilterByTestAnnotation));

		Set<Class<?>> classes = Sets.newHashSet();
		Set<Method> methodsAnnotatedWith = reflections.getMethodsAnnotatedWith(Test.class);
		for (Method method : methodsAnnotatedWith) {
			classes.add(method.getDeclaringClass());
		}
		return classes;

	}
}<commit_msg>correct suite after review issue YPUB-5401<commit_after>package eu.ydp.empiria.player;

import java.lang.reflect.Method;
import java.util.Set;

import junit.framework.JUnit4TestAdapter;
import junit.framework.TestSuite;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.AllTests;
import org.reflections.Reflections;
import org.reflections.scanners.MethodAnnotationsScanner;
import org.reflections.scanners.Scanner;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.FilterBuilder;

import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;

import eu.ydp.gwtutil.junit.runners.ExMockRunner;

@RunWith(AllTests.class)
@SuppressWarnings("PMD")
public class JUnitTTestSuite {

	private final static Predicate<Class<?>> filterUnsupportedClazz = new Predicate<Class<?>>() {
		@Override
		public boolean apply(Class<?> clazz) {
			if (clazz.isAnnotationPresent(RunWith.class)) {
				if (ExMockRunner.class.isAssignableFrom(clazz.getAnnotation(RunWith.class).value())) {
					return false;
				}
			}
			return true;
		}
	};


	private final static Predicate<String> onlyMethodWithTestAnnotation = new Predicate<String>() {
		@Override
		public boolean apply(String name) {
			return name.contains("org.junit.Test");
		}
	};

	private final static Predicate<String> onlyClassEndsWithTest = new Predicate<String>() {
		@Override
		public boolean apply(String name) {
			return name.endsWith("Test.class");
		}
	};
	public static TestSuite suite() {
		TestSuite junitSuite = new TestSuite();
		Iterable<Class<?>> filteredClasses = getTestClasses();
		for (Class<?> clazz :  filteredClasses) {
			JUnit4TestAdapter adapter = new JUnit4TestAdapter(clazz);
			junitSuite.addTest(adapter);
		}

		return junitSuite;
	}

	public static Iterable<Class<?>> getTestClasses() {
		return Iterables.filter(getAllTestClasses(), filterUnsupportedClazz);
	}

	public static Set<Class<?>> getAllTestClasses() {

		ConfigurationBuilder inputFilterByName = new ConfigurationBuilder().filterInputsBy(new FilterBuilder().add(onlyClassEndsWithTest));
		Scanner methodFilterByTestAnnotation = new MethodAnnotationsScanner().filterResultsBy(onlyMethodWithTestAnnotation);

		Reflections reflections = new Reflections(inputFilterByName.
				 setUrls(ClasspathHelper.forPackage("eu.ydp.empiria"))
				.setScanners(new SubTypesScanner(), methodFilterByTestAnnotation));

		Set<Class<?>> classes = Sets.newHashSet();
		Set<Method> methodsAnnotatedWith = reflections.getMethodsAnnotatedWith(Test.class);
		for (Method method : methodsAnnotatedWith) {
			classes.add(method.getDeclaringClass());
		}
		return classes;

	}
}
{'fraction_non_alphanumeric': 0.11191992720655142, 'fraction_numerical': 0.0018198362147406734, 'mean_word_length': 5.9045226130653266, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2883000', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1662, 'n_words': 307}