<commit_before>package org.mockito.internal.util;

import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.mockito.exceptions.misusing.NotAMockException;
import org.mockito.internal.invocation.Stubbing;
import org.mockitousage.IMethods;

import java.util.Collection;

import static junit.framework.TestCase.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mockingDetails;
import static org.mockito.Mockito.when;

@SuppressWarnings("unchecked")
public class DefaultMockingDetailsTest {

    @Mock private Foo foo;
    @Mock private Bar bar;
    @Mock private IMethods mock;
    @Spy private Gork gork;

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

    @Test
    public void should_check_that_a_mock_is_indeed_a_mock() throws Exception {
        assertEquals(true, mockingDetails(foo).isMock());
        assertEquals(true, mockingDetails(bar).isMock());
        assertEquals(true, mockingDetails(gork).isMock());
        assertEquals(false, mockingDetails("no a mock").isMock());
    }

    @Test
    public void should_check_that_a_spy_is_indeed_a_spy() throws Exception {
        assertEquals(true, mockingDetails(gork).isSpy());
        assertEquals(false, mockingDetails(foo).isSpy());
        assertEquals(false, mockingDetails(bar).isSpy());
        assertEquals(false, mockingDetails("not a spy").isSpy());
    }

    @Test
    public void should_check_that_a_spy_is_also_a_mock() throws Exception {
        assertEquals(true, mockingDetails(gork).isMock());
    }

    @Test
    public void provides_invocations() {
        //when
        mock.simpleMethod(10);
        mock.otherMethod();

        //then
        assertEquals(0, mockingDetails(foo).getInvocations().size());
        assertEquals("[mock.simpleMethod(10);, mock.otherMethod();]", mockingDetails(mock).getInvocations().toString());
    }

    @Test
    public void provides_mock_creation_settings() {
        //smoke test some creation settings
        assertEquals(Foo.class, mockingDetails(foo).getMockCreationSettings().getTypeToMock());
        assertEquals(Bar.class, mockingDetails(bar).getMockCreationSettings().getTypeToMock());
        assertEquals(0, mockingDetails(mock).getMockCreationSettings().getExtraInterfaces().size());
    }

    @Test(expected = NotAMockException.class)<commit_msg>Added test that covers existing functionality<commit_after>package org.mockito.internal.util;

import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.mockito.exceptions.misusing.NotAMockException;
import org.mockito.internal.invocation.Stubbing;
import org.mockitousage.IMethods;

import java.util.Collection;

import static junit.framework.TestCase.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mockingDetails;
import static org.mockito.Mockito.when;

@SuppressWarnings("unchecked")
public class DefaultMockingDetailsTest {

    @Mock private Foo foo;
    @Mock private Bar bar;
    @Mock private IMethods mock;
    @Spy private Gork gork;

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

    @Test
    public void should_check_that_a_mock_is_indeed_a_mock() throws Exception {
        assertEquals(true, mockingDetails(foo).isMock());
        assertEquals(true, mockingDetails(bar).isMock());
        assertEquals(true, mockingDetails(gork).isMock());
        assertEquals(false, mockingDetails("no a mock").isMock());
    }

    @Test
    public void should_check_that_a_spy_is_indeed_a_spy() throws Exception {
        assertEquals(true, mockingDetails(gork).isSpy());
        assertEquals(false, mockingDetails(foo).isSpy());
        assertEquals(false, mockingDetails(bar).isSpy());
        assertEquals(false, mockingDetails("not a spy").isSpy());
    }

    @Test
    public void should_check_that_a_spy_is_also_a_mock() throws Exception {
        assertEquals(true, mockingDetails(gork).isMock());
    }

    @Test
    public void provides_invocations() {
        //when
        mock.simpleMethod(10);
        mock.otherMethod();

        //then
        assertEquals(0, mockingDetails(foo).getInvocations().size());
        assertEquals("[mock.simpleMethod(10);, mock.otherMethod();]", mockingDetails(mock).getInvocations().toString());
    }

    @Test
    public void manipulating_invocations_is_safe() {
        mock.simpleMethod();

        //when we manipulate the invocations
        mockingDetails(mock).getInvocations().clear();

        //then we didn't actually changed the invocations
        assertEquals(1, mockingDetails(mock).getInvocations().size());
    }

    @Test
    public void provides_mock_creation_settings() {
        //smoke test some creation settings
        assertEquals(Foo.class, mockingDetails(foo).getMockCreationSettings().getTypeToMock());
        assertEquals(Bar.class, mockingDetails(bar).getMockCreationSettings().getTypeToMock());
        assertEquals(0, mockingDetails(mock).getMockCreationSettings().getExtraInterfaces().size());
    }

    @Test(expected = NotAMockException.class)
{'fraction_non_alphanumeric': 0.11434395848776872, 'fraction_numerical': 0.0024091919940696814, 'mean_word_length': 4.110795454545454, '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': '3752093', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1512, 'n_words': 288}