// Path: src/main/java/com/github/ferstl/maven/pomenforcers/model/PomSection.java
// public enum PomSection {
//   MODEL_VERSION("modelVersion"),
//   PREREQUISITES("prerequisites"),
//   PARENT("parent"),
//   GROUP_ID("groupId"),
//   ARTIFACT_ID("artifactId"),
//   VERSION("version"),
//   PACKAGING("packaging"),
//   NAME("name"),
//   DESCRIPTION("description"),
//   URL("url"),
//   LICENSES("licenses"),
//   ORGANIZATION("organization"),
//   INCEPTION_YEAR("inceptionYear"),
//   CI_MANAGEMENT("ciManagement"),
//   MAILING_LISTS("mailingLists"),
//   ISSUE_MANAGEMENT("issueManagement"),
//   DEVELOPERS("developers"),
//   CONTRIBUTORS("contributors"),
//   SCM("scm"),
//   REPOSITORIES("repositories"),
//   PLUGIN_REPOSITORIES("pluginRepositories"),
//   DISTRIBUTION_MANAGEMENT("distributionManagement"),
//   MODULES("modules"),
//   PROPERTIES("properties"),
//   DEPENDENCY_MANAGEMENT("dependencyManagement"),
//   DEPENDENCIES("dependencies"),
//   BUILD("build"),
//   PROFILES("profiles"),
//   REPORTING("reporting"),
//   REPORTS("reports");
// 
//   private static final Map<String, PomSection> pomSectionMap;
// 
//   static {
//     pomSectionMap = Maps.newHashMap();
//     for (PomSection pomSection : values()) {
//       pomSectionMap.put(pomSection.getSectionName(), pomSection);
//     }
//   }
// 
//   public static PomSection getBySectionName(String sectionName) {
//     requireNonNull(sectionName, "Section name is null.");
// 
//     PomSection value = pomSectionMap.get(sectionName);
//     if (value == null) {
//       throw new IllegalArgumentException("POM section " + sectionName + " does not exist.");
//     }
// 
//     return value;
//   }
// 
//   private final String sectionName;
// 
//   PomSection(String sectionName) {
//     this.sectionName = sectionName;
//   }
// 
//   public String getSectionName() {
//     return this.sectionName;
//   }
// }
// 
// Path: src/main/java/com/github/ferstl/maven/pomenforcers/util/SideBySideDiffUtil.java
// public static String diff(Collection<String> actual, Collection<String> required, String leftTitle, String rightTitle) {
// 
//   SideBySideContext context = new SideBySideContext(actual, required, leftTitle, rightTitle);
//   int offset = 0;
// 
//   for (Delta<String> delta : context.deltas) {
//     Chunk<String> original = delta.getOriginal();
//     Chunk<String> revised = delta.getRevised();
//     int currentPosition = original.getPosition() + offset;
// 
//     switch (delta.getType()) {
//       case INSERT:
//         offset += context.expand(currentPosition, revised.size());
//         context.setRightContent(currentPosition, revised.getLines());
//         break;
// 
//       case CHANGE:
//         int difference = revised.size() - original.size();
//         if (difference > 0) {
//           offset += context.expand(currentPosition + original.size(), difference);
//         } else {
//           context.clearRightContent(currentPosition + revised.size(), Math.abs(difference));
//         }
// 
//         context.setLeftContent(currentPosition, original.getLines());
//         context.setRightContent(currentPosition, revised.getLines());
//         break;
// 
//       case DELETE:
//         context.setLeftContent(currentPosition, original.getLines());
//         context.clearRightContent(currentPosition, original.size());
//         break;
// 
//       default:
//         throw new IllegalStateException("Unsupported delta type: " + delta.getType());
// 
//     }
//   }
// 
//   return context.toString();
// }


import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeDiagnosingMatcher;
import org.junit.Test;
import com.github.ferstl.maven.pomenforcers.model.PomSection;
import com.google.common.collect.Ordering;
import static com.github.ferstl.maven.pomenforcers.util.SideBySideDiffUtil.diff;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.junit.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
  @Test
  public void differentLengthsShortOriginal() {
    String diff = diff(singletonList("abc"), asList("def", "ghi", "jkl", "abc"), "", "");

    assertThat(diff, hasContent(
        "      | + def",
        "      | + ghi",
        "      | + jkl",
        "  abc |   abc"
    ));
  }

  @Test
  public void differentLengthsShortRevised() {
    String diff = diff(asList("def", "ghi", "jkl", "abc"), singletonList("abc"), "", "");

    assertThat(diff, hasContent(
        "- def |",
        "- ghi |",
        "- jkl |",
        "  abc |   abc"
    ));
  }

  /**
   * Tests the combination of all scenarios by comparing the required order of {@link PomSection}s
   * to alphabetically sorted {@link PomSection}s.
   */
  @Test
  public void combinations() {
// Path: src/main/java/com/github/ferstl/maven/pomenforcers/model/PomSection.java
// public enum PomSection {
//   MODEL_VERSION("modelVersion"),
//   PREREQUISITES("prerequisites"),
//   PARENT("parent"),
//   GROUP_ID("groupId"),
//   ARTIFACT_ID("artifactId"),
//   VERSION("version"),
//   PACKAGING("packaging"),
//   NAME("name"),
//   DESCRIPTION("description"),
//   URL("url"),
//   LICENSES("licenses"),
//   ORGANIZATION("organization"),
//   INCEPTION_YEAR("inceptionYear"),
//   CI_MANAGEMENT("ciManagement"),
//   MAILING_LISTS("mailingLists"),
//   ISSUE_MANAGEMENT("issueManagement"),
//   DEVELOPERS("developers"),
//   CONTRIBUTORS("contributors"),
//   SCM("scm"),
//   REPOSITORIES("repositories"),
//   PLUGIN_REPOSITORIES("pluginRepositories"),
//   DISTRIBUTION_MANAGEMENT("distributionManagement"),
//   MODULES("modules"),
//   PROPERTIES("properties"),
//   DEPENDENCY_MANAGEMENT("dependencyManagement"),
//   DEPENDENCIES("dependencies"),
//   BUILD("build"),
//   PROFILES("profiles"),
//   REPORTING("reporting"),
//   REPORTS("reports");
// 
//   private static final Map<String, PomSection> pomSectionMap;
// 
//   static {
//     pomSectionMap = Maps.newHashMap();
//     for (PomSection pomSection : values()) {
//       pomSectionMap.put(pomSection.getSectionName(), pomSection);
//     }
//   }
// 
//   public static PomSection getBySectionName(String sectionName) {
//     requireNonNull(sectionName, "Section name is null.");
// 
//     PomSection value = pomSectionMap.get(sectionName);
//     if (value == null) {
//       throw new IllegalArgumentException("POM section " + sectionName + " does not exist.");
//     }
// 
//     return value;
//   }
// 
//   private final String sectionName;
// 
//   PomSection(String sectionName) {
//     this.sectionName = sectionName;
//   }
// 
//   public String getSectionName() {
//     return this.sectionName;
//   }
// }
// 
// Path: src/main/java/com/github/ferstl/maven/pomenforcers/util/SideBySideDiffUtil.java
// public static String diff(Collection<String> actual, Collection<String> required, String leftTitle, String rightTitle) {
// 
//   SideBySideContext context = new SideBySideContext(actual, required, leftTitle, rightTitle);
//   int offset = 0;
// 
//   for (Delta<String> delta : context.deltas) {
//     Chunk<String> original = delta.getOriginal();
//     Chunk<String> revised = delta.getRevised();
//     int currentPosition = original.getPosition() + offset;
// 
//     switch (delta.getType()) {
//       case INSERT:
//         offset += context.expand(currentPosition, revised.size());
//         context.setRightContent(currentPosition, revised.getLines());
//         break;
// 
//       case CHANGE:
//         int difference = revised.size() - original.size();
//         if (difference > 0) {
//           offset += context.expand(currentPosition + original.size(), difference);
//         } else {
//           context.clearRightContent(currentPosition + revised.size(), Math.abs(difference));
//         }
// 
//         context.setLeftContent(currentPosition, original.getLines());
//         context.setRightContent(currentPosition, revised.getLines());
//         break;
// 
//       case DELETE:
//         context.setLeftContent(currentPosition, original.getLines());
//         context.clearRightContent(currentPosition, original.size());
//         break;
// 
//       default:
//         throw new IllegalStateException("Unsupported delta type: " + delta.getType());
// 
//     }
//   }
// 
//   return context.toString();
// }


// Path: src/test/java/com/github/ferstl/maven/pomenforcers/util/SideBySideDiffUtilTest.java
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeDiagnosingMatcher;
import org.junit.Test;
import com.github.ferstl.maven.pomenforcers.model.PomSection;
import com.google.common.collect.Ordering;
import static com.github.ferstl.maven.pomenforcers.util.SideBySideDiffUtil.diff;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.junit.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;

  @Test
  public void differentLengthsShortOriginal() {
    String diff = diff(singletonList("abc"), asList("def", "ghi", "jkl", "abc"), "", "");

    assertThat(diff, hasContent(
        "      | + def",
        "      | + ghi",
        "      | + jkl",
        "  abc |   abc"
    ));
  }

  @Test
  public void differentLengthsShortRevised() {
    String diff = diff(asList("def", "ghi", "jkl", "abc"), singletonList("abc"), "", "");

    assertThat(diff, hasContent(
        "- def |",
        "- ghi |",
        "- jkl |",
        "  abc |   abc"
    ));
  }

  /**
   * Tests the combination of all scenarios by comparing the required order of {@link PomSection}s
   * to alphabetically sorted {@link PomSection}s.
   */
  @Test
  public void combinations() {
    List<String> required = Arrays.stream(PomSection.values()).map(PomSection::getSectionName).collect(Collectors.toList());