<commit_before>package org.javers.core.examples;

import org.javers.core.Changes;
import org.javers.core.Javers;
import org.javers.core.JaversBuilder;
import org.javers.core.changelog.SimpleTextChangeLog;
import org.javers.core.diff.Change;
import org.javers.core.examples.model.Employee;
import org.javers.repository.jql.QueryBuilder;
import org.junit.Test;
import java.util.List;

public class ChangeLogExample {

    @Test
    public void changesPrintingExampleWithGrouping() {
        // given
        Javers javers = JaversBuilder.javers().build();

        Employee sam = new Employee("Sam", 1_000);
        Employee frodo = new Employee("Frodo", 10_000);
        javers.commit("author", frodo);

        frodo.addSubordinate(sam);
        frodo.setSalary(11_000);
        sam.setSalary(2_000);
        javers.commit("author", frodo);

        // when
        Changes changes = javers.findChanges(QueryBuilder.byClass(Employee.class)
                .withNewObjectChanges().build());

        //then
        System.out.println("Printing the flat list of Changes :");
        changes.forEach(change -> System.out.println("- " + change));

        System.out.println("Printing Changes with grouping by commit and by object :");
        changes.groupByCommit().forEach(byCommit -> {
            System.out.println("commit " + byCommit.getCommit().getId());
            byCommit.groupByObject().forEach(byObject -> {
                System.out.println("  changes on " + byObject.getGlobalId().value() + " : ");
                byObject.get().forEach(change -> {
                    System.out.println("  - " + change);
                });
            });
        });
    }

    @Test<commit_msg>ChangeLogExample<commit_after>package org.javers.core.examples;

import org.javers.core.Changes;
import org.javers.core.Javers;
import org.javers.core.JaversBuilder;
import org.javers.core.changelog.SimpleTextChangeLog;
import org.javers.core.diff.Change;
import org.javers.core.examples.model.Employee;
import org.javers.repository.jql.QueryBuilder;
import org.junit.Test;
import java.util.List;

public class ChangeLogExample {

    @Test
    public void changesPrintingExampleWithGrouping() {
        // given
        Javers javers = JaversBuilder.javers().build();

        Employee sam = new Employee("Sam", 1_000);
        Employee frodo = new Employee("Frodo", 10_000);
        javers.commit("author", frodo);

        frodo.addSubordinate(sam);
        frodo.setSalary(11_000);
        sam.setSalary(2_000);
        javers.commit("author", frodo);

        // when
        Changes changes = javers.findChanges(QueryBuilder.byClass(Employee.class)
                .withNewObjectChanges().build());

        //then
        System.out.println("Printing the flat list of Changes :");
        changes.forEach(change -> System.out.println("- " + change));

        //then
        System.out.println("Changes prettyPrint :");
        System.out.println(changes.prettyPrint());

        System.out.println("Printing Changes with grouping by commits and by objects :");
        changes.groupByCommit().forEach(byCommit -> {
            System.out.println("commit " + byCommit.getCommit().getId());
            byCommit.groupByObject().forEach(byObject -> {
                System.out.println("  changes on " + byObject.getGlobalId().value() + " : ");
                byObject.get().forEach(change -> {
                    System.out.println("  - " + change);
                });
            });
        });
    }

    @Test
{'fraction_non_alphanumeric': 0.13356067064506963, 'fraction_numerical': 0.010230179028132993, 'mean_word_length': 2.527054108216433, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '420146', 'n_tokens_mistral': 1064, 'n_tokens_neox': 1002, 'n_words': 171}