@Test @WithMockUser void testRunAsSystemRunnableAsSystem() { assertTrue(getAuthentication() instanceof UsernamePasswordAuthenticationToken); assertTrue(runAsSystem(this::getAuthentication) instanceof SystemSecurityToken); assertTrue(getAuthentication() instanceof UsernamePasswordAuthenticationToken); }
public static void runAsSystem(Runnable runnable) { runAsSystem( () -> { runnable.run(); return null; }); }
RunAsSystemAspect { public static void runAsSystem(Runnable runnable) { runAsSystem( () -> { runnable.run(); return null; }); } }
RunAsSystemAspect { public static void runAsSystem(Runnable runnable) { runAsSystem( () -> { runnable.run(); return null; }); }  }
RunAsSystemAspect { public static void runAsSystem(Runnable runnable) { runAsSystem( () -> { runnable.run(); return null; }); }  @SuppressWarnings("java:S00112") // generic exceptions should never be thrown @Around("@annotation(RunAsSystem)") Object aroundAdvice(ProceedingJoinPoint joinPoint); static void runAsSystem(Runnable runnable); static T runAsSystem(RunnableAsSystem<T, X> runnable); }
RunAsSystemAspect { public static void runAsSystem(Runnable runnable) { runAsSystem( () -> { runnable.run(); return null; }); }  @SuppressWarnings("java:S00112") // generic exceptions should never be thrown @Around("@annotation(RunAsSystem)") Object aroundAdvice(ProceedingJoinPoint joinPoint); static void runAsSystem(Runnable runnable); static T runAsSystem(RunnableAsSystem<T, X> runnable);  }