<commit_before>package org.umlg.sqlg.test.gremlincompile;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;

import java.beans.PropertyVetoException;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;

import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.BeforeClass;
import org.junit.Test;
import org.umlg.sqlg.predicate.FullText;
import org.umlg.sqlg.structure.SchemaManager;
import org.umlg.sqlg.test.BaseTest;

/**
 * test full text support
 * @author jpmoresmau
 *
 */
public class TestGremlinCompileFullTextPredicate extends BaseTest {

    @BeforeClass
    public static void beforeClass() throws ClassNotFoundException, IOException, PropertyVetoException {
        BaseTest.beforeClass();
        if (configuration.getString("jdbc.url").contains("postgresql")) {
            configuration.addProperty("distributed", true);
        }
    }
	
	public TestGremlinCompileFullTextPredicate() {
		
	}
	
	@Test
	public void testDefaultImplementation(){
		FullText ft=new FullText("",true);
		assertTrue(ft.test("a fat cat sat on a mat and ate a fat rat", "cat"));
		assertTrue(ft.test("a fat cat sat on a mat and ate a fat rat", "cat rat"));
		assertFalse(ft.test("a fat cat sat on a mat and ate a fat rat", "cat cow"));
	}
	
	@Test
	public void testDocExamples() throws SQLException {
		 assumeTrue(configuration.getString("jdbc.url").contains("postgresql"));
		 Vertex v0=this.sqlgGraph.addVertex(T.label, "Sentence", "name", "a fat cat sat on a mat and ate a fat rat");
		 Vertex v1=this.sqlgGraph.addVertex(T.label, "Sentence", "name", "fatal error");
		 Vertex v2=this.sqlgGraph.addVertex(T.label, "Sentence", "name", "error is not fatal");
		 
		 
		 this.sqlgGraph.tx().commit();
		 try (Statement s=this.sqlgGraph.tx().getConnection().createStatement();){
			 String create="CREATE INDEX sentence_idx ON \""+SchemaManager.VERTEX_PREFIX+"Sentence\" USING GIN (to_tsvector('english', name))";
			 s.execute(create);
		 }
		 this.sqlgGraph.tx().commit();
		 <commit_msg>Please codacy<commit_after>package org.umlg.sqlg.test.gremlincompile;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;

import java.beans.PropertyVetoException;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;

import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.BeforeClass;
import org.junit.Test;
import org.umlg.sqlg.predicate.FullText;
import org.umlg.sqlg.structure.SchemaManager;
import org.umlg.sqlg.test.BaseTest;

/**
 * test full text support
 * @author jpmoresmau
 *
 */
public class TestGremlinCompileFullTextPredicate extends BaseTest {

    @BeforeClass
    public static void beforeClass() throws ClassNotFoundException, IOException, PropertyVetoException {
        BaseTest.beforeClass();
        if (configuration.getString("jdbc.url").contains("postgresql")) {
            configuration.addProperty("distributed", true);
        }
    }

	
	@Test
	public void testDefaultImplementation(){
		FullText ft=new FullText("",true);
		assertTrue(ft.test("a fat cat sat on a mat and ate a fat rat", "cat"));
		assertTrue(ft.test("a fat cat sat on a mat and ate a fat rat", "cat rat"));
		assertFalse(ft.test("a fat cat sat on a mat and ate a fat rat", "cat cow"));
	}
	
	@Test
	public void testDocExamples() throws SQLException {
		 assumeTrue(configuration.getString("jdbc.url").contains("postgresql"));
		 Vertex v0=this.sqlgGraph.addVertex(T.label, "Sentence", "name", "a fat cat sat on a mat and ate a fat rat");
		 Vertex v1=this.sqlgGraph.addVertex(T.label, "Sentence", "name", "fatal error");
		 Vertex v2=this.sqlgGraph.addVertex(T.label, "Sentence", "name", "error is not fatal");
		 
		 
		 this.sqlgGraph.tx().commit();
		 try (Statement s=this.sqlgGraph.tx().getConnection().createStatement();){
			 String create="CREATE INDEX sentence_idx ON \""+SchemaManager.VERTEX_PREFIX+"Sentence\" USING GIN (to_tsvector('english', name))";
			 s.execute(create);
		 }
		 this.sqlgGraph.tx().commit();
		 
{'fraction_non_alphanumeric': 0.12917898567204913, 'fraction_numerical': 0.001364566750056857, 'mean_word_length': 4.652956298200514, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3639119', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1338, 'n_words': 331}