@Test(expectedExceptions = {RuntimeException.class}) public void testToMap_with_empty_xmlString() { WxPayOrderQueryResult result = new WxPayOrderQueryResult(); result.setXmlString(" "); Map<String, String> map = result.toMap(); System.out.println(map); }
public Map<String, String> toMap() { if (StringUtils.isBlank(this.xmlString)) { throw new RuntimeException("xml数据有问题，请核实！"); } Map<String, String> result = Maps.newHashMap(); Document doc = this.getXmlDoc(); try { NodeList list = (NodeList) XPathFactory.newInstance().newXPath() .compile("/xml/*") .evaluate(doc, XPathConstants.NODESET); int len = list.getLength(); for (int i = 0; i < len; i++) { result.put(list.item(i).getNodeName(), list.item(i).getTextContent()); } } catch (XPathExpressionException e) { throw new RuntimeException("非法的xml文本内容：" + xmlString); } return result; }
BaseWxPayResult implements Serializable { public Map<String, String> toMap() { if (StringUtils.isBlank(this.xmlString)) { throw new RuntimeException("xml数据有问题，请核实！"); } Map<String, String> result = Maps.newHashMap(); Document doc = this.getXmlDoc(); try { NodeList list = (NodeList) XPathFactory.newInstance().newXPath() .compile("/xml/*") .evaluate(doc, XPathConstants.NODESET); int len = list.getLength(); for (int i = 0; i < len; i++) { result.put(list.item(i).getNodeName(), list.item(i).getTextContent()); } } catch (XPathExpressionException e) { throw new RuntimeException("非法的xml文本内容：" + xmlString); } return result; } }
BaseWxPayResult implements Serializable { public Map<String, String> toMap() { if (StringUtils.isBlank(this.xmlString)) { throw new RuntimeException("xml数据有问题，请核实！"); } Map<String, String> result = Maps.newHashMap(); Document doc = this.getXmlDoc(); try { NodeList list = (NodeList) XPathFactory.newInstance().newXPath() .compile("/xml/*") .evaluate(doc, XPathConstants.NODESET); int len = list.getLength(); for (int i = 0; i < len; i++) { result.put(list.item(i).getNodeName(), list.item(i).getTextContent()); } } catch (XPathExpressionException e) { throw new RuntimeException("非法的xml文本内容：" + xmlString); } return result; }  }
BaseWxPayResult implements Serializable { public Map<String, String> toMap() { if (StringUtils.isBlank(this.xmlString)) { throw new RuntimeException("xml数据有问题，请核实！"); } Map<String, String> result = Maps.newHashMap(); Document doc = this.getXmlDoc(); try { NodeList list = (NodeList) XPathFactory.newInstance().newXPath() .compile("/xml/*") .evaluate(doc, XPathConstants.NODESET); int len = list.getLength(); for (int i = 0; i < len; i++) { result.put(list.item(i).getNodeName(), list.item(i).getTextContent()); } } catch (XPathExpressionException e) { throw new RuntimeException("非法的xml文本内容：" + xmlString); } return result; }  static String fenToYuan(Integer fen); static T fromXML(String xmlString, Class<T> clz); @Override String toString(); Map<String, String> toMap(); void checkResult(WxPayService wxPayService, String signType, boolean checkSuccess); }
BaseWxPayResult implements Serializable { public Map<String, String> toMap() { if (StringUtils.isBlank(this.xmlString)) { throw new RuntimeException("xml数据有问题，请核实！"); } Map<String, String> result = Maps.newHashMap(); Document doc = this.getXmlDoc(); try { NodeList list = (NodeList) XPathFactory.newInstance().newXPath() .compile("/xml/*") .evaluate(doc, XPathConstants.NODESET); int len = list.getLength(); for (int i = 0; i < len; i++) { result.put(list.item(i).getNodeName(), list.item(i).getTextContent()); } } catch (XPathExpressionException e) { throw new RuntimeException("非法的xml文本内容：" + xmlString); } return result; }  static String fenToYuan(Integer fen); static T fromXML(String xmlString, Class<T> clz); @Override String toString(); Map<String, String> toMap(); void checkResult(WxPayService wxPayService, String signType, boolean checkSuccess);  }