<commit_before>/*
 * This code is free software; you can redistribute it and/or modify it under
 * the terms of the new BSD License.
 *
 * Copyright (c) 2011-2017, <NAME>
 */

package com.github.koraktor.mavanagaiata.mojo;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.TimeZone;

import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

import com.github.koraktor.mavanagaiata.git.GitCommit;
import com.github.koraktor.mavanagaiata.git.GitTag;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class ChangelogMojoTest extends GitOutputMojoAbstractTest<ChangelogMojo> {

    private List<GitCommit> mockCommits;

    private static GitCommit mockCommit(String id, String message) {
        GitCommit commit = mock(GitCommit.class);
        when(commit.getId()).thenReturn(id);
        when(commit.getMessage()).thenReturn(message);
        when(commit.getMessageSubject()).thenReturn(message.split("\\n\\n")[0]);
        return commit;
    }

    @Before
    @Override
    public void setup() throws Exception {
        super.setup();

        this.mojo.branchFormat = "Commits on branch \"master\"\\n";
        this.mojo.commitPrefix = " * ";
        this.mojo.gitHubBranchLinkFormat = "\\nSee Git history for changes in the \"%s\" branch since version %s at: %s";
        this.mojo.gitHubBranchOnlyLinkFormat = "\\nSee Git history for changes in the \"%s\" branch at: %s";
        this.mojo.gitHubTagLinkFormat = "\\nSee Git history for version %s at: %s";
        this.mojo.header       = "Changelog\\n=========\\n";
        this.mojo.skipTagged   = false;
        this.mojo.tagFormat    = "\\nVersion %s – %s\\n";
        this.mojo.skipCommitsMatching  = null;

        this.mockCommits = new ArrayList<>();
        this.mockCommits.add(mockCommit("598a75596868dec45f8e6a808a07d533bc0184f0", "8th commit"));
        this.mockCommits.add(mockCommit("6727d8c671ce9022047940ebb6568096b4362f90", "7th commit"));
        this.mockCommits.add(mockCommit("06cee865ab7f006a58be39f1d46f01dcb1880105", "6th commit"));
        this.mockCommits.add(mockCommit("99982df241980fdeebbb01216b5e80286163c62e", "5th commit"));
        this.mockCommits.add(mockCommit("afb48c6be4278ba7f5e4197b80adbbb80c6df3a7", "4th commit\n\n[ci skip]"));
        this.mockCommits.add(mockCommit("5979a86e9bb091fc792529bee68ed222000ebc7e", "3rd commit"));
        this.mockCommits.add(mockCommit("b3b28176c1a05b76fb9231abe2f2cbbf15a86118", "2nd commit"));
        this.mockCommits.add(mockCommit("e82314841e1d990eeb33878cae55dadc8a11bf68", "1st commit"));

        HashMap<String, GitTag> tags = new HashMap<>();
        GitTag tag1 = mock(GitTag.class);
        when(tag1.getDate()).thenReturn(new Date(1162580880000L));
        when(tag1.getName()).thenReturn("1.0.0");
        when(tag1.getTimeZone()).thenReturn(TimeZone.getTimeZone("GMT"));
        tags.put("5979a86e9bb091fc792529bee68ed222000ebc7e", tag1);
        GitTag tag2 = mock(GitTag.class);
        when(tag2.getDate()).thenReturn(new Date(1275131880000L));
        when(tag2.getName()).thenReturn("2.0.0");<commit_msg>Make ChangelogMojoTest locale neutral<commit_after>/*
 * This code is free software; you can redistribute it and/or modify it under
 * the terms of the new BSD License.
 *
 * Copyright (c) 2011-2017, <NAME>
 */

package com.github.koraktor.mavanagaiata.mojo;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.TimeZone;

import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

import com.github.koraktor.mavanagaiata.git.GitCommit;
import com.github.koraktor.mavanagaiata.git.GitTag;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class ChangelogMojoTest extends GitOutputMojoAbstractTest<ChangelogMojo> {

    private List<GitCommit> mockCommits;

    private static GitCommit mockCommit(String id, String message) {
        GitCommit commit = mock(GitCommit.class);
        when(commit.getId()).thenReturn(id);
        when(commit.getMessage()).thenReturn(message);
        when(commit.getMessageSubject()).thenReturn(message.split("\\n\\n")[0]);
        return commit;
    }

    @Before
    @Override
    public void setup() throws Exception {
        super.setup();

        Locale.setDefault(Locale.ENGLISH);

        this.mojo.branchFormat = "Commits on branch \"master\"\\n";
        this.mojo.commitPrefix = " * ";
        this.mojo.gitHubBranchLinkFormat = "\\nSee Git history for changes in the \"%s\" branch since version %s at: %s";
        this.mojo.gitHubBranchOnlyLinkFormat = "\\nSee Git history for changes in the \"%s\" branch at: %s";
        this.mojo.gitHubTagLinkFormat = "\\nSee Git history for version %s at: %s";
        this.mojo.header       = "Changelog\\n=========\\n";
        this.mojo.skipTagged   = false;
        this.mojo.tagFormat    = "\\nVersion %s – %s\\n";
        this.mojo.skipCommitsMatching  = null;

        this.mockCommits = new ArrayList<>();
        this.mockCommits.add(mockCommit("598a75596868dec45f8e6a808a07d533bc0184f0", "8th commit"));
        this.mockCommits.add(mockCommit("6727d8c671ce9022047940ebb6568096b4362f90", "7th commit"));
        this.mockCommits.add(mockCommit("06cee865ab7f006a58be39f1d46f01dcb1880105", "6th commit"));
        this.mockCommits.add(mockCommit("99982df241980fdeebbb01216b5e80286163c62e", "5th commit"));
        this.mockCommits.add(mockCommit("afb48c6be4278ba7f5e4197b80adbbb80c6df3a7", "4th commit\n\n[ci skip]"));
        this.mockCommits.add(mockCommit("5979a86e9bb091fc792529bee68ed222000ebc7e", "3rd commit"));
        this.mockCommits.add(mockCommit("b3b28176c1a05b76fb9231abe2f2cbbf15a86118", "2nd commit"));
        this.mockCommits.add(mockCommit("e82314841e1d990eeb33878cae55dadc8a11bf68", "1st commit"));

        HashMap<String, GitTag> tags = new HashMap<>();
        GitTag tag1 = mock(GitTag.class);
        when(tag1.getDate()).thenReturn(new Date(1162580880000L));
        when(tag1.getName()).thenReturn("1.0.0");
        when(tag1.getTimeZone()).thenReturn(TimeZone.getTimeZone("GMT"));
        tags.put("5979a86e9bb091fc792529bee68ed222000ebc7e", tag1);
        GitTag tag2 = mock(GitTag.class);
        when(tag2.getDate()).thenReturn(new Date(1275131880000L));
        when(tag2.getName()).thenReturn("2.0.0");
{'fraction_non_alphanumeric': 0.13114988558352403, 'fraction_numerical': 0.08180778032036613, 'mean_word_length': 3.9666193181818183, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '3958766', 'n_tokens_mistral': 2710, 'n_tokens_neox': 2441, 'n_words': 407}