package com.atlassian.stash.internal.pull;

import com.atlassian.bitbucket.AbstractServiceTest;
import com.atlassian.bitbucket.pull.PullRequestSupplier;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static org.junit.Assert.assertSame;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class DefaultPullRequestSupplierTest extends AbstractServiceTest {

    @Mock
    private InternalPullRequest pullRequest;
    @Mock
    private PullRequestDao pullRequestDao;
    @InjectMocks
    private DefaultPullRequestSupplier supplier;

    public DefaultPullRequestSupplierTest() {
        super(DefaultPullRequestSupplier.class, PullRequestSupplier.class);
    }

    @Test
    public void testGetById() {
        when(pullRequestDao.findByRepositoryScopedId(eq(1), eq(2L))).thenReturn(pullRequest);

        assertSame(pullRequest, supplier.getById(1, 2L));
    }
}