<commit_before>package com.github.nyrkovalex.seed.test;

import org.hamcrest.CoreMatchers;
import org.hamcrest.Matcher;
import org.junit.Assert;
import org.junit.Before;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.stubbing.OngoingStubbing;
import org.mockito.verification.VerificationMode;


@SuppressWarnings("UnusedDeclaration")
public final class Seed {
    // This class is factored out to standalone module to be used as a dependency with `test` scope

    private Seed() {
    }

    /**
     * This class is used as a base for all unit tests
     */
    public static abstract class Test {
        /**
         * Shorthand for <code>assertThat(condition, is(true));</code>
         *
         * @param condition assertion to verify
         * @see org.junit.Assert#assertThat(Object, org.hamcrest.Matcher)
         */
        public static void assertThat(boolean condition) {
            Assert.assertThat(condition, is(true));
        }

        /**
         * Delegates directly to the {@link org.junit.Assert#assertThat(Object, org.hamcrest.Matcher)}
         * so you won't have to import it for each test
         *
         * @see org.junit.Assert#assertThat(Object, org.hamcrest.Matcher)
         */
        public static <T> void assertThat(T actual, Matcher<? super T> matcher) {
            Assert.assertThat(actual, matcher);
        }


        /**
         * Delegates directly to the {@link org.junit.Assert#assertThat(String, Object, org.hamcrest.Matcher)}
         * so you won't have to import it for each test
         *
         * @see org.junit.Assert#assertThat(String, Object, org.hamcrest.Matcher)
         */
        public static <T> void assertThat(String reason, T actual, Matcher<? super T> matcher) {
            Assert.assertThat(reason, actual, matcher);
        }

        /**
         * Delegates to {@link org.hamcrest.CoreMatchers#is(Object)}.
         *
         * @see org.hamcrest.CoreMatchers#is(java.lang.Object)
         */
        public static <T> Matcher<T> is(T value) {
            return CoreMatchers.is(value);
        }

        /**
         * Delegates to {@link org.hamcrest.CoreMatchers#is(org.hamcrest.Matcher)}.
         *
         * @see org.hamcrest.CoreMatchers#is(org.hamcrest.Matcher)
         */
        public static <T> Matcher<T> is(Matcher<T> matcher) {
            return CoreMatchers.is(matcher);
        }

        /**
         * Delegates to {@link org.hamcrest.CoreMatchers#sameInstance(Object)}
         *
         * @see org.hamcrest.CoreMatchers#sameInstance(Object)
         */
        public static <T> Matcher<T> sameInstance(T target) {
            return CoreMatchers.sameInstance(target);
        }

        /**
         * Delegates to {@link org.hamcrest.CoreMatchers#instanceOf(Class)}
         *
         * @see org.hamcrest.CoreMatchers#instanceOf(Class)
         */
        public static <T> Matcher<T> instanceOf(Class<?> type) {
            return CoreMatchers.instanceOf(type);
        }
        
        /**
         * Delegates to {@link Mockito#verify(java.lang.Object) }
         * 
         * @see Mockito#verify(java.lang.Object)
         */
        public static <T> T verify(T mock) {
            return Mockito.verify(mock);
        }
        
        /**
         * Delegates to {@link Mockito#verify(java.lang.Object, VerificationMode) }
         * 
         * @see Mockito#verify(java.lang.Object, VerificationMode)
         */
        public static <T> T verify(T mock, VerificationMode mode) {
            return Mockito.verify(mock, mode);
        }
        
        /**
         * Delegates to {@link Mockito#when(java.lang.Object) }
         * 
         * @see Mockito#when(java.lang.Object) 
         */
        public static <T> OngoingStubbing<T> when(T methodCall) {
            return Mockito.when(methodCall);
        }

        @Before
        public void initMocks() {
            MockitoAnnotations.initMocks(this);
        }
    }
}<commit_msg>Seed.Test interface changed to expect-style<commit_after>package com.github.nyrkovalex.seed.test;

import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Before;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;


@SuppressWarnings("UnusedDeclaration")
public final class Seed {
    // This class is factored out to standalone module to be used as a dependency with `test` scope

    private Seed() {
    }

    /**
     * This class is used as a base for all unit tests
     */
    public static abstract class Test {

        /**
         * Expect something to satisfy condition provided to {@link Expectation}
         *
         * @param <T> type of an object under test
         * @param actual actual value
         * @return expectation object containing check methods
         */
        public static <T> Expectation<T> expect(T actual) {
            return new Expectation<>(actual);
        }

        @Before
        public void initMocks() {
            MockitoAnnotations.initMocks(this);
        }
    }

    /**
     * This class contains various check methods used in unit testing
     *
     * @param <T>
     */
    public static class Expectation<T> {
        private final T actual;

        private Expectation(T actual) {
            this.actual = actual;
        }

        /**
         * Checks an equality of an actual item provided earlier and expected argument
         *
         * @param expected expected value
         */
        public void toBe(T expected) {
            Assert.assertThat(actual, CoreMatchers.is(expected));
        }

        /**
         * Checks that mock had calls to a specific method
         *
         * @return mock object itself
         */
        public T toHaveCall() {
            return Mockito.verify(actual);
        }

        /**
         * Checks that mock had some number of calls to a specific method
         *
         * @param times times a method is expected to be called
         * @return mock object itself
         */
        public T toHaveCalls(int times) {
            return Mockito.verify(actual, Mockito.times(times));
        }
    }
}
{'fraction_non_alphanumeric': 0.10116731517509728, 'fraction_numerical': 0.0, 'mean_word_length': 1.9859632139399805, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '6612878', 'n_tokens_mistral': 1751, 'n_tokens_neox': 1725, 'n_words': 449}