<commit_before>package com.github.bedrin.jdbc.sniffer.junit;

import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class QueryCounterTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    @Rule
    public QueryCounter queryCounter = new QueryCounter();

    @BeforeClass
    public static void loadDriver() throws ClassNotFoundException {
        Class.forName("com.github.bedrin.jdbc.sniffer.MockDriver");
    }

    @Test
    @AllowedQueries(1)
    public void testAllowedOneQuery() throws SQLException {
        Connection connection = DriverManager.getConnection("sniffer:jdbc:h2:~/test", "sa", "sa");
        connection.createStatement().execute("SELECT 1 FROM DUAL");
    }

    @Test
    @NotAllowedQueries
    public void testNotAllowedQueries() throws SQLException {
        Connection connection = DriverManager.getConnection("sniffer:jdbc:h2:~/test", "sa", "sa");
        connection.createStatement().execute("SELECT 1 FROM DUAL");
        thrown.expect(IllegalStateException.class);
    }

    @Test
    @AllowedQueries(1)
    public void testAllowedOneQueryExecutedTwo() throws SQLException {
        Connection connection = DriverManager.getConnection("sniffer:jdbc:h2:~/test", "sa", "sa");
        connection.createStatement().execute("SELECT 1 FROM DUAL");
        connection.createStatement().execute("SELECT 1 FROM DUAL");
        thrown.expect(IllegalStateException.class);
    }

    @Test
    @AllowedQueries(2)
    public void testAllowedTwoQueries() throws SQLException {
        Connection connection = DriverManager.getConnection("sniffer:jdbc:h2:~/test", "sa", "sa");
        connection.createStatement().execute("SELECT 1 FROM DUAL");
        connection.createStatement().execute("SELECT 1 FROM DUAL");
    }

}<commit_msg>Added unit test for @AllowedQueries(min = 1)<commit_after>package com.github.bedrin.jdbc.sniffer.junit;

import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class QueryCounterTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    @Rule
    public QueryCounter queryCounter = new QueryCounter();

    @BeforeClass
    public static void loadDriver() throws ClassNotFoundException {
        Class.forName("com.github.bedrin.jdbc.sniffer.MockDriver");
    }

    @Test
    @AllowedQueries(1)
    public void testAllowedOneQuery() throws SQLException {
        Connection connection = DriverManager.getConnection("sniffer:jdbc:h2:~/test", "sa", "sa");
        connection.createStatement().execute("SELECT 1 FROM DUAL");
    }

    @Test
    @NotAllowedQueries
    public void testNotAllowedQueries() throws SQLException {
        Connection connection = DriverManager.getConnection("sniffer:jdbc:h2:~/test", "sa", "sa");
        connection.createStatement().execute("SELECT 1 FROM DUAL");
        thrown.expect(IllegalStateException.class);
    }

    @Test
    @AllowedQueries(1)
    public void testAllowedOneQueryExecutedTwo() throws SQLException {
        Connection connection = DriverManager.getConnection("sniffer:jdbc:h2:~/test", "sa", "sa");
        connection.createStatement().execute("SELECT 1 FROM DUAL");
        connection.createStatement().execute("SELECT 1 FROM DUAL");
        thrown.expect(IllegalStateException.class);
    }

    @Test
    @AllowedQueries(min = 1)
    public void testAllowedMinOneQueryExecutedTwo() throws SQLException {
        Connection connection = DriverManager.getConnection("sniffer:jdbc:h2:~/test", "sa", "sa");
        connection.createStatement().execute("SELECT 1 FROM DUAL");
        connection.createStatement().execute("SELECT 1 FROM DUAL");
    }

    @Test
    @AllowedQueries(2)
    public void testAllowedTwoQueries() throws SQLException {
        Connection connection = DriverManager.getConnection("sniffer:jdbc:h2:~/test", "sa", "sa");
        connection.createStatement().execute("SELECT 1 FROM DUAL");
        connection.createStatement().execute("SELECT 1 FROM DUAL");
    }

}
{'fraction_non_alphanumeric': 0.11716557530402245, 'fraction_numerical': 0.007249766136576239, 'mean_word_length': 4.014067995310668, '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': '420311', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1170, 'n_words': 250}