XmlSearch implements Service { public int getMaxRecordValue() { return maxRecordValue; }  void init(Path appPath, ServiceConfig config); Element exec(Element params, ServiceContext context); int getMaxRecordValue();  }
@Test public void testFromDefinedToDefinedOutOfRange() { Element params = new Element("request"); params.addContent(new Element("from").setText("324")) .addContent(new Element("to").setText(Integer.toString(324 + xs.getMaxRecordValue() + 55))); boolean ret = (boolean) ReflectionUtils.invokeMethod(setSafeBoundaries, xs, params); assertTrue(ret); assertTrue(params.getChild("from").getText().equals("324")); assertTrue(params.getChild("to").getText().equals(Integer.toString(324 + xs.getMaxRecordValue() - 1))); }
@Test public void testFromUndefinedToUndefined() { Element params = new Element("request"); boolean ret = (boolean) ReflectionUtils.invokeMethod(setSafeBoundaries, xs, params); assertTrue("expected modified passed params", ret); assertTrue(params.getChild("from").getText().equals("1")); assertTrue(params.getChild("to").getText().equals(Integer.toString(xs.getMaxRecordValue()))); }
@Test public void testFromUndefinedToDefined() { Element params = new Element("request"); params.addContent(new Element("to").setText("150")); boolean ret = (boolean) ReflectionUtils.invokeMethod(setSafeBoundaries, xs, params); assertTrue("expected modified passed params", ret); assertTrue(params.getChild("from").getText().equals(Integer.toString(150 - xs.getMaxRecordValue()))); assertTrue(params.getChild("to").getText().equals("150")); }
@Test public void testFromUndefinedToDefinedButTooSmall() { Element params = new Element("request"); int boundaryTo = xs.getMaxRecordValue() / 2; params.addContent(new Element("to").setText(Integer.toString(boundaryTo))); boolean ret = (boolean) ReflectionUtils.invokeMethod(setSafeBoundaries, xs, params); assertTrue("expected modified passed params", ret); assertTrue(params.getChild("from").getText().equals("1")); assertTrue(params.getChild("to").getText().equals(Integer.toString(boundaryTo))); }
@Test public void testFromDefinedToUndefined() { Element params = new Element("request"); params.addContent(new Element("from").setText("42")); boolean ret = (boolean) ReflectionUtils.invokeMethod(setSafeBoundaries, xs, params); assertTrue("expected modified passed params", ret); assertTrue(params.getChild("from").getText().equals("42")); assertTrue(params.getChild("to").getText().equals(Integer.toString(42 + xs.getMaxRecordValue() - 1))); }