<commit_before>package es.moki.ratelimitj.core.limiter.request;

import org.junit.jupiter.api.Test;

import java.time.Duration;
import java.util.concurrent.TimeUnit;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

class RequestLimitRuleTest {

    @Test
    void shouldHaveDuration1Seconds() {

        RequestLimitRule requestLimitRule = RequestLimitRule.of(Duration.ofSeconds(1), 5);

        assertThat(requestLimitRule.getDurationSeconds()).isEqualTo(1);
    }

    @Test
    void shouldHaveDuration60Seconds() {
        RequestLimitRule requestLimitRule = RequestLimitRule.of(Duration.ofMinutes(1), 5);

        assertThat(requestLimitRule.getDurationSeconds()).isEqualTo(60);
    }

    @Test
    void shouldDefaultPrecisionToEqualDuration() {
        RequestLimitRule requestLimitRule = RequestLimitRule.of(Duration.ofMinutes(1), 5);

        assertThat(requestLimitRule.getPrecision()).isEqualTo(60);
    }

    @Test
    void shouldHaveLimit5() {
        RequestLimitRule requestLimitRule = RequestLimitRule.of(Duration.ofMinutes(1), 5);

        assertThat(requestLimitRule.getLimit()).isEqualTo(5);
    }

    @Test
    void shouldHavePrecisionOf10() {
        RequestLimitRule requestLimitRule = RequestLimitRule.of(Duration.ofSeconds(1), 5).withPrecision(10);

        assertThat(requestLimitRule.getPrecision()).isEqualTo(10);
    }

    @Test
    void shouldHaveNameOfBoom() {
        RequestLimitRule requestLimitRule = RequestLimitRule.of(Duration.ofSeconds(1), 5).withName("boom");

        assertThat(requestLimitRule.getName()).isEqualTo("boom");
    }

    @Test
    public void shouldHaveLimitGreaterThanZero() {
        assertThatThrownBy(() -> RequestLimitRule.of(Duration.ofSeconds(1), -1).withName("boom") );
    }

}<commit_msg>Fix ensure limit is greater than zero test<commit_after>package es.moki.ratelimitj.core.limiter.request;

import org.junit.jupiter.api.Test;

import java.time.Duration;
import java.util.concurrent.TimeUnit;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

class RequestLimitRuleTest {

    @Test
    void shouldHaveDuration1Seconds() {

        RequestLimitRule requestLimitRule = RequestLimitRule.of(Duration.ofSeconds(1), 5);

        assertThat(requestLimitRule.getDurationSeconds()).isEqualTo(1);
    }

    @Test
    void shouldHaveDuration60Seconds() {
        RequestLimitRule requestLimitRule = RequestLimitRule.of(Duration.ofMinutes(1), 5);

        assertThat(requestLimitRule.getDurationSeconds()).isEqualTo(60);
    }

    @Test
    void shouldDefaultPrecisionToEqualDuration() {
        RequestLimitRule requestLimitRule = RequestLimitRule.of(Duration.ofMinutes(1), 5);

        assertThat(requestLimitRule.getPrecision()).isEqualTo(60);
    }

    @Test
    void shouldHaveLimit5() {
        RequestLimitRule requestLimitRule = RequestLimitRule.of(Duration.ofMinutes(1), 5);

        assertThat(requestLimitRule.getLimit()).isEqualTo(5);
    }

    @Test
    void shouldHavePrecisionOf10() {
        RequestLimitRule requestLimitRule = RequestLimitRule.of(Duration.ofSeconds(1), 5).withPrecision(10);

        assertThat(requestLimitRule.getPrecision()).isEqualTo(10);
    }

    @Test
    void shouldHaveNameOfBoom() {
        RequestLimitRule requestLimitRule = RequestLimitRule.of(Duration.ofSeconds(1), 5).withName("boom");

        assertThat(requestLimitRule.getName()).isEqualTo("boom");
    }

    @Test
    public void shouldHaveLimitGreaterThanZero() {
        assertThatThrownBy(() -> RequestLimitRule.of(Duration.ofSeconds(1), -1).withName("boom")).isInstanceOf(IllegalArgumentException.class);
    }

}
{'fraction_non_alphanumeric': 0.1123294998662744, 'fraction_numerical': 0.016047071409467772, 'mean_word_length': 4.187239944521498, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1896131', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1094, 'n_words': 149}