public Element getFirstChildElement(String name) { nu.xom.Element body = xomElement.getFirstChildElement(name); if (body == null) { return null; } return new Element(body); }
private Element[] wrapXomElements(Elements xomElements) { int count = xomElements.size(); Element[] elements = new Element[count]; for (int i = 0; i < count; i++) { elements[i] = new Element(xomElements.get(i)); } return elements; }
private Element getDocumentBody(Element rootElement) { Element body = rootElement.getFirstDescendantNamed("body"); if (body == null) { body = new Element("body"); rootElement.appendChild(body); } return body; }
public Element[] getDescendantElements(String name) { List<Element> descendants = new ArrayList<Element>(); Nodes nodes = xomElement.query(xpathForElementName(name), namespaceMappings); for (int i = 0; i < nodes.size(); i++) { descendants.add(new Element((nu.xom.Element)nodes.get(i))); } descendants.remove(this); return descendants.toArray(new Element[0]); }
private Element exceptionMessage(String exceptionMessage) { return new Element("span") .addStyleClass("exceptionMessage") .appendText(exceptionMessage); }
public Element[] getDescendantElements(String name) { List<Element> descendants = new ArrayList<Element>(); Nodes nodes = xomElement.query(xpathForElementName(name), namespaceMappings); for (int i = 0; i < nodes.size(); i++) { descendants.add(new Element((nu.xom.Element)nodes.get(i))); } descendants.remove(this); return descendants.toArray(new Element[0]); }
private Element[] wrapXomElements(Elements xomElements) { int count = xomElements.size(); Element[] elements = new Element[count]; for (int i = 0; i < count; i++) { elements[i] = new Element(xomElements.get(i)); } return elements; }
private Element getDocumentBody(Element rootElement) { Element body = rootElement.getFirstDescendantNamed("body"); if (body == null) { body = new Element("body"); rootElement.appendChild(body); } return body; }
protected void addDateGeneratedAt(long millisTaken, Element footer) { Element dateDiv = new Element("div"); dateDiv.addStyleClass("testTime"); dateDiv.appendText("in " + (millisTaken + 1) + " ms "); dateDiv.appendText(new SimpleDateFormat("'on' dd-MMM-yyyy 'at' HH:mm:ss z").format(new Date())); footer.appendChild(dateDiv); }
protected void addDateGeneratedAt(long millisTaken, Element footer) { Element dateDiv = new Element("div"); dateDiv.addStyleClass("testTime"); dateDiv.appendText("in " + (millisTaken + 1) + " ms "); dateDiv.appendText(new SimpleDateFormat("'on' dd-MMM-yyyy 'at' HH:mm:ss z").format(new Date())); footer.appendChild(dateDiv); }
private Element stackTrace(Throwable t, String expression) { Element stackTrace = new Element("div").addStyleClass("stackTrace"); stackTrace.setId("stackTrace" + buttonId); Element p = new Element("p") .appendText("While evaluating expression: "); p.appendChild(new Element("code").appendText(expression)); stackTrace.appendChild(p); recursivelyAppendStackTrace(t, stackTrace); return stackTrace; }
private Element createBreadcrumbElement(Resource documentResource, Resource indexPageResource, SpecificationConverter specificationConverter) throws IOException { String breadcrumbWording = getBreadcrumbWordingForResource(indexPageResource, specificationConverter); Element a = new Element("a"); Resource indexPageAsHtmlResource = new Resource(indexPageResource.getPath().replaceFirst("\\..*$", "\\.html")); a.addAttribute("href", documentResource.getRelativePath(indexPageAsHtmlResource)); a.appendText(breadcrumbWording); return a; }
public void afterProcessingSpecification(SpecificationProcessingEvent event) { try { Element span = new Element("span").addStyleClass("breadcrumbs"); appendBreadcrumbsTo(span, event.getResource()); if (span.hasChildren()) { getDocumentBody(event.getRootElement()) .prependChild(span); } } catch (Throwable t) { t.printStackTrace(); } }
public void afterProcessingSpecification(SpecificationProcessingEvent event) { try { Element span = new Element("span").addStyleClass("breadcrumbs"); appendBreadcrumbsTo(span, event.getResource()); if (span.hasChildren()) { getDocumentBody(event.getRootElement()) .prependChild(span); } } catch (Throwable t) { t.printStackTrace(); } }
protected void addResultsGeneratedBy(Element footer) { footer.appendText("Results generated by "); Element link = new Element("a"); link.addAttribute("href", CONCORDION_WEBSITE_URL); link.addAttribute("style", "font-weight: bold; text-decoration: none; color: #89C;"); footer.appendChild(link); link.appendText("Concordion"); } }
private Element stackTraceTogglingButton() { return new Element("input") .addStyleClass("stackTraceButton") .setId("stackTraceButton" + buttonId) .addAttribute("type", "button") .addAttribute("onclick", "javascript:toggleStackTrace('" + buttonId + "')") .addAttribute("value", "View Stack"); }
public static void setupCommandForExample(CommandCall node, ResultRecorder resultRecorder, String exampleName) { node.getElement().addAttribute("id", exampleName); // let's be really nice and add the implementation status text into the element itself. ImplementationStatusChecker checker = ImplementationStatusChecker.implementationStatusCheckerFor(resultRecorder.getImplementationStatus()); Element fixtureNode = new Element("p"); fixtureNode.appendText(checker.printNoteToString()); node.getElement().prependChild(fixtureNode); }
@Test public void createsBodyIfNoneExists() { stubSource.addResource(PACKAGE_RESOURCE_NAME, GOOD_HTML); Element rootElement = new Element("html"); SpecificationProcessingEvent event = new SpecificationProcessingEvent(new Resource(SPEC_RESOURCE_NAME), new org.concordion.api.Element(rootElement)); renderer.afterProcessingSpecification(event); String logMessage = systemErrRule.getLog(); assertThat(logMessage, is("")); assertThat(rootElement.getChildElements("body").size(), is(1)); }
@Test public void getParentElementOfRootReturnsNull() throws Exception { Document document = XMLParser.parse("<root></root>"); Element root = new Element(document.getRootElement()); assertNull(root.getParentElement()); }
public String markAsException(String fragment, String expression, String errorMessage) { Throwable t = new Throwable(errorMessage); t.setStackTrace(stackTraceElements.toArray(new StackTraceElement[0])); Element element = new Element((nu.xom.Element) new TestRig() .processFragment(fragment) .getXOMDocument() .query("//p") .get(0)); new ThrowableRenderer(new ClassPathSource()).throwableCaught(new ThrowableCaughtEvent(t, element, expression)); return element.toXML(); } }