### Question:
DocumentRestURLGenerator extends AbstractEntityRestURLGenerator<DocumentReference> { @Override public URL getURL(DocumentReference reference) throws XWikiRestException { try { Locale locale = reference.getLocale(); URL url; if (locale != null && !locale.toString().isEmpty()) { url = Utils.createURI(getBaseURI(), PageTranslationResource.class, reference.getWikiReference().getName(), getSpaceList(reference.getLastSpaceReference()), reference.getName(), reference.getLocale()).toURL(); } else { url = Utils.createURI(getBaseURI(), PageResource.class, reference.getWikiReference().getName(), getSpaceList(reference.getLastSpaceReference()), reference.getName()).toURL(); } return url; } catch (MalformedURLException e) { throw new XWikiRestException( String.format("Failed to generate a REST URL for the document [%s].", reference), e); } }  @Override URL getURL(DocumentReference reference);  }### Answer:
@Test void getURLWithoutLocale() throws Exception { DocumentReference documentReference = new DocumentReference("wiki", "space", "page"); assertEquals("http: this.generator.getURL(documentReference).toString()); }
@Test void getURLWithLocale() throws Exception { DocumentReference documentReference = new DocumentReference("wiki", "space", "page", Locale.FRENCH); assertEquals("http: this.generator.getURL(documentReference).toString()); }
@Test void getURLWithSlash() throws Exception { DocumentReference documentReference = new DocumentReference("wiki", "space", "pa/ge"); assertEquals("http: this.generator.getURL(documentReference).toString()); }