<commit_before>package com.github.ferstl.maven.pomenforcers;

import java.nio.file.Paths;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.junit.Test;
import org.w3c.dom.Document;
import com.github.ferstl.maven.pomenforcers.model.ProjectModel;
import com.github.ferstl.maven.pomenforcers.util.XmlUtils;

import static org.mockito.Mockito.mock;

public class PedanticDependencyElementEnforcerTest {

  @Test
  public void test() {
    PedanticDependencyElementEnforcer enforcer = new PedanticDependencyElementEnforcer();
    Document document = XmlUtils.parseXml(Paths.get("src/test/projects/example-project/module1/pom.xml").toFile());

    enforcer.initialize(mock(EnforcerRuleHelper.class), document, new ProjectModel());
    ErrorReport report = new ErrorReport(PedanticEnforcerRule.DEPENDENCY_ELEMENT);
    enforcer.doEnforce(report);

    System.out.println(report);
  }
}<commit_msg>#19 Improve test<commit_after>package com.github.ferstl.maven.pomenforcers;

import java.nio.file.Path;
import java.nio.file.Paths;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
import com.github.ferstl.maven.pomenforcers.model.ProjectModel;
import com.github.ferstl.maven.pomenforcers.util.XmlUtils;

import static com.github.ferstl.maven.pomenforcers.ErrorReportMatcher.hasErrors;
import static com.github.ferstl.maven.pomenforcers.ErrorReportMatcher.hasNoErrors;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;

public class PedanticDependencyElementEnforcerTest {

  private ErrorReport errorReport;

  @Before
  public void before() {
    this.errorReport = new ErrorReport(PedanticEnforcerRule.DEPENDENCY_ELEMENT);
  }

  @Test
  public void defaultOrdering() {
    // arrange
    Path pomFile = Paths.get("src/test/projects/example-project/module1/pom.xml");
    PedanticDependencyElementEnforcer enforcer = createEnforcer(pomFile);

    // act
    enforcer.doEnforce(this.errorReport);

    // assert
    assertThat(this.errorReport, hasNoErrors());
  }

  @Test
  public void customOrdering() {
    // arrange
    Path pomFile = Paths.get("src/test/projects/example-project/module1/pom.xml");
    PedanticDependencyElementEnforcer enforcer = createEnforcer(pomFile);

    enforcer.setElementPriorities("artifactId,groupId");

    // act
    enforcer.doEnforce(this.errorReport);

    // assert
    assertThat(this.errorReport, hasErrors());
  }

  private PedanticDependencyElementEnforcer createEnforcer(Path pomFile) {
    Document document = XmlUtils.parseXml(pomFile.toFile());
    PedanticDependencyElementEnforcer enforcer = new PedanticDependencyElementEnforcer();

    enforcer.initialize(mock(EnforcerRuleHelper.class), document, new ProjectModel());
    return enforcer;
  }


}
{'fraction_non_alphanumeric': 0.10606060606060606, 'fraction_numerical': 0.0024665257223396757, 'mean_word_length': 5.118534482758621, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, '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': '5532651', 'n_tokens_mistral': 934, 'n_tokens_neox': 899, 'n_words': 136}