package com.atlassian.bitbucket.web.conditions;

import com.atlassian.bitbucket.mail.MailService;
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.Collections;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class IsMailServerConfiguredConditionTest {

    @Mock
    private MailService mailService;

    @InjectMocks
    private IsMailServerConfiguredCondition condition;

    @Test
    public void testMailServerNotConfigured() throws Exception {
        assertFalse(condition.shouldDisplay(Collections.<String, Object>emptyMap()));
    }

    @Test
    public void testMailServerConfigured() throws Exception {
        when(mailService.isHostConfigured()).thenReturn(true);
        assertTrue(condition.shouldDisplay(Collections.<String, Object>emptyMap()));
    }
}
