コード例 #1
0
  /**
   * This methods checks whether elements have a child element of with a given attribute.
   *
   * @param elements
   * @param testSolutionHandler
   */
  private void checkChildElementWithAttributePresence(
      Elements elements, TestSolutionHandler testSolutionHandler) {
    if (elements.isEmpty()) {
      testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
      return;
    }

    TestSolution testSolution = TestSolution.PASSED;

    for (Element el : elements) {

      if (!el.getElementsByAttribute(attributeName).isEmpty()) {

        testSolution = setTestSolution(testSolution, getSuccessSolution());
        addSourceCodeRemark(getSuccessSolution(), el, getSuccessMsgCode());

      } else {

        testSolution = setTestSolution(testSolution, getFailureSolution());
        addSourceCodeRemark(getFailureSolution(), el, getFailureMsgCode());
      }
    }

    testSolutionHandler.addTestSolution(testSolution);
  }