Search in sources :

Example 1 with RunToLineScheduler

use of org.absmodels.abs.plugin.debug.scheduling.RunToLineScheduler in project abstools by abstools.

the class SchedulingTest method testRunToLineScheduler.

@Test
public void testRunToLineScheduler() {
    final SchedulingStrategy ss = mock(SchedulingStrategy.class);
    doCallRealMethod().when(ss).setBaseScheduler(any(TotalScheduler.class));
    doCallRealMethod().when(ss).setCurrentScheduler(any(TotalScheduler.class));
    doCallRealMethod().when(ss).doSingleStep();
    TotalScheduler ts = mock(TotalScheduler.class);
    ScheduleAction scheduleAction = mock(ScheduleAction.class, Mockito.RETURNS_DEEP_STUBS);
    when(ts.choose(any(ScheduleOptions.class))).thenReturn(scheduleAction);
    TaskInfo taskInfo = mock(TaskInfo.class);
    when(ts.schedule(any(TaskScheduler.class), any(List.class))).thenReturn(taskInfo);
    ss.setBaseScheduler(ts);
    final int line = new Random().nextInt(1000);
    final String fileName = "filename";
    abs.backend.java.debugging.TaskInfo ti = mock(abs.backend.java.debugging.TaskInfo.class);
    when(ti.getCurrentFile()).thenReturn("filename");
    when(ti.getCurrentLine()).thenReturn(line - 5).thenReturn(line - 4).thenReturn(line - 3).thenReturn(line - 2).thenReturn(line - 1).thenReturn(line);
    ss.steppedTask = ti;
    RunToLineScheduler rtls = new RunToLineScheduler(ss, fileName, line);
    ss.setCurrentScheduler(rtls);
    ScheduleOptions scheduleOptions = mock(ScheduleOptions.class, Mockito.RETURNS_DEEP_STUBS);
    for (int i = 0; i < 6; i++) {
        ss.curScheduler.choose(scheduleOptions);
    }
    verify(ss).awaitGUIAction(any(ScheduleOptions.class));
}
Also used : TotalScheduler(org.absmodels.abs.plugin.debug.scheduling.TotalScheduler) TaskScheduler(abs.backend.java.scheduling.TaskScheduler) TaskInfo(abs.backend.java.scheduling.SimpleTaskScheduler.TaskInfo) SchedulingStrategy(org.absmodels.abs.plugin.debug.scheduling.SchedulingStrategy) ScheduleOptions(abs.backend.java.scheduling.ScheduleOptions) RunToLineScheduler(org.absmodels.abs.plugin.debug.scheduling.RunToLineScheduler) ScheduleAction(abs.backend.java.scheduling.ScheduleAction) Random(java.util.Random) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

ScheduleAction (abs.backend.java.scheduling.ScheduleAction)1 ScheduleOptions (abs.backend.java.scheduling.ScheduleOptions)1 TaskInfo (abs.backend.java.scheduling.SimpleTaskScheduler.TaskInfo)1 TaskScheduler (abs.backend.java.scheduling.TaskScheduler)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Random (java.util.Random)1 RunToLineScheduler (org.absmodels.abs.plugin.debug.scheduling.RunToLineScheduler)1 SchedulingStrategy (org.absmodels.abs.plugin.debug.scheduling.SchedulingStrategy)1 TotalScheduler (org.absmodels.abs.plugin.debug.scheduling.TotalScheduler)1 Test (org.junit.Test)1