<commit_before>package name.abuchen.portfolio.snapshot;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import java.time.LocalDate;

import org.junit.Test;

public class AggregationTest
{
    @Test
    public void testWeekly()
    {
        assertThat(Aggregation.Period.WEEKLY.getStartDateFor(LocalDate.of(2011, 10, 17)), //
                        is(LocalDate.of(2011, 10, 17)));
        assertThat(Aggregation.Period.WEEKLY.getStartDateFor(LocalDate.of(2012, 1, 13)), //
                        is(LocalDate.of(2012, 1, 9)));
        assertThat(Aggregation.Period.WEEKLY.getStartDateFor(LocalDate.of(2012, 8, 10)), //
                        is(LocalDate.of(2012, 8, 6)));
        assertThat(Aggregation.Period.WEEKLY.getStartDateFor(LocalDate.of(2012, 9, 23)), //
                        is(LocalDate.of(2012, 9, 17)));
    }

    @Test
    public void testMonthly()
    {
        assertThat(Aggregation.Period.MONTHLY.getStartDateFor(LocalDate.of(2011, 10, 17)), //
                        is(LocalDate.of(2011, 10, 1)));
        assertThat(Aggregation.Period.MONTHLY.getStartDateFor(LocalDate.of(2012, 1, 13)), //
                        is(LocalDate.of(2012, 1, 1)));
        assertThat(Aggregation.Period.MONTHLY.getStartDateFor(LocalDate.of(2012, 8, 10)), //
                        is(LocalDate.of(2012, 8, 1)));
        assertThat(Aggregation.Period.MONTHLY.getStartDateFor(LocalDate.of(2012, 9, 23)), //
                        is(LocalDate.of(2012, 9, 1)));
    }

    @Test
    public void testQuartlerly()
    {
        assertThat(Aggregation.Period.QUARTERLY.getStartDateFor(LocalDate.of(2011, 10, 17)), //
                        is(LocalDate.of(2011, 10, 1)));
        assertThat(Aggregation.Period.QUARTERLY.getStartDateFor(LocalDate.of(2012, 1, 13)), //
                        is(LocalDate.of(2012, 1, 1)));
        assertThat(Aggregation.Period.QUARTERLY.getStartDateFor(LocalDate.of(2012, 8, 10)), //
                        is(LocalDate.of(2012, 7, 1)));
        assertThat(Aggregation.Period.QUARTERLY.getStartDateFor(LocalDate.of(2012, 9, 23)), //
                        is(LocalDate.of(2012, 7, 1)));
    }

    @Test
    public void testYearly()
    {
        assertThat(Aggregation.Period.YEARLY.getStartDateFor(LocalDate.of(2011, 10, 17)), //
                        is(LocalDate.of(2011, 1, 1)));
        assertThat(Aggregation.Period.YEARLY.getStartDateFor(LocalDate.of(2012, 1, 13)), //
                        is(LocalDate.of(2012, 1, 1)));
        assertThat(Aggregation.Period.YEARLY.getStartDateFor(LocalDate.of(2012, 8, 10)), //
                        is(LocalDate.of(2012, 1, 1)));
        assertThat(Aggregation.Period.YEARLY.getStartDateFor(LocalDate.of(2012, 9, 23)), //
                        is(LocalDate.of(2012, 1, 1)));
    }

}
<commit_msg>Fixed locale dependent test checking for first day in week<commit_after>package name.abuchen.portfolio.snapshot;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import java.time.LocalDate;
import java.util.Locale;

import org.junit.Test;

public class AggregationTest
{
    @Test
    public void testWeekly()
    {
        // first day of week is locale dependent
        Locale locale = Locale.getDefault();
        Locale.setDefault(Locale.GERMAN);

        try
        {
            assertThat(Aggregation.Period.WEEKLY.getStartDateFor(LocalDate.of(2011, 10, 17)), //
                            is(LocalDate.of(2011, 10, 17)));
            assertThat(Aggregation.Period.WEEKLY.getStartDateFor(LocalDate.of(2012, 1, 13)), //
                            is(LocalDate.of(2012, 1, 9)));
            assertThat(Aggregation.Period.WEEKLY.getStartDateFor(LocalDate.of(2012, 8, 10)), //
                            is(LocalDate.of(2012, 8, 6)));
            assertThat(Aggregation.Period.WEEKLY.getStartDateFor(LocalDate.of(2012, 9, 23)), //
                            is(LocalDate.of(2012, 9, 17)));
        }
        finally
        {
            Locale.setDefault(locale);
        }
    }

    @Test
    public void testMonthly()
    {
        assertThat(Aggregation.Period.MONTHLY.getStartDateFor(LocalDate.of(2011, 10, 17)), //
                        is(LocalDate.of(2011, 10, 1)));
        assertThat(Aggregation.Period.MONTHLY.getStartDateFor(LocalDate.of(2012, 1, 13)), //
                        is(LocalDate.of(2012, 1, 1)));
        assertThat(Aggregation.Period.MONTHLY.getStartDateFor(LocalDate.of(2012, 8, 10)), //
                        is(LocalDate.of(2012, 8, 1)));
        assertThat(Aggregation.Period.MONTHLY.getStartDateFor(LocalDate.of(2012, 9, 23)), //
                        is(LocalDate.of(2012, 9, 1)));
    }

    @Test
    public void testQuartlerly()
    {
        assertThat(Aggregation.Period.QUARTERLY.getStartDateFor(LocalDate.of(2011, 10, 17)), //
                        is(LocalDate.of(2011, 10, 1)));
        assertThat(Aggregation.Period.QUARTERLY.getStartDateFor(LocalDate.of(2012, 1, 13)), //
                        is(LocalDate.of(2012, 1, 1)));
        assertThat(Aggregation.Period.QUARTERLY.getStartDateFor(LocalDate.of(2012, 8, 10)), //
                        is(LocalDate.of(2012, 7, 1)));
        assertThat(Aggregation.Period.QUARTERLY.getStartDateFor(LocalDate.of(2012, 9, 23)), //
                        is(LocalDate.of(2012, 7, 1)));
    }

    @Test
    public void testYearly()
    {
        assertThat(Aggregation.Period.YEARLY.getStartDateFor(LocalDate.of(2011, 10, 17)), //
                        is(LocalDate.of(2011, 1, 1)));
        assertThat(Aggregation.Period.YEARLY.getStartDateFor(LocalDate.of(2012, 1, 13)), //
                        is(LocalDate.of(2012, 1, 1)));
        assertThat(Aggregation.Period.YEARLY.getStartDateFor(LocalDate.of(2012, 8, 10)), //
                        is(LocalDate.of(2012, 1, 1)));
        assertThat(Aggregation.Period.YEARLY.getStartDateFor(LocalDate.of(2012, 9, 23)), //
                        is(LocalDate.of(2012, 1, 1)));
    }

}

{'fraction_non_alphanumeric': 0.14055222887558216, 'fraction_numerical': 0.07218895542248836, 'mean_word_length': 2.196703880914407, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1797401', 'n_tokens_mistral': 2255, 'n_tokens_neox': 1872, 'n_words': 279}