RemoveNodesDataModifier extends AbstractDataModifierJob<String> { @Override public void setParameters(Map<String, String> params) throws ParametersException { if (params.containsKey(PARAM_XPATH)) { xpathString = params.get(PARAM_XPATH); XPathFactory xPathfactory = XPathFactory.newInstance(); XPath xpath = xPathfactory.newXPath(); try { expr = xpath.compile(xpathString); } catch (XPathExpressionException e) { throw new ParametersException(e.getMessage(), e); } } else { throw new ParametersException("XPath must be provided"); } }  @Override void setParameters(Map<String, String> params); @Override String modifyData(String source); @Override String getInfo(); static final String NAME; }
@Test(expected = ParametersException.class) public void setParameters_XPathIsEmpty_ExceptionIsThrown() throws ParametersException { tested.setParameters(params); }
@Test(expected = ParametersException.class) public void setParameters_XPathIsInvalid_ExceptionIsThrown() throws ParametersException { when(params.containsKey(PARAM_XPATH)).thenReturn(true); when(params.get(PARAM_XPATH)).thenReturn(PARAM_XPATH_INVALID_VALUE); tested.setParameters(params); }