<commit_before>package com.poolik.classfinder;

import com.poolik.classfinder.filter.*;
import com.poolik.classfinder.info.ClassInfo;
import com.poolik.classfinder.otherTestClasses.ConcreteClass;
import com.poolik.classfinder.otherTestClasses.SomeInterface;
import com.poolik.classfinder.testClasses.TestClass1;
import org.junit.Test;

import java.io.File;
import java.util.Collection;

import static org.hamcrest.core.AnyOf.anyOf;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

public class ClassFinderFilterTest extends TestWithTestClasses {

  @Test
  public void filtersInterfaces() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(new Interface());
    assertThat(classes.size(), is(1));
    assertThat(classes.iterator().next().getClassName(), is(SomeInterface.class.getName()));
  }

  @Test
  public void filtersAbstractClasses() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(new AbstractClass());

    assertThat(classes.size(), is(1));
    assertThat(classes.iterator().next().getClassName(), is(com.poolik.classfinder.otherTestClasses.AbstractClass.class.getName()));
  }

  @Test
  public void filtersByClassNameRegex() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(new Regex(".*\\d$"));
    assertThat(classes.size(), is(3));
  }

  @Test
  public void filtersSubclassesOfAbstractClass() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(new Subclass(com.poolik.classfinder.otherTestClasses.AbstractClass.class));
    assertThat(classes.size(), is(1));
    assertThat(classes.iterator().next().getClassName(), is(ConcreteClass.class.getName()));
  }

  @Test
  public void filtersSubclassesOfInterface() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(new Subclass(SomeInterface.class));
    assertThat(classes.size(), is(3));
  }

  @Test
  public void combinesFiltersWithAnd() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(new And(new Subclass(SomeInterface.class), new AbstractClass()));
    assertThat(classes.size(), is(1));
    assertThat(classes.iterator().next().getClassName(), is(com.poolik.classfinder.otherTestClasses.AbstractClass.class.getName()));
  }

  @Test
  public void combinesFiltersWithOr() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(new Or(new Regex(".*1$"), new AbstractClass()));
    assertThat(classes.size(), is(2));
    assertThat(classes.iterator().next().getClassName(), anyOf(is(TestClass1.class.getName()), is(com.poolik.classfinder.otherTestClasses.AbstractClass.class.getName())));
    assertThat(classes.iterator().next().getClassName(), anyOf(is(TestClass1.class.getName()), is(com.poolik.classfinder.otherTestClasses.AbstractClass.class.getName())));
  }

  @Test
  public void invertsFilterWithNot() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(new Not(new Regex(".*\\d$")));
    assertThat(classes.size(), is(6));
  }

  private ClassFinder getClassFinder() {
    ClassFinder classFinder = new ClassFinder();
    classFinder.add(new File[]{otherClassesFolder.toFile(), classesFolder.toFile()});
    return classFinder;
  }
}
<commit_msg>Updates some tests to use new factory methods<commit_after>package com.poolik.classfinder;

import com.poolik.classfinder.filter.*;
import com.poolik.classfinder.info.ClassInfo;
import com.poolik.classfinder.otherTestClasses.ConcreteClass;
import com.poolik.classfinder.otherTestClasses.SomeInterface;
import com.poolik.classfinder.testClasses.TestClass1;
import org.junit.Test;

import java.io.File;
import java.util.Collection;

import static org.hamcrest.core.AnyOf.anyOf;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

public class ClassFinderFilterTest extends TestWithTestClasses {

  @Test
  public void filtersInterfaces() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(new Interface());
    assertThat(classes.size(), is(1));
    assertThat(classes.iterator().next().getClassName(), is(SomeInterface.class.getName()));
  }

  @Test
  public void filtersAbstractClasses() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(new AbstractClass());

    assertThat(classes.size(), is(1));
    assertThat(classes.iterator().next().getClassName(), is(com.poolik.classfinder.otherTestClasses.AbstractClass.class.getName()));
  }

  @Test
  public void filtersByClassNameRegex() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(Regex.matches(".*\\d$"));
    assertThat(classes.size(), is(3));
  }

  @Test
  public void filtersSubclassesOfAbstractClass() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(Subclass.of(com.poolik.classfinder.otherTestClasses.AbstractClass.class));
    assertThat(classes.size(), is(1));
    assertThat(classes.iterator().next().getClassName(), is(ConcreteClass.class.getName()));
  }

  @Test
  public void filtersSubclassesOfInterface() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(new Subclass(SomeInterface.class));
    assertThat(classes.size(), is(3));
  }

  @Test
  public void combinesFiltersWithAnd() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(And.allOf(Subclass.of(SomeInterface.class), new AbstractClass()));
    assertThat(classes.size(), is(1));
    assertThat(classes.iterator().next().getClassName(), is(com.poolik.classfinder.otherTestClasses.AbstractClass.class.getName()));
  }

  @Test
  public void combinesFiltersWithOr() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(Or.anyOf(Regex.matches(".*1$"), new AbstractClass()));
    assertThat(classes.size(), is(2));
    assertThat(classes.iterator().next().getClassName(), anyOf(is(TestClass1.class.getName()), is(com.poolik.classfinder.otherTestClasses.AbstractClass.class.getName())));
    assertThat(classes.iterator().next().getClassName(), anyOf(is(TestClass1.class.getName()), is(com.poolik.classfinder.otherTestClasses.AbstractClass.class.getName())));
  }

  @Test
  public void invertsFilterWithNot() {
    Collection<ClassInfo> classes = getClassFinder().findClasses(Not.a(Regex.matches(".*\\d$")));
    assertThat(classes.size(), is(6));
  }

  private ClassFinder getClassFinder() {
    ClassFinder classFinder = new ClassFinder();
    classFinder.add(new File[]{otherClassesFolder.toFile(), classesFolder.toFile()});
    return classFinder;
  }
}

{'fraction_non_alphanumeric': 0.14668327623793212, 'fraction_numerical': 0.003737153534724385, 'mean_word_length': 5.891630901287554, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '980748', 'n_tokens_mistral': 1838, 'n_tokens_neox': 1877, 'n_words': 289}