@Test
public void testEjbTimerSchedulerTestOnTimerLoop() {

    
    Collection<Timer> timers = new ArrayList<>();
    
    TimerService timerService = mock(TimerService.class);
    when(timerService.getTimers()).thenReturn(timers);
    
    TimerJobInstance timerJobInstance1 = mock(TimerJobInstance.class);
    EjbGlobalJobHandle ejbGlobalJobHandle1 = new EjbGlobalJobHandle(1L, "test job", "test");
    ejbGlobalJobHandle1.setTimerJobInstance(timerJobInstance1);
    when(timerJobInstance1.getJobHandle()).thenReturn(ejbGlobalJobHandle1);
    
    Timer timer1 = mock(Timer.class);
    when(timer1.getInfo()).thenReturn(new EjbTimerJob(timerJobInstance1));
    
    timers.add(timer1);
    
    EJBTimerScheduler scheduler = new EJBTimerScheduler();
    scheduler.timerService = timerService;
    // first call to go over list of timers should not add anything to the cache as there is no matching timers
    TimerJobInstance jobInstance = scheduler.getTimerByName("not existing");
    assertNull(jobInstance);
    // second call should result in exact same behavior
    jobInstance = scheduler.getTimerByName("not existing");
    assertNull(jobInstance);
    // calling for existing timer should return it as it matches and thus also add it to cache
    jobInstance = scheduler.getTimerByName("test job");
    assertNotNull(jobInstance);
}