package ch.sferstl.maven.pomenforcer.reader;

import java.util.List;

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.w3c.dom.Document;

import com.google.common.collect.Lists;
import com.thoughtworks.xstream.XStream;

public class DeclaredDependencyManagementReader extends AbstractPomSectionReader<List<Artifact>> {

  private static final String DEPENDENCIES_XPATH = "/project/dependencyManagement/dependencies";
  private static final String DEPENDENCIES_ALIAS = "dependencies";
  private static final String DEPENDENCY_ALIAS = "dependency";

  public DeclaredDependencyManagementReader(Document pom) {
    super(pom);
  }

  @Override
  protected XPathExpression createXPathExpression(XPath xpath) throws XPathExpressionException {
    return xpath.compile(DEPENDENCIES_XPATH);
  }

  @Override
  protected void configureXStream(XStream xstream) {
    xstream.alias(DEPENDENCIES_ALIAS, List.class);
    xstream.alias(DEPENDENCY_ALIAS, DefaultArtifact.class);
    xstream.omitField(DefaultArtifact.class, "exclusions");
  }

  @Override
  protected List<Artifact> getUndeclaredSection() {
    return Lists.newArrayList();
  }

}

@@ -523,27 +523,36 @@
 ng DEPENDENC
-IES
+Y_MANAGEMENT
 _XPATH = %22/p
@@ -949,19 +949,28 @@
 EPENDENC
-IES
+Y_MANAGEMENT
 _XPATH);

correct constant name