use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class RestTestUtils method assertTaskStates.
protected static void assertTaskStates(Page<TaskState> expected, RestPage<TaskStateData> actual) {
assertEquals("Number of tasks in page is incorrect", expected.getList().size(), actual.getList().size());
assertEquals("Total number of tasks is incorrect", expected.getSize(), actual.getSize());
for (int i = 0; i < expected.getList().size(); i++) {
TaskState tExpected = expected.getList().get(i);
TaskStateData tActual = actual.getList().get(i);
assertEquals("readableName incorrect", tExpected.getId().getReadableName(), tActual.getName());
assertEquals("tag incorrect", tExpected.getTag(), tActual.getTag());
}
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class SchedulerStateRestPaginationTest method newMockedJob.
private JobState newMockedJob(final String jobIdStr, final int nbTasks) {
JobState mockedJob = mock(JobState.class);
JobId mockedJobId = mock(JobId.class);
List<TaskState> dumbList = new ArrayList<TaskState>(nbTasks);
for (int i = 0; i < nbTasks; i++) {
TaskState mockedTask = mock(TaskState.class);
TaskId mockedTaskId = mock(TaskId.class);
when(mockedTaskId.getReadableName()).thenReturn(generateReadableName(jobIdStr, i, nbTasks));
when(mockedTask.getId()).thenReturn(mockedTaskId);
dumbList.add(mockedTask);
}
when(mockedJobId.value()).thenReturn(jobIdStr);
when(mockedJob.getId()).thenReturn(mockedJobId);
when(mockedJob.getTasksPaginated(0, 50)).thenReturn(new TaskStatesPage(dumbList, nbTasks));
when(mockedJob.getTaskByTagPaginated("", 0, 50)).thenReturn(new TaskStatesPage(dumbList, nbTasks));
return mockedJob;
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class SchedulerStateRestTaskCentricTest method testGetTaskStatesByTagNoSorting.
@Test
public void testGetTaskStatesByTagNoSorting() throws Throwable {
int nbTasksInPage = 50;
int nbTotalTasks = 100;
String jobIdStr = "1";
String tag = "TAG-TEST";
Page<TaskState> expectedPage = RestTestUtils.newMockedTaskStatePage(jobIdStr, tag, nbTasksInPage, nbTotalTasks);
when(mockOfScheduler.getTaskStates(anyString(), anyLong(), anyLong(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyInt(), anyInt(), any(SortSpecifierContainer.class))).thenReturn(expectedPage);
RestPage<TaskStateData> page = restInterface.getTaskStatesByTag(sessionId, tag, 0, 0, false, true, true, true, 0, nbTasksInPage, new SortSpecifierContainer());
RestTestUtils.assertTaskStates(expectedPage, page);
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class JobStateImpl method getTasksByTag.
@Override
public List<TaskState> getTasksByTag(String tag) {
Map<String, TaskStateData> taskStateMap = jobStateData.getTasks();
List<TaskState> taskStateList = new ArrayList<>(taskStateMap.size());
for (TaskStateData ts : taskStateMap.values()) {
String taskTag = ts.getTag();
if (taskTag != null && taskTag.equals(tag)) {
taskStateList.add(DataUtility.taskState(ts));
}
}
return taskStateList;
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class JobStateImpl method getTasks.
@Override
public List<TaskState> getTasks() {
Map<String, TaskStateData> taskStateMap = jobStateData.getTasks();
List<TaskState> taskStateList = new ArrayList<>(taskStateMap.size());
for (TaskStateData ts : taskStateMap.values()) {
taskStateList.add(DataUtility.taskState(ts));
}
return taskStateList;
}
Aggregations