use of org.ow2.proactive.utils.Criteria in project scheduling by ow2-proactive.
the class SchedulerDBManagerTest method assertTaskStatePage.
private void assertTaskStatePage(Page<TaskState> page, TaskFilterCriteria criterias) {
int nbTaskStates = page.getList().size();
for (TaskState taskState : page.getList()) {
String tag = criterias.getTag();
if (tag != null)
assertEquals("Tag is incorrect", tag, taskState.getTag());
// from
long from = criterias.getFrom();
if (from != 0)
assertEquals("startTime is incorrect", from, taskState.getStartTime());
// to
long to = criterias.getTo();
if (to != 0)
assertEquals("finishedTime is incorrect", to, taskState.getFinishedTime());
// pagination
int pageSize = criterias.getLimit() - criterias.getOffset();
if (pageSize > 0) {
assertTrue("Page size is incorrect", pageSize >= nbTaskStates);
}
// user
String expectedUser = criterias.getUser();
String actualUser = taskState.getTaskInfo().getJobInfo().getJobOwner();
if (expectedUser != null && "".compareTo(expectedUser) != 0) {
assertEquals("user is incorrect", expectedUser, actualUser);
}
// the corresponding criteria should be true
switch(taskState.getStatus()) {
case SUBMITTED:
case PENDING:
case NOT_STARTED:
assertTrue("Task status is incorrect", criterias.isPending());
break;
case PAUSED:
case RUNNING:
case WAITING_ON_ERROR:
case WAITING_ON_FAILURE:
assertTrue("Task status is incorrect", criterias.isRunning());
break;
case FAILED:
case NOT_RESTARTED:
case ABORTED:
case FAULTY:
case FINISHED:
case SKIPPED:
assertTrue("Task status is incorrect", criterias.isFinished());
break;
default:
fail("Incoherent task status");
}
}
}
Aggregations