@Test void serializeWhenNotDocumentUserReference() { UserResourceReference userReference = mock(UserResourceReference.class); Throwable exception = assertThrows(RuntimeException.class, () -> this.serializer.serialize(userReference)); assertEquals("The passed user resource reference is not pointing to a wiki Document", exception.getMessage()); }
@Override public ExtendedURL serialize(UserResourceReference resourceReference) throws SerializeResourceReferenceException { UserReference userReference = resourceReference.getUserReference(); if (!(userReference instanceof DocumentUserReference)) { throw new IllegalArgumentException("The passed user resource reference is not pointing to a wiki Document"); } DocumentReference documentReference = ((DocumentUserReference) userReference).getReference(); XWikiContext xcontext = this.xwikiContextProvider.get(); XWikiURLFactory urlFactory = xcontext.getURLFactory(); URL url = createURL(urlFactory, documentReference, xcontext); ExtendedURL extendedURL; try { extendedURL = new ExtendedURL(url, null); } catch (CreateResourceReferenceException e) { throw new SerializeResourceReferenceException( String.format("Failed to serialize user reference [%s] into a [%s]", documentReference, ExtendedURL.class.getName()), e); } return extendedURL; }
DocumentUserResourceReferenceSerializer implements ResourceReferenceSerializer<UserResourceReference, ExtendedURL> { @Override public ExtendedURL serialize(UserResourceReference resourceReference) throws SerializeResourceReferenceException { UserReference userReference = resourceReference.getUserReference(); if (!(userReference instanceof DocumentUserReference)) { throw new IllegalArgumentException("The passed user resource reference is not pointing to a wiki Document"); } DocumentReference documentReference = ((DocumentUserReference) userReference).getReference(); XWikiContext xcontext = this.xwikiContextProvider.get(); XWikiURLFactory urlFactory = xcontext.getURLFactory(); URL url = createURL(urlFactory, documentReference, xcontext); ExtendedURL extendedURL; try { extendedURL = new ExtendedURL(url, null); } catch (CreateResourceReferenceException e) { throw new SerializeResourceReferenceException( String.format("Failed to serialize user reference [%s] into a [%s]", documentReference, ExtendedURL.class.getName()), e); } return extendedURL; } }
DocumentUserResourceReferenceSerializer implements ResourceReferenceSerializer<UserResourceReference, ExtendedURL> { @Override public ExtendedURL serialize(UserResourceReference resourceReference) throws SerializeResourceReferenceException { UserReference userReference = resourceReference.getUserReference(); if (!(userReference instanceof DocumentUserReference)) { throw new IllegalArgumentException("The passed user resource reference is not pointing to a wiki Document"); } DocumentReference documentReference = ((DocumentUserReference) userReference).getReference(); XWikiContext xcontext = this.xwikiContextProvider.get(); XWikiURLFactory urlFactory = xcontext.getURLFactory(); URL url = createURL(urlFactory, documentReference, xcontext); ExtendedURL extendedURL; try { extendedURL = new ExtendedURL(url, null); } catch (CreateResourceReferenceException e) { throw new SerializeResourceReferenceException( String.format("Failed to serialize user reference [%s] into a [%s]", documentReference, ExtendedURL.class.getName()), e); } return extendedURL; }  }
DocumentUserResourceReferenceSerializer implements ResourceReferenceSerializer<UserResourceReference, ExtendedURL> { @Override public ExtendedURL serialize(UserResourceReference resourceReference) throws SerializeResourceReferenceException { UserReference userReference = resourceReference.getUserReference(); if (!(userReference instanceof DocumentUserReference)) { throw new IllegalArgumentException("The passed user resource reference is not pointing to a wiki Document"); } DocumentReference documentReference = ((DocumentUserReference) userReference).getReference(); XWikiContext xcontext = this.xwikiContextProvider.get(); XWikiURLFactory urlFactory = xcontext.getURLFactory(); URL url = createURL(urlFactory, documentReference, xcontext); ExtendedURL extendedURL; try { extendedURL = new ExtendedURL(url, null); } catch (CreateResourceReferenceException e) { throw new SerializeResourceReferenceException( String.format("Failed to serialize user reference [%s] into a [%s]", documentReference, ExtendedURL.class.getName()), e); } return extendedURL; }  @Override ExtendedURL serialize(UserResourceReference resourceReference); }
DocumentUserResourceReferenceSerializer implements ResourceReferenceSerializer<UserResourceReference, ExtendedURL> { @Override public ExtendedURL serialize(UserResourceReference resourceReference) throws SerializeResourceReferenceException { UserReference userReference = resourceReference.getUserReference(); if (!(userReference instanceof DocumentUserReference)) { throw new IllegalArgumentException("The passed user resource reference is not pointing to a wiki Document"); } DocumentReference documentReference = ((DocumentUserReference) userReference).getReference(); XWikiContext xcontext = this.xwikiContextProvider.get(); XWikiURLFactory urlFactory = xcontext.getURLFactory(); URL url = createURL(urlFactory, documentReference, xcontext); ExtendedURL extendedURL; try { extendedURL = new ExtendedURL(url, null); } catch (CreateResourceReferenceException e) { throw new SerializeResourceReferenceException( String.format("Failed to serialize user reference [%s] into a [%s]", documentReference, ExtendedURL.class.getName()), e); } return extendedURL; }  @Override ExtendedURL serialize(UserResourceReference resourceReference);  }