@Test void testCreateLocaleUser() { String username = "MyUsername"; JobExecution jobExecution = when(mock(JobExecution.class).getUser()).thenReturn(Optional.of(username)).getMock(); Locale locale = Locale.getDefault(); when(userLocaleResolver.resolveLocale(username)).thenReturn(locale); assertEquals(locale, jobExecutorLocaleServiceImpl.createLocale(jobExecution)); }
@Override public Locale createLocale(JobExecution jobExecution) { return jobExecution .getUser() .map(userLocaleResolver::resolveLocale) .orElseGet(Locale::getDefault); }
JobExecutorLocaleServiceImpl implements JobExecutorLocaleService { @Override public Locale createLocale(JobExecution jobExecution) { return jobExecution .getUser() .map(userLocaleResolver::resolveLocale) .orElseGet(Locale::getDefault); } }
JobExecutorLocaleServiceImpl implements JobExecutorLocaleService { @Override public Locale createLocale(JobExecution jobExecution) { return jobExecution .getUser() .map(userLocaleResolver::resolveLocale) .orElseGet(Locale::getDefault); } JobExecutorLocaleServiceImpl(UserLocaleResolver userLocaleResolver); }
JobExecutorLocaleServiceImpl implements JobExecutorLocaleService { @Override public Locale createLocale(JobExecution jobExecution) { return jobExecution .getUser() .map(userLocaleResolver::resolveLocale) .orElseGet(Locale::getDefault); } JobExecutorLocaleServiceImpl(UserLocaleResolver userLocaleResolver); @Override Locale createLocale(JobExecution jobExecution); }
JobExecutorLocaleServiceImpl implements JobExecutorLocaleService { @Override public Locale createLocale(JobExecution jobExecution) { return jobExecution .getUser() .map(userLocaleResolver::resolveLocale) .orElseGet(Locale::getDefault); } JobExecutorLocaleServiceImpl(UserLocaleResolver userLocaleResolver); @Override Locale createLocale(JobExecution jobExecution);  }