package com.atlassian.bitbucket.internal.integration.jira.idx;

import com.atlassian.integration.jira.JiraService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import java.util.Collection;
import java.util.Collections;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class JiraCommitPropertyConfigurationTest {

    @InjectMocks
    private JiraCommitPropertyConfiguration configuration;
    @Mock
    private JiraService jiraService;

    @Test
    public void testGetAttributesToPreload() {
        when(jiraService.isLinked()).thenReturn(true, false);

        Collection<String> properties = configuration.getPropertiesToPreload(null);
        assertEquals(JiraCommitPropertyConfiguration.ISSUE_KEYS, properties);

        properties = configuration.getPropertiesToPreload(null);
        assertEquals(Collections.<String>emptySet(), properties);
    }
}
