@Test
public void testResolveResultPath() {
WebApplication webapp = new WebApplication(true);
webapp.registerMadvocComponents();
ResultMapper resultMapper = webapp.getComponent(ResultMapper.class);
String path = "/boo.foo.html";
ResultPath resultPath = resultMapper.resolveResultPath(path, "ok");
assertEquals("/boo.foo.html.ok", resultPath.getPathValue());
assertEquals("/boo.foo.html", resultPath.getPath());
assertEquals("ok", resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "doo.ok");
assertEquals("/boo.foo.html.doo.ok", resultPath.getPathValue());
assertEquals("/boo.foo.html", resultPath.getPath());
assertEquals("doo.ok", resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "#ok");
assertEquals("/boo.foo.ok", resultPath.getPathValue());
assertEquals("/boo.foo.ok", resultPath.getPath());
assertNull(resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "#.ok");
assertEquals("/boo.foo.ok", resultPath.getPathValue());
assertEquals("/boo.foo", resultPath.getPath());
assertEquals("ok", resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "#.ok.do");
assertEquals("/boo.foo.ok.do", resultPath.getPathValue());
assertEquals("/boo.foo", resultPath.getPath());
assertEquals("ok.do", resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "##ok");
assertEquals("/boo.ok", resultPath.getPathValue());
assertEquals("/boo.ok", resultPath.getPath());
assertNull(resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "##.ok");
assertEquals("/boo.ok", resultPath.getPathValue());
assertEquals("/boo", resultPath.getPath());
assertEquals("ok", resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "##ok.do");
assertEquals("/boo.ok.do", resultPath.getPathValue());
assertEquals("/boo.ok.do", resultPath.getPath());
assertNull(resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "##ok..do");
assertEquals("/boo.ok.do", resultPath.getPathValue());
assertEquals("/boo.ok", resultPath.getPath());
assertEquals("do", resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "#");
assertEquals("/boo.foo", resultPath.getPath());
assertNull(resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, null);
assertEquals("/boo.foo.html", resultPath.getPath());
assertNull(resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "/xxx");
assertEquals("/xxx", resultPath.getPath());
assertNull(resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "/xxx.ext");
assertEquals("/xxx.ext", resultPath.getPath());
assertNull(resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "/xxx..ext");
assertEquals("/xxx", resultPath.getPath());
assertEquals("ext", resultPath.getValue());
path = "/boo.html";
resultPath = resultMapper.resolveResultPath(path, "ok");
assertEquals("/boo.html", resultPath.getPath());
assertEquals("ok", resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "#.ok");
assertEquals("/boo", resultPath.getPath());
assertEquals("ok", resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "##ok");
assertEquals("/ok", resultPath.getPath());
assertEquals(null, resultPath.getValue());
resultPath = resultMapper.resolveResultPath(path, "##.ok");
assertEquals("/", resultPath.getPath());
assertEquals("ok", resultPath.getValue());
}