Package org.jsoup.nodes

Examples of org.jsoup.nodes.Document


        Map<String, Object> root = createInspectionResultWrapper(ENTITY_NAME, NUMBER_PROP_WITH_MIN_VAL);

        Resource<URL> templateResource = resourceFactory.create(getClass().getResource(Deployments.BASE_PACKAGE_PATH + Deployments.BASIC_PROPERTY_DETAIL_INCLUDE));
        Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
        String output = processor.process(root);
        Document html = Jsoup.parseBodyFragment(output);
        assertThat(output.trim(), not(equalTo("")));
       
        Elements container = html.select("div.form-group");
        assertThat(container, notNullValue());
        assertThat(container.attr("ng-class"), not(equalTo("")));
       
        Elements formInputElement = html.select("div.form-group input");
        assertThat(formInputElement.attr("id"), equalTo("score"));
        assertThat(formInputElement.attr("type"), equalTo("number"));
        assertThat(formInputElement.attr("min"), equalTo("0"));
        assertThat(formInputElement.attr("ng-model"), equalTo(StringUtils.camelCase(ENTITY_NAME)+"."+"score"));
    }
View Full Code Here


        root.put("entityName", "SampleEntity");
        root.put("properties", properties);
        Resource<URL> templateResource = resourceFactory.create(getClass().getResource(Deployments.BASE_PACKAGE_PATH + Deployments.SEARCH_RESULTS));
        Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
        String output = processor.process(root);
        Document html = Jsoup.parseBodyFragment(output);
        assertThat(output.trim(), not(equalTo("")));
       
        Elements headers = html.select("table > thead > tr > th");
        assertThat(0, equalTo(headers.size()));
    }
View Full Code Here

        root.put("entityName", "SampleEntity");
        root.put("properties", properties);
        Resource<URL> templateResource = resourceFactory.create(getClass().getResource(Deployments.BASE_PACKAGE_PATH + Deployments.SEARCH_RESULTS));
        Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
        String output = processor.process(root);
        Document html = Jsoup.parseBodyFragment(output);
        assertThat(output.trim(), not(equalTo("")));
       
        Elements headers = html.select("table > thead > tr > th");
        assertThat(0, equalTo(headers.size()));
    }
View Full Code Here

        root.put("entityName", "SampleEntity");
        root.put("properties", properties);
        Resource<URL> templateResource = resourceFactory.create(getClass().getResource(Deployments.BASE_PACKAGE_PATH + Deployments.SEARCH_RESULTS));
        Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
        String output = processor.process(root);
        Document html = Jsoup.parseBodyFragment(output);
        assertThat(output.trim(), not(equalTo("")));
       
        Elements headers = html.select("table > thead > tr > th");
        assertThat(0, equalTo(headers.size()));
    }
View Full Code Here

        root.put("entityName", "SampleEntity");
        root.put("properties", properties);
        Resource<URL> templateResource = resourceFactory.create(getClass().getResource(Deployments.BASE_PACKAGE_PATH + Deployments.SEARCH_RESULTS));
        Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
        String output = processor.process(root);
        Document html = Jsoup.parseBodyFragment(output);
        assertThat(output.trim(), not(equalTo("")));
       
        Elements headers = html.select("table > thead > tr > th");
        assertThat(0, equalTo(headers.size()));
    }
View Full Code Here

        root.put("entityId", basicStringProperty);
        root.put("properties", properties);
        Resource<URL> templateResource = resourceFactory.create(getClass().getResource(Deployments.BASE_PACKAGE_PATH + Deployments.SEARCH_RESULTS));
        Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
        String output = processor.process(root);
        Document html = Jsoup.parseBodyFragment(output);
        assertThat(output.trim(), not(equalTo("")));
       
        Elements headers = html.select("table > thead > tr > th");
        assertThat(headers.size(), equalTo(1));
        assertThat(headers.text(), equalTo("Full Name"));
       
        Elements resultRows = html.select("table > tbody > tr");
        assertThat(resultRows.attr("ng-repeat"), containsString("result in searchResults"));
       
        Elements resultCells = resultRows.select(" > td");
        assertThat(resultCells.size(), equalTo(1));
        assertThat(resultCells.select("a").attr("href"), equalTo("#/"+"SampleEntities"+ "/edit/{{result.fullName}}"));
View Full Code Here

        root.put("entityId", basicNumberProperty);
        root.put("properties", properties);
        Resource<URL> templateResource = resourceFactory.create(getClass().getResource(Deployments.BASE_PACKAGE_PATH + Deployments.SEARCH_RESULTS));
        Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
        String output = processor.process(root);
        Document html = Jsoup.parseBodyFragment(output);
        assertThat(output.trim(), not(equalTo("")));
       
        Elements headers = html.select("table > thead > tr > th");
        assertThat(headers.size(), equalTo(1));
        assertThat(headers.text(), equalTo("Age"));
       
        Elements resultRows = html.select("table > tbody > tr");
        assertThat(resultRows.attr("ng-repeat"), containsString("result in searchResults"));
       
        Elements resultCells = resultRows.select(" > td");
        assertThat(resultCells.size(), equalTo(1));
        assertThat(resultCells.select("a").attr("href"), equalTo("#/"+"SampleEntities"+ "/edit/{{result.age}}"));
View Full Code Here

        root.put("entityId", basicDateProperty);
        root.put("properties", properties);
        Resource<URL> templateResource = resourceFactory.create(getClass().getResource(Deployments.BASE_PACKAGE_PATH + Deployments.SEARCH_RESULTS));
        Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
        String output = processor.process(root);
        Document html = Jsoup.parseBodyFragment(output);
        assertThat(output.trim(), not(equalTo("")));
       
        Elements headers = html.select("table > thead > tr > th");
        assertThat(headers.size(), equalTo(1));
        assertThat(headers.text(), equalTo("Date Of Birth"));
       
        Elements resultRows = html.select("table > tbody > tr");
        assertThat(resultRows.attr("ng-repeat"), containsString("result in searchResults"));
       
        Elements resultCells = resultRows.select(" > td");
        assertThat(resultCells.size(), equalTo(1));
        assertThat(resultCells.select("a").attr("href"), equalTo("#/"+"SampleEntities"+ "/edit/{{result.dateOfBirth}}"));
View Full Code Here

      HttpResponseContent response = performHttpGetCall(url, null);

      if (response.contentType != null && response.contentType.contains("text/html")) {

        try {
          Document doc = Jsoup.parse(new ByteArrayInputStream(response.content), null, url);

          if (htmlMapping == null) {
            return doc.html();
          } else {
            Map<String, String> ret = new HashMap<>();
            for (String dataField : htmlMapping.keySet()) {
              String value = null;
              Map<String, Object> fieldMappingConfig = htmlMapping.get(dataField);
              String cssSelector = Utils.trimToNull((String) fieldMappingConfig.get(CFG_HM_CSS_SELECTOR));
              boolean stripHtml = XContentMapValues.nodeBooleanValue(fieldMappingConfig.get(CFG_HM_STRIP_HTML), false);
              if (cssSelector != null) {
                Elements elements = doc.select(cssSelector);
                if (elements != null && !elements.isEmpty()) {
                  String valueAttribute = Utils.trimToNull((String) fieldMappingConfig.get(CFG_HM_VALUE_ATTRIBUTE));
                  if (valueAttribute != null) {
                    StringBuilder sb = new StringBuilder();
                    for (Element e : elements) {
                      String v = Utils.trimToNull(e.attr(valueAttribute));
                      if (v != null) {
                        if (sb.length() > 0) {
                          sb.append(" ");
                        }
                        sb.append(v);
                      }
                    }
                    value = Utils.trimToNull(sb.toString());
                  } else {
                    if (stripHtml) {
                      value = convertElementsToText(elements);
                    } else {
                      if (elements.size() == 1) {
                        value = elements.html();
                      } else {
                        value = elements.outerHtml();
                      }
                    }
                  }
                }
              } else {
                if (stripHtml) {
                  value = convertNodeToText(doc);
                } else {
                  value = doc.html();
                }
              }
              ret.put(dataField, value);
            }
            return ret;
View Full Code Here

        Map<String, Object> root = createInspectionResultWrapper(ENTITY_NAME, NUMBER_PROP_WITH_MAX_VAL);

        Resource<URL> templateResource = resourceFactory.create(getClass().getResource(Deployments.BASE_PACKAGE_PATH + Deployments.BASIC_PROPERTY_DETAIL_INCLUDE));
        Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
        String output = processor.process(root);
        Document html = Jsoup.parseBodyFragment(output);
        assertThat(output.trim(), not(equalTo("")));
       
        Elements container = html.select("div.form-group");
        assertThat(container, notNullValue());
        assertThat(container.attr("ng-class"), not(equalTo("")));
       
        Elements formInputElement = html.select("div.form-group input");
        assertThat(formInputElement.attr("id"), equalTo("score"));
        assertThat(formInputElement.attr("type"), equalTo("number"));
        assertThat(formInputElement.attr("max"), equalTo("100"));
        assertThat(formInputElement.attr("ng-model"), equalTo(StringUtils.camelCase(ENTITY_NAME)+"."+"score"));
    }
View Full Code Here

TOP

Related Classes of org.jsoup.nodes.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.