### Question:
XPathRecord implements Record { @Override public List<Value> getValues(String field) { try { XPathExpression expr = xpath_map.get(field); if (expr == null) { return null; } NodeList lst = (NodeList)expr.evaluate(doc, XPathConstants.NODESET); ArrayList<Value> ret = new ArrayList<Value>(); for (int i = 0; i < lst.getLength(); i++) { String str = lst.item(i).getTextContent().trim(); if (!"".equals(str)) { ret.add(new StringValue(str)); } } return ret; } catch(XPathExpressionException e) { logger.info(e.getStackTrace()); } return null; } XPathRecord(Document doc, Map<String, String> xpath_string_map); @Override List<Value> getValues(String field); @Override MutableRecord makeMutable(); @Override boolean isMutable(); @Override boolean hasField(String field); @Override Set<String> getFields();  }### Answer:
@Test public void testGetValues_Attributes() { List<Value> res3 = rec.getValues("leaf1_attribute"); assertEquals(1, res3.size()); assertEquals("leaf1 attribute", res3.get(0).getAsString()); List<Value> res4 = rec.getValues("all_attributes"); assertEquals(2, res4.size()); assertEquals("leaf1 attribute", res4.get(0).getAsString()); assertEquals("leaf2 attribute", res4.get(1).getAsString()); }
@Test public void testGetValues_NotExisting() { assertNull(rec.getValues("not_existing")); }
@Test public void testGetValues_Empty() { List<Value> res0 = rec.getValues("empty"); assertEquals(0, res0.size()); }
@Test public void testGetValues_Text() { List<Value> res1 = rec.getValues("leaf1_text"); assertEquals(1, res1.size()); assertEquals("Text of leaf1", res1.get(0).getAsString()); List<Value> res2 = rec.getValues("node2_text"); assertEquals(3, res2.size()); assertEquals("Text of node2 that contains", res2.get(0).getAsString()); assertEquals("a leaf with text", res2.get(1).getAsString()); assertEquals("and has some more text at the end.", res2.get(2).getAsString()); }