package com.atlassian.stash.internal.repository.sync.command;

import com.atlassian.bitbucket.project.Project;
import com.atlassian.bitbucket.repository.Repository;
import com.atlassian.bitbucket.scm.git.GitAgent;
import com.atlassian.bitbucket.scm.git.command.GitCommand;
import com.atlassian.bitbucket.user.ApplicationUser;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static org.mockito.Mockito.*;

/**
 * @since 2.6
 */
@RunWith(MockitoJUnitRunner.class)
public abstract class AbstractRefCommandTest {

    protected static final String MASTER = "refs/heads/master";

    @Mock
    protected GitAgent agent;
    @Mock
    protected GitCommand<Object> command;
    @Mock
    protected Repository repository;
    @Mock
    protected Repository upstream;
    @Mock
    protected ApplicationUser user;

    @Before
    public void setup() {
        Project project = mock(Project.class);
        when(project.getKey()).thenReturn("KEY");

        doThrow(IllegalStateException.class).when(repository).getOrigin(); //Nothing should assume origin is upstream
        when(repository.getProject()).thenReturn(project);
        when(repository.getSlug()).thenReturn("repository");
        when(upstream.getProject()).thenReturn(project);
        when(upstream.getSlug()).thenReturn("upstream");
        when(user.getDisplayName()).thenReturn("John Doe");
        when(user.getEmailAddress()).thenReturn("jdoe@test.com");
    }
}
