/**
   * Test method for {@link
   * net.hyperadapt.pxweave.interpreter.test.OperationInterpreter#interpreteFillComponentByID(java.lang.String,
   * java.lang.String, org.w3c.dom.NodeList, java.util.List)} .
   *
   * @throws XMLWeaverException
   */
  @Test
  public void testInterpreteFillComponentByID() throws XMLWeaverException {
    final Document listTarget = parser.buildDOM(URI.create("testData/bookList.xml"));
    final Document bookSource = parser.buildDOM(URI.create("testData/book.xml"));
    final NodeList joinPoints = xPathEvaluator.evaluateXPath("//book", listTarget);
    final NodeList sourceComps = xPathEvaluator.evaluateXPath("//books:book", bookSource);

    final List<Element> sourceComponents = new ArrayList<Element>();
    sourceComponents.add((Element) sourceComps.item(0));
    sourceComponents.add((Element) sourceComps.item(1));
    sourceComponents.add((Element) sourceComps.item(2));

    oInterpreter.interpreteFillComponentByID("price", "price", joinPoints, sourceComponents);
    NodeList result = xPathEvaluator.evaluateXPath("//book//books:name/text()", listTarget);
    assertTrue(
        "JoinPoints are filled with the correct nodes",
        (result.item(0).getNodeValue().contentEquals("Sam")
                & result.item(1).getNodeValue().contentEquals("M."))
            & result.item(2).getNodeValue().contentEquals("A"));
    oInterpreter.interpreteFillComponentByID("price", "price", joinPoints, sourceComponents);
    result = xPathEvaluator.evaluateXPath("//book//books:name/text()", listTarget);
    assertTrue(
        "Already existing nodes in joinPoints are kept",
        (result.item(0).getNodeValue().contentEquals("Sam")
                & result.item(1).getNodeValue().contentEquals("Sam"))
            & result.item(2).getNodeValue().contentEquals("M."));
  }
  /**
   * Test method for {@link
   * net.hyperadapt.pxweave.interpreter.test.OperationInterpreter#interpreteFillComponentByID(java.lang.String,
   * java.lang.String, org.w3c.dom.NodeList, java.util.List)} .
   *
   * @throws XMLWeaverException
   */
  @Test(expected = XMLWeaverException.class)
  public void testInterpreteFillComponentByIDMissingSource() throws XMLWeaverException {
    final Document listTarget = parser.buildDOM(URI.create("testData/bookList.xml"));
    final Document source = parser.buildDOM(URI.create("testData/book.xml"));
    final NodeList joinPoints = xPathEvaluator.evaluateXPath("//book", listTarget);
    final NodeList sourceComps = xPathEvaluator.evaluateXPath("//books:book", source);

    final List<Element> sourceComponents = new ArrayList<Element>();
    sourceComponents.add((Element) sourceComps.item(0));
    sourceComponents.add((Element) sourceComps.item(1));

    oInterpreter.interpreteFillComponentByID("price", "price", joinPoints, sourceComponents);
  }
  /** @throws java.lang.Exception */
  @Before
  public void setUp() throws Exception {
    parser = new DOML3Parser();
    document = parser.buildDOM((new File("testData/book.xml")).toURI());

    xPathEvaluator =
        new XPathEvaluator(
            new Environment.NSContext() {
              {
                this.getNamespaces().put("books", URI.create("http://books"));
                this.getDefinitions()
                    .put(URI.create("http://books"), (new File("testData/book.xsd")).toURI());
              }
            });
    testElements0 = new ArrayList<Element>();

    testElements1 =
        new ArrayList<Element>() {
          private static final long serialVersionUID = 1L;

          {
            add(document.createElement("test0"));
          }
        };

    testElements3 =
        new ArrayList<Element>() {
          private static final long serialVersionUID = 1L;

          {
            add(document.createElement("test0"));
            add(document.createElement("test1"));
            add(document.createElement("test2"));
          }
        };

    testText0 = new ArrayList<Text>();
    testText1 =
        new ArrayList<Text>() {
          private static final long serialVersionUID = 1L;

          {
            add(document.createTextNode("text0"));
          }
        };

    testText3 =
        new ArrayList<Text>() {
          private static final long serialVersionUID = 1L;

          {
            add(document.createTextNode("text0"));
            add(document.createTextNode("text1"));
            add(document.createTextNode("text2"));
          }
        };
  }