<commit_before>package lan.dk.podcastserver.controller.api;

import lan.dk.podcastserver.business.stats.StatsBusiness;
import lan.dk.podcastserver.utils.facade.stats.StatsPodcastType;
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.ArrayList;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.only;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

/**
 * Created by kevin on 21/09/15 for Podcast Server
 */
@RunWith(MockitoJUnitRunner.class)
public class StatsControllerTest {

    private @Mock StatsBusiness statsBusiness;
    private @InjectMocks StatsController statsController;

    @Test
    public void should_find_stats_for_all_podcast_by_download_date() {
        /* Given */
        Integer numberOfMonth = 6;
        List<StatsPodcastType> stats = new ArrayList<>();
        when(statsBusiness.allStatsByTypeAndDownloadDate(eq(6))).thenReturn(stats);

        /* When */
        List<StatsPodcastType> statsByDownloadDate = statsController.byDownloadDate(numberOfMonth);

        /* Then */
        assertThat(stats).isSameAs(statsByDownloadDate);
        verify(statsBusiness, only()).allStatsByTypeAndDownloadDate(eq(numberOfMonth));
    }

    @Test
    public void should_find_stats_for_all_podcast_by_creation_date() {
        /* Given */
        Integer numberOfMonth = 6;
        List<StatsPodcastType> stats = new ArrayList<>();
        when(statsBusiness.allStatsByTypeAndCreationDate(6)).thenReturn(stats);

        /* When */
        List<StatsPodcastType> statsByCreationDate = statsController.byCreationDate(numberOfMonth);

        /* Then */
        assertThat(stats).isSameAs(statsByCreationDate);
        verify(statsBusiness, only()).allStatsByTypeAndCreationDate(eq(numberOfMonth));
    }



}<commit_msg>test(stats): expand testing on controller<commit_after>package lan.dk.podcastserver.controller.api;

import lan.dk.podcastserver.business.stats.StatsBusiness;
import lan.dk.podcastserver.utils.facade.stats.StatsPodcastType;
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.ArrayList;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.only;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

/**
 * Created by kevin on 21/09/15 for Podcast Server
 */
@RunWith(MockitoJUnitRunner.class)
public class StatsControllerTest {

    private @Mock StatsBusiness statsBusiness;
    private @InjectMocks StatsController statsController;

    @Test
    public void should_find_stats_for_all_podcast_by_download_date() {
        /* Given */
        Integer numberOfMonth = 6;
        List<StatsPodcastType> stats = new ArrayList<>();
        when(statsBusiness.allStatsByTypeAndDownloadDate(eq(6))).thenReturn(stats);

        /* When */
        List<StatsPodcastType> statsByDownloadDate = statsController.byDownloadDate(numberOfMonth);

        /* Then */
        assertThat(stats).isSameAs(statsByDownloadDate);
        verify(statsBusiness, only()).allStatsByTypeAndDownloadDate(eq(numberOfMonth));
    }

    @Test
    public void should_find_stats_for_all_podcast_by_creation_date() {
        /* Given */
        Integer numberOfMonth = 6;
        List<StatsPodcastType> stats = new ArrayList<>();
        when(statsBusiness.allStatsByTypeAndCreationDate(6)).thenReturn(stats);

        /* When */
        List<StatsPodcastType> statsByCreationDate = statsController.byCreationDate(numberOfMonth);

        /* Then */
        assertThat(stats).isSameAs(statsByCreationDate);
        verify(statsBusiness, only()).allStatsByTypeAndCreationDate(eq(numberOfMonth));
    }

    @Test
    public void should_find_stats_for_all_podcast_by_publication_date() {
        /* Given */
        Integer numberOfMonth = 6;
        List<StatsPodcastType> stats = new ArrayList<>();
        when(statsBusiness.allStatsByTypeAndPubDate(6)).thenReturn(stats);

        /* When */
        List<StatsPodcastType> statsByCreationDate = statsController.byPubDate(numberOfMonth);

        /* Then */
        assertThat(stats).isSameAs(statsByCreationDate);
        verify(statsBusiness, only()).allStatsByTypeAndPubDate(eq(numberOfMonth));
    }



}
{'fraction_non_alphanumeric': 0.10348583877995643, 'fraction_numerical': 0.004793028322440087, 'mean_word_length': 4.017486338797815, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4116092', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1330, 'n_words': 219}