UserAndGroupReferenceResolver implements DocumentReferenceResolver<String> { public DocumentReference resolve(String documentReferenceRepresentation, Object... parameters) { if (parameters.length == 1 && !(parameters[0] instanceof String)) { throw new IllegalArgumentException("The resolver parameter is not a String."); } EntityReference defaultSpace; if (parameters.length == 1) { EntityReference defaultWiki = new EntityReference((String) parameters[0], EntityType.WIKI, null); defaultSpace = new EntityReference(DEFAULT_USER_SPACE, EntityType.SPACE, defaultWiki); } else { defaultSpace = resolver.resolve(DEFAULT_USER_SPACE, EntityType.SPACE); } return new DocumentReference(resolver.resolve(documentReferenceRepresentation, EntityType.DOCUMENT, defaultSpace)); }  DocumentReference resolve(String documentReferenceRepresentation, Object... parameters);  }
@Test public void testResolver() { try { DocumentReferenceResolver<String> resolver = getComponentManager().lookup(DocumentReferenceResolver.class, "user"); DocumentReferenceResolver<String> defaultResolver = getComponentManager().lookup(DocumentReferenceResolver.class, "user"); assertTrue(resolver.resolve("Bosse") .equals(defaultResolver.resolve("xwiki:XWiki.Bosse"))); assertTrue(resolver.resolve("bossesSpace.Bosse") .equals(defaultResolver.resolve("xwiki:bossesSpace.Bosse"))); assertTrue(resolver.resolve("Bosse", "bossesWiki") .equals(defaultResolver.resolve("bossesWiki:XWiki.Bosse"))); assertTrue(resolver.resolve("bossesSpace.Bosse", "bossesWiki").equals(defaultResolver.resolve("bossesWiki:bossesSpace.Bosse"))); assertTrue(resolver.resolve("bossesWiki:bossesSpace.Bosse") .equals(defaultResolver.resolve("bossesWiki:bossesSpace.Bosse"))); } catch(Exception e) { System.out.println("Caught exception: " + e); e.printStackTrace(System.out); assert false; } }