<commit_before>/*******************************************************************************
 * Copyright (c) 2018 Eclipse RDF4J contributors.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Distribution License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *******************************************************************************/

package org.eclipse.rdf4j.sail.shacl;

import org.eclipse.rdf4j.IsolationLevel;
import org.eclipse.rdf4j.IsolationLevels;
import org.eclipse.rdf4j.common.io.IOUtil;
import org.eclipse.rdf4j.model.Model;
import org.eclipse.rdf4j.repository.RepositoryException;
import org.eclipse.rdf4j.repository.sail.SailRepository;
import org.eclipse.rdf4j.repository.sail.SailRepositoryConnection;
import org.eclipse.rdf4j.rio.RDFFormat;
import org.eclipse.rdf4j.rio.Rio;
import org.eclipse.rdf4j.sail.memory.MemoryStore;
import org.eclipse.rdf4j.sail.shacl.planNodes.LoggingNode;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;

/**
 * @author <NAME>
 */
@RunWith(Parameterized.class)
abstract public class AbstractShaclTest {

	private static final List<String> testCasePaths = Stream.of(
		"test-cases/complex/dcat",
		"test-cases/complex/foaf",
		"test-cases/datatype/simple",
		"test-cases/datatype/targetNode",
		"test-cases/datatype/targetSubjectsOf",
		"test-cases/datatype/targetSubjectsOfSingle",
		"test-cases/datatype/targetObjectsOf",
		"test-cases/minLength/simple",
		"test-cases/maxLength/simple",
		"test-cases/pattern/simple",
		"test-cases/pattern/multiple",
		"test-cases/languageIn/simple",
		"test-cases/nodeKind/simple",
		"test-cases/minCount/simple",
		"test-cases/minCount/targetNode",
		"test-cases/maxCount/simple",
		"test-cases/maxCount/targetNode",
		"test-cases/or/multiple",
		"test-cases/or/inheritance",
		"test-cases/or/inheritance-deep",
		"test-cases/or/inheritance-deep-minCountMaxCount",
		"test-cases/or/inheritanceNodeShape",
		"test-cases/or/datatype",
		"test-cases/or/datatypeTargetNode",
		"test-cases/or/minCountMaxCount",
		"test-cases/or/maxCount",
		"test-cases/or/minCount",
		"test-cases/or/nodeKindMinLength",
		"test-cases/or/implicitAnd",
		"test-cases/or/datatypeDifferentPaths",
		"test-cases/minExclusive/simple",
		"test-cases/minExclusive/dateVsTime",
		"test-cases/maxExclusive/simple",
		"test-cases/minInclusive/simple",
		"test-cases/maxInclusive/simple",
		"test-cases/implicitTargetClass/simple",
		"test-cases/class/simple",
		"test-cases/class/subclass",
		"test-cases/class/targetNode",
		"test-cases/class/multipleClass",
		"test-cases/or/class",
		"test-cases/or/datatype2",
		"test-cases/or/minCountDifferentPath",
		"test-cases/deactivated/nodeshape",
		"test-cases/deactivated/or",
		"test-cases/deactivated/propertyshape"
	)
		.distinct()
		.collect(Collectors.toList());


	final String testCasePath;
	final String path;
	final ExpectedResult expectedResult;
	final IsolationLevel isolationLevel;

	public AbstractShaclTest(String testCasePath, String path, ExpectedResult expectedResult, IsolationLevel isolationLevel) {
		this.testCasePath = testCasePath;
		this.path = path;
		this.expectedResult = expectedResult;
		LoggingNode.loggingEnabled = true;
		this.isolationLevel = isolationLevel;
	}

	@Parameterized.Parameters(name = "{2} - {1} - {3}")
	public static Collection<Object[]> data() {

		return getTestsToRun();
	}


	private static List<String> findTestCases(String testCase, String baseCase) {

		List<String> ret = new ArrayList<>();

		for (int i = 0; i < 1000; i++) {
			String path = testCase + "/" + baseCase + "/case" + i;
			InputStream resourceAsStream = AbstractShaclTest.class.getClassLoader().getResourceAsStream(path);
			if (resourceAsStream != null) {
				ret.add(path);
				try {
					resourceAsStream.close();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}

		return ret;<commit_msg>make tests faster to initiate<commit_after>/*******************************************************************************
 * Copyright (c) 2018 Eclipse RDF4J contributors.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Distribution License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *******************************************************************************/

package org.eclipse.rdf4j.sail.shacl;

import org.eclipse.rdf4j.IsolationLevel;
import org.eclipse.rdf4j.IsolationLevels;
import org.eclipse.rdf4j.common.io.IOUtil;
import org.eclipse.rdf4j.model.Model;
import org.eclipse.rdf4j.repository.RepositoryException;
import org.eclipse.rdf4j.repository.sail.SailRepository;
import org.eclipse.rdf4j.repository.sail.SailRepositoryConnection;
import org.eclipse.rdf4j.rio.RDFFormat;
import org.eclipse.rdf4j.rio.Rio;
import org.eclipse.rdf4j.sail.memory.MemoryStore;
import org.eclipse.rdf4j.sail.shacl.planNodes.LoggingNode;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;

/**
 * @author <NAME>
 */
@RunWith(Parameterized.class)
abstract public class AbstractShaclTest {

	private static final List<String> testCasePaths = Stream.of(
		"test-cases/complex/dcat",
		"test-cases/complex/foaf",
		"test-cases/datatype/simple",
		"test-cases/datatype/targetNode",
		"test-cases/datatype/targetSubjectsOf",
		"test-cases/datatype/targetSubjectsOfSingle",
		"test-cases/datatype/targetObjectsOf",
		"test-cases/minLength/simple",
		"test-cases/maxLength/simple",
		"test-cases/pattern/simple",
		"test-cases/pattern/multiple",
		"test-cases/languageIn/simple",
		"test-cases/nodeKind/simple",
		"test-cases/minCount/simple",
		"test-cases/minCount/targetNode",
		"test-cases/maxCount/simple",
		"test-cases/maxCount/targetNode",
		"test-cases/or/multiple",
		"test-cases/or/inheritance",
		"test-cases/or/inheritance-deep",
		"test-cases/or/inheritance-deep-minCountMaxCount",
		"test-cases/or/inheritanceNodeShape",
		"test-cases/or/datatype",
		"test-cases/or/datatypeTargetNode",
		"test-cases/or/minCountMaxCount",
		"test-cases/or/maxCount",
		"test-cases/or/minCount",
		"test-cases/or/nodeKindMinLength",
		"test-cases/or/implicitAnd",
		"test-cases/or/datatypeDifferentPaths",
		"test-cases/minExclusive/simple",
		"test-cases/minExclusive/dateVsTime",
		"test-cases/maxExclusive/simple",
		"test-cases/minInclusive/simple",
		"test-cases/maxInclusive/simple",
		"test-cases/implicitTargetClass/simple",
		"test-cases/class/simple",
		"test-cases/class/subclass",
		"test-cases/class/targetNode",
		"test-cases/class/multipleClass",
		"test-cases/or/class",
		"test-cases/or/datatype2",
		"test-cases/or/minCountDifferentPath",
		"test-cases/deactivated/nodeshape",
		"test-cases/deactivated/or",
		"test-cases/deactivated/propertyshape"
	)
		.distinct()
		.collect(Collectors.toList());


	final String testCasePath;
	final String path;
	final ExpectedResult expectedResult;
	final IsolationLevel isolationLevel;

	public AbstractShaclTest(String testCasePath, String path, ExpectedResult expectedResult, IsolationLevel isolationLevel) {
		this.testCasePath = testCasePath;
		this.path = path;
		this.expectedResult = expectedResult;
		LoggingNode.loggingEnabled = true;
		this.isolationLevel = isolationLevel;
	}

	@Parameterized.Parameters(name = "{2} - {1} - {3}")
	public static Collection<Object[]> data() {

		return getTestsToRun();
	}


	private static List<String> findTestCases(String testCase, String baseCase) {

		List<String> ret = new ArrayList<>();

		for (int i = 0; i < 100; i++) {
			String path = testCase + "/" + baseCase + "/case" + i;
			InputStream resourceAsStream = AbstractShaclTest.class.getClassLoader().getResourceAsStream(path);
			if (resourceAsStream != null) {
				ret.add(path);
				try {
					resourceAsStream.close();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}

		return ret;
{'fraction_non_alphanumeric': 0.16527028577986916, 'fraction_numerical': 0.006771490875702973, 'mean_word_length': 5.005513439007581, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5937645', 'n_tokens_mistral': 3063, 'n_tokens_neox': 2821, 'n_words': 463}