### Question:
SecurityHelper { public String getCurrentLogin() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { logger.debug("Current user is not authenticated."); throw new AccessDeniedException("User is not authenticated."); } return authentication.getName(); }  String getCurrentRealm(); String getCurrentLogin();  }### Answer:
@Test void getCurrentLogin() { SecurityContextHolder.getContext().setAuthentication( new UsernamePasswordAuthenticationToken(LOGIN, null, new ArrayList<>())); assertNotNull(SecurityContextHolder.getContext().getAuthentication()); assertEquals(LOGIN, securityHelper.getCurrentLogin()); }
@Test void getCurrentLoginException() { SecurityContextHolder.clearContext(); assertNull(SecurityContextHolder.getContext().getAuthentication()); assertThrows(AccessDeniedException.class, () -> securityHelper.getCurrentLogin()); }