content: package org.aksw.rdfunit.tests.generators;
  
  import com.google.common.collect.ImmutableList;
  import java.util.Collection;
  import java.util.List;
  import org.aksw.rdfunit.enums.TestGenerationType;
  import org.aksw.rdfunit.model.interfaces.TestGenerator;
  import org.aksw.rdfunit.tests.generators.monitors.TestGeneratorExecutorMonitor;
  
  /**
   * @author Dimitris Kontokostas
   * @since 2/11/18
   */
  public final class TestGeneratorFactory {
  
    private TestGeneratorFactory() {
    }
  
    public static RdfUnitTestGenerator createTagWithCacheGenerator(
        Collection<TestGenerator> testGenerators, String testFolder) {
      return new FirstSuccessfulTestGenerator(ImmutableList.of(
          new CacheTestGenerator(testFolder),
          new GenerateAndCacheRdfUnitTestGenerator(new TagRdfUnitTestGenerator(testGenerators),
              testFolder)
      ));
    }
  
    public static RdfUnitTestGenerator create(Collection<TestGenerator> testGenerators,
        String testFolder, boolean useAutoTests, boolean loadFromCache, boolean useManualTests) {
      return create(testGenerators, testFolder, useAutoTests, loadFromCache, useManualTests,
          ImmutableList.of());
    }
  
    public static RdfUnitTestGenerator create(Collection<TestGenerator> testGenerators,
        String testFolder, boolean useAutoTests, boolean loadFromCache, boolean useManualTests,
        Collection<TestGeneratorExecutorMonitor> monitors) {
      // tag / cache
      ImmutableList.Builder<RdfUnitTestGenerator> builder = ImmutableList.builder();
      if (useAutoTests) {
        if (loadFromCache) {
          builder.add(createTagWithCacheGenerator(testGenerators, testFolder));
        } else {
          builder.add(new TagRdfUnitTestGenerator(testGenerators));
        }
      }
      // add shacl eitherway
      builder.add(new ShaclTestGenerator());
  
      // read the manual RDFUnit tests that are defined
      builder.add(new ManualRdfunitTestReaderGenerator());
  
      List<RdfUnitTestGenerator> autogenerator = builder.build();
      RdfUnitTestGenerator autoGeneratorsWithMonitor = new RdfUnitTestGeneratorMonitor(
          new CompositeTestGenerator(autogenerator),
          monitors,
          TestGenerationType.AutoGenerated);
  
      // load the pre-defined manual tests for a source
      if (useManualTests) {
        RdfUnitTestGenerator manualGeneratorsWithMonitor = new RdfUnitTestGeneratorMonitor(
            new ManualRdfunitTestLoaderGenerator(testFolder),
            monitors,
            TestGenerationType.ManuallyGenerated);
  
        return new CompositeTestGenerator(
            ImmutableList.of(autoGeneratorsWithMonitor, manualGeneratorsWithMonitor));
  
      } else {
        return autoGeneratorsWithMonitor;
      }
    }
  
    public static RdfUnitTestGenerator createAllWithCache(Collection<TestGenerator> testGenerators,
        String testFolder) {
      return create(testGenerators, testFolder, true, true, true);
    }
  
    public static RdfUnitTestGenerator createAllNoCache(Collection<TestGenerator> testGenerators,
        String testFolder) {
      return create(testGenerators, testFolder, true, false, true);
    }
  
    public static RdfUnitTestGenerator createShaclOnly() {
      return new ShaclTestGenerator();
    }
  
    public static RdfUnitTestGenerator createShaclAndManualOnly(String testFolder) {
      return new CompositeTestGenerator(ImmutableList.of(
          new ShaclTestGenerator(),
          new ManualRdfunitTestLoaderGenerator(testFolder)
      ));
    }
  
    public static RdfUnitTestGenerator createShaclAndTagNoManual(
        Collection<TestGenerator> testGenerators) {
      return new CompositeTestGenerator(ImmutableList.of(
          new ShaclTestGenerator(),
          new TagRdfUnitTestGenerator(testGenerators)
      ));
    }
  }
  