### Question:
VfsScriptService implements ScriptService { public String url(VfsResourceReference reference) { try { return this.vfsManager.getURL(reference); } catch (Exception e) { return null; } }  String url(VfsResourceReference reference); @Unstable String url(VfsResourceReference reference, String contentType);  }### Answer:
@Test public void url() throws Exception { VfsResourceReference reference = new VfsResourceReference( URI.create("attach:xwiki:space.page@attachment"), "path1/path2/test.txt"); when(manager.getURL(reference)).thenReturn("/generated/url"); assertEquals("/generated/url", this.scriptService.url( new VfsResourceReference(URI.create("attach:xwiki:space.page@attachment"), "path1/path2/test.txt"))); }
@Test public void urlError() throws Exception { VfsResourceReference reference = new VfsResourceReference( URI.create("attach:xwiki:space.page@attachment"), "path1/path2/test.txt"); when(manager.getURL(reference)).thenThrow(new VfsException("error")); assertNull(this.scriptService.url( new VfsResourceReference(URI.create("attach:xwiki:space.page@attachment"), "path1/path2/test.txt"))); }