@Test void testCreateTokenUser() { String username = "user"; JobExecution jobExecution = when(mock(JobExecution.class).getUser()).thenReturn(Optional.of(username)).getMock(); UserDetails userDetails = mock(UserDetails.class); when(userDetailsService.loadUserByUsername(username)).thenReturn(userDetails); RunAsUserToken runAsUserToken = mock(RunAsUserToken.class); when(runAsUserTokenFactory.create("Job Execution", userDetails, null)) .thenReturn(runAsUserToken); assertEquals(runAsUserToken, jobExecutorTokenServiceImpl.createToken(jobExecution)); }
@Override public AbstractAuthenticationToken createToken(JobExecution jobExecution) { return jobExecution .getUser() .map(this::createRunAsUsertoken) .orElseGet(SystemSecurityToken::getInstance); }
JobExecutorTokenServiceImpl implements JobExecutorTokenService { @Override public AbstractAuthenticationToken createToken(JobExecution jobExecution) { return jobExecution .getUser() .map(this::createRunAsUsertoken) .orElseGet(SystemSecurityToken::getInstance); } }
JobExecutorTokenServiceImpl implements JobExecutorTokenService { @Override public AbstractAuthenticationToken createToken(JobExecution jobExecution) { return jobExecution .getUser() .map(this::createRunAsUsertoken) .orElseGet(SystemSecurityToken::getInstance); } JobExecutorTokenServiceImpl(
      UserDetailsServiceImpl userDetailsServiceImpl, RunAsUserTokenFactory runAsUserTokenFactory); }
JobExecutorTokenServiceImpl implements JobExecutorTokenService { @Override public AbstractAuthenticationToken createToken(JobExecution jobExecution) { return jobExecution .getUser() .map(this::createRunAsUsertoken) .orElseGet(SystemSecurityToken::getInstance); } JobExecutorTokenServiceImpl(
      UserDetailsServiceImpl userDetailsServiceImpl, RunAsUserTokenFactory runAsUserTokenFactory); @Override AbstractAuthenticationToken createToken(JobExecution jobExecution); }
JobExecutorTokenServiceImpl implements JobExecutorTokenService { @Override public AbstractAuthenticationToken createToken(JobExecution jobExecution) { return jobExecution .getUser() .map(this::createRunAsUsertoken) .orElseGet(SystemSecurityToken::getInstance); } JobExecutorTokenServiceImpl(
      UserDetailsServiceImpl userDetailsServiceImpl, RunAsUserTokenFactory runAsUserTokenFactory); @Override AbstractAuthenticationToken createToken(JobExecution jobExecution);  }