### Question:
DefaultVfsManager implements VfsManager { @Override public String getURL(VfsResourceReference reference) throws VfsException { try { return this.serializer.serialize(reference).toString(); } catch (Exception e) { throw new VfsException("Failed to compute URL for [%s]", e, reference); } }  @Override String getURL(VfsResourceReference reference);  }### Answer:
@Test public void getURL() throws Exception { VfsResourceReference reference = new VfsResourceReference( URI.create("attach:xwiki:space.page@attachment"), "path1/path2/test.txt"); ResourceReferenceSerializer<VfsResourceReference, ExtendedURL> serializer = this.mocker.getInstance( new DefaultParameterizedType(null, ResourceReferenceSerializer.class, VfsResourceReference.class, ExtendedURL.class)); when(serializer.serialize(reference)).thenReturn(new ExtendedURL(Arrays.asList("generated", "url"))); assertEquals("/generated/url", this.mocker.getComponentUnderTest().getURL(reference)); }
@Test public void getURLerror() throws Exception { VfsResourceReference reference = new VfsResourceReference( URI.create("attach:xwiki:space.page@attachment"), "path1/path2/test.txt"); ResourceReferenceSerializer<VfsResourceReference, ExtendedURL> serializer = this.mocker.getInstance( new DefaultParameterizedType(null, ResourceReferenceSerializer.class, VfsResourceReference.class, ExtendedURL.class)); when(serializer.serialize(reference)).thenThrow(new SerializeResourceReferenceException("error")); try { this.mocker.getComponentUnderTest().getURL(reference); fail("Should have thrown an exception"); } catch (VfsException expected) { assertEquals("Failed to compute URL for [scheme = [attach], reference = [xwiki:space.page@attachment], " + "path = [path1/path2/test.txt], parameters = []]", expected.getMessage()); } }