package com.atlassian.stash.internal.comment.like.config;

import com.atlassian.bitbucket.server.ApplicationPropertiesService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static com.atlassian.bitbucket.mockito.MockitoUtils.returnArg;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.*;
import static org.mockito.Mockito.when;

// for code coverage
@RunWith(MockitoJUnitRunner.class)
public class DefaultCommentLikeConfigTest {

    @Mock
    private ApplicationPropertiesService propertiesService;

    @InjectMocks
    private DefaultCommentLikeConfig commentLikeConfig;

    @Before
    public void setUp() throws Exception {
        when(propertiesService.getPluginProperty(anyString(), anyInt())).thenAnswer(returnArg(1));
        when(propertiesService.getPluginProperty(anyString(), anyLong())).thenAnswer(returnArg(1));
    }

    @Test // the properties are within a sane range without checking the exact values
    public void testGetConfigProperties() throws Exception {
        assertThat(commentLikeConfig.getMaxPageSize(), both(greaterThanOrEqualTo(50)).and(lessThan(999)));
        assertThat(commentLikeConfig.getMaxResources(), both(greaterThanOrEqualTo(50)).and(lessThan(999)));
    }

}