### Question:
CurrentUserReferenceResolver implements UserReferenceResolver<CurrentUserReference> { @Override public UserReference resolve(CurrentUserReference unused, Object... parameters) { UserReference userReference; DocumentReference currentDocumentReference = getXWikiContext().getUserReference(); if (currentDocumentReference == null) { userReference = GuestUserReference.INSTANCE; } else { userReference = this.documentReferenceUserReferenceResolver.resolve(currentDocumentReference); } return userReference; }  @Override UserReference resolve(CurrentUserReference unused, Object... parameters);  }### Answer:
@Test void resolve() { DocumentReference reference = new DocumentReference("wiki", "space", "currentuser"); XWikiContext xcontext = mock(XWikiContext.class); when(xcontext.getUserReference()).thenReturn(reference); when(this.contextProvider.get()).thenReturn(xcontext); UserReference currentUserReference = mock(UserReference.class); when(this.documentReferenceUserReferenceResolver.resolve(reference)).thenReturn(currentUserReference); UserReference userReference = this.resolver.resolve(null); assertSame(currentUserReference, userReference); }
@Test void resolveWhenNoCurrentUser() { XWikiContext xcontext = mock(XWikiContext.class); when(xcontext.getUserReference()).thenReturn(null); when(this.contextProvider.get()).thenReturn(xcontext); UserReference userReference = this.resolver.resolve(null); assertSame(GuestUserReference.INSTANCE, userReference); }