package com.atlassian.bitbucket.web.conditions;

import com.atlassian.bitbucket.i18n.KeyedMessage;
import com.atlassian.bitbucket.license.LicenseService;
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 HasLicenseStatusConditionTest {

    @Mock
    private LicenseService licenseService;
    @InjectMocks
    private HasLicenseStatusCondition condition;

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

    @Test
    public void testHasLicenseStatus() throws Exception {
        when(licenseService.getStatus()).thenReturn(new KeyedMessage("k", "l", "r"));
        assertTrue(condition.shouldDisplay(Collections.<String, Object>emptyMap()));
    }
}

