<commit_before>package ru.yandex.qatools.allure.testng;

import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.testng.annotations.*;
import ru.yandex.qatools.allure.Allure;
import ru.yandex.qatools.allure.events.*;

import java.lang.annotation.Annotation;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.mockito.Mockito.*;

/**
 * @author <NAME> <EMAIL>
 *         Date: 02.02.14
 */
public class InternalAllureTestListenerTest {

    private InternalAllureTestListener internalListener;
    private Allure allure;

    @BeforeMethod
    public void setUp() {
        internalListener = new InternalAllureTestListener("suite");
        allure = mock(Allure.class);

        internalListener.setLifecycle(allure);
    }

    @Test
    public void skipTestFireTestCaseStartedEvent() {
        AllureTestResultAdaptor testResult = mock(AllureTestResultAdaptor.class);
        when(testResult.getName()).thenReturn("test");
        when(testResult.getAnnotations()).thenReturn(new Annotation[0]);

        internalListener.onTestSkipped(testResult);

        verify(allure).fire(isA(TestCaseStartedEvent.class));
    }

    @Test
    public void skipTestFiredSkippedEventWithThrowable() {
        AllureTestResultAdaptor testResult = mock(AllureTestResultAdaptor.class);
        when(testResult.getThrowable()).thenReturn(new NullPointerException());
        when(testResult.getName()).thenReturn("test");
        when(testResult.getAnnotations()).thenReturn(new Annotation[0]);

        internalListener.onTestSkipped(testResult);

        ArgumentCaptor<TestCaseEvent> firedEvent = ArgumentCaptor.forClass(TestCaseEvent.class);
        verify(allure).fire(firedEvent.capture());

        assertThat(firedEvent.getValue(), instanceOf(TestCaseSkippedEvent.class));
        TestCaseSkippedEvent skippedEvent = (TestCaseSkippedEvent)firedEvent.getValue();
        assertThat(skippedEvent.getThrowable(), instanceOf(NullPointerException.class));
    }

    @Test
    public void skipTestFiredEventsOrder() {
        AllureTestResultAdaptor testResult = mock(AllureTestResultAdaptor.class);
        when(testResult.getThrowable()).thenReturn(new NullPointerException());
        when(testResult.getName()).thenReturn("test");
        when(testResult.getAnnotations()).thenReturn(new Annotation[0]);

        internalListener.onTestSkipped(testResult);

        InOrder inOrder = inOrder(allure);
        inOrder.verify(allure).fire(isA(TestCaseStartedEvent.class));
        inOrder.verify(allure).fire(isA(TestCaseSkippedEvent.class));
        inOrder.verify(allure).fire(isA(TestCaseFinishedEvent.class));
    }
}<commit_msg>Use eq() matcher for mockito verify<commit_after>package ru.yandex.qatools.allure.testng;

import org.mockito.InOrder;
import org.testng.annotations.*;
import ru.yandex.qatools.allure.Allure;
import ru.yandex.qatools.allure.events.*;

import java.lang.annotation.Annotation;

import static org.mockito.Mockito.*;

/**
 * @author <NAME> <EMAIL>
 *         Date: 02.02.14
 */
public class InternalAllureTestListenerTest {

    private static final String DEFAULT_SUITE_NAME = "suite";
    private static final String DEFAULT_TEST_NAME = "test";

    private InternalAllureTestListener internalListener;
    private Allure allure;

    @BeforeMethod
    public void setUp() {
        internalListener = new InternalAllureTestListener(DEFAULT_SUITE_NAME);
        allure = mock(Allure.class);

        internalListener.setLifecycle(allure);
    }

    @Test
    public void skipTestFireTestCaseStartedEvent() {
        AllureTestResultAdaptor testResult = mock(AllureTestResultAdaptor.class);
        when(testResult.getName()).thenReturn(DEFAULT_TEST_NAME);
        when(testResult.getAnnotations()).thenReturn(new Annotation[0]);

        internalListener.onTestSkipped(testResult);

        verify(allure).fire(eq(new TestCaseStartedEvent(DEFAULT_SUITE_NAME, DEFAULT_TEST_NAME)));
    }

    @Test
    public void skipTestFiredSkippedEventWithThrowable() {
        AllureTestResultAdaptor testResult = mock(AllureTestResultAdaptor.class);
        Throwable throwable = new NullPointerException();
        when(testResult.getThrowable()).thenReturn(throwable);
        when(testResult.getName()).thenReturn("test");
        when(testResult.getAnnotations()).thenReturn(new Annotation[0]);

        internalListener.onTestSkipped(testResult);

        verify(allure).fire(eq(new TestCaseSkippedEvent().withThrowable(throwable)));
    }

    @Test
    public void skipTestFiredEventsOrder() {
        AllureTestResultAdaptor testResult = mock(AllureTestResultAdaptor.class);
        when(testResult.getThrowable()).thenReturn(new NullPointerException());
        when(testResult.getName()).thenReturn(DEFAULT_TEST_NAME);
        when(testResult.getAnnotations()).thenReturn(new Annotation[0]);

        internalListener.onTestSkipped(testResult);

        InOrder inOrder = inOrder(allure);
        inOrder.verify(allure).fire(isA(TestCaseStartedEvent.class));
        inOrder.verify(allure).fire(isA(TestCaseSkippedEvent.class));
        inOrder.verify(allure).fire(isA(TestCaseFinishedEvent.class));
    }
}
{'fraction_non_alphanumeric': 0.11006891271056661, 'fraction_numerical': 0.003445635528330781, 'mean_word_length': 4.320773930753564, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '5533823', 'n_tokens_mistral': 1531, 'n_tokens_neox': 1506, 'n_words': 209}