CurrentUserRestController { @RequestMapping(value = CURRENT_USER_URI_PREFIX, method = RequestMethod.GET) @PreAuthorize("isAuthenticated()") @Secured(SecurityFunctions.FN_CURRENT_USER_GET) public UserAuthorizations getCurrentUser() { return currentUserService.getCurrentUser(); }  @RequestMapping(value = CURRENT_USER_URI_PREFIX, method = RequestMethod.GET) @PreAuthorize("isAuthenticated()") @Secured(SecurityFunctions.FN_CURRENT_USER_GET) UserAuthorizations getCurrentUser(); static final String CURRENT_USER_URI_PREFIX; }
@Test public void testGetCurrentUser() throws Exception { Set<NamespaceAuthorization> namespaceAuthorizations = new LinkedHashSet<>(); namespaceAuthorizations.add(new NamespaceAuthorization(NAMESPACE, SUPPORTED_NAMESPACE_PERMISSIONS)); namespaceAuthorizations.add(new NamespaceAuthorization(NAMESPACE_2, SUPPORTED_NAMESPACE_PERMISSIONS)); UserAuthorizations userAuthorizations = new UserAuthorizations(); userAuthorizations.setNamespaceAuthorizations(new ArrayList(namespaceAuthorizations)); when(currentUserService.getCurrentUser()).thenReturn(userAuthorizations); UserAuthorizations resultUserAuthorizations = currentUserRestController.getCurrentUser(); verify(currentUserService).getCurrentUser(); verifyNoMoreInteractions(currentUserService); assertEquals(userAuthorizations, resultUserAuthorizations); }