Search in sources :

Example 6 with RestPage

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage in project scheduling by ow2-proactive.

the class SchedulerStateRestPaginationTest method testGetJobTasksIdsPaginated.

@Test
public void testGetJobTasksIdsPaginated() throws Throwable {
    JobState job = newMockedJob(jobIdStr, nbTasks);
    when(mockOfScheduler.getJobState(jobIdStr)).thenReturn(job);
    RestPage<String> page = restInterface.getTasksNamesPaginated(sessionId, jobIdStr, 0, nbTasks);
    assertTasks(nbTasks, jobIdStr, page);
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState) Test(org.junit.Test)

Example 7 with RestPage

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage in project scheduling by ow2-proactive.

the class SchedulerStateRestTaskCentricTest method testGetTaskStatesByTagSortByJobIdAsc.

@Test
public void testGetTaskStatesByTagSortByJobIdAsc() throws Throwable {
    int nbTasksInPage = 6;
    int nbTotalTasks = 6;
    ArrayList<String> jobIds = new ArrayList<String>(Arrays.asList("1", "8", "4", "4", "6", "2"));
    String tag = "TAG-TEST";
    Page<TaskState> expectedPage = RestTestUtils.newMockedTaskStatePage(jobIds, 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(".jobData.id,ascending"));
    RestTestUtils.assertTaskStates(expectedPage, page);
}
Also used : SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) ArrayList(java.util.ArrayList) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Test(org.junit.Test)

Example 8 with RestPage

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage in project scheduling by ow2-proactive.

the class SchedulerStateRestTaskCentricTest method testGetJobTasksIdsByTagPaginated.

@Test
public void testGetJobTasksIdsByTagPaginated() throws Throwable {
    int nbTasks = 50;
    String jobIdStr = "1";
    JobState job = RestTestUtils.newMockedJob(jobIdStr, "", nbTasks);
    when(mockOfScheduler.getJobState(jobIdStr)).thenReturn(job);
    RestPage<String> page = restInterface.getTasksNamesPaginated(sessionId, jobIdStr, 0, nbTasks);
    RestTestUtils.assertTasks(nbTasks, jobIdStr, page);
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState) Test(org.junit.Test)

Example 9 with RestPage

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage in project scheduling by ow2-proactive.

the class SchedulerStateRestTaskCentricTest method testGetJobTasksIdsPaginated.

@Test
public void testGetJobTasksIdsPaginated() throws Throwable {
    int nbTasks = 50;
    String jobIdStr = "1";
    JobState job = RestTestUtils.newMockedJob(jobIdStr, "", nbTasks);
    when(mockOfScheduler.getJobState(jobIdStr)).thenReturn(job);
    RestPage<String> page = restInterface.getTasksNamesPaginated(sessionId, jobIdStr, 0, nbTasks);
    RestTestUtils.assertTasks(nbTasks, jobIdStr, page);
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState) Test(org.junit.Test)

Example 10 with RestPage

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage in project scheduling by ow2-proactive.

the class SchedulerStateRestTaskCentricTest method testGetTaskStatesByTagSortByTaskIdDesc.

@Test
public void testGetTaskStatesByTagSortByTaskIdDesc() 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(".id.taskId,descending"));
    RestTestUtils.assertTaskStates(expectedPage, page);
    // let's check only the first two as the string comparison is not valid
    // after that case : "JOB-1-TASK-1/50".compareTo("JOB-1-TASK-10/50")
    List<TaskStateData> tasks = page.getList();
    TaskStateData previousTask = tasks.get(0);
    TaskStateData currentTask = tasks.get(1);
    assertTrue(previousTask.getName().compareTo(currentTask.getName()) < 0);
}
Also used : SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Test(org.junit.Test)

Aggregations

RestPage (org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage)15 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)12 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)12 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)12 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)12 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)10 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)10 JobState (org.ow2.proactive.scheduler.common.job.JobState)10 TaskStateData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData)10 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)9 GET (javax.ws.rs.GET)8 Path (javax.ws.rs.Path)8 Produces (javax.ws.rs.Produces)8 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)6 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)6 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)6 SortSpecifierContainer (org.ow2.proactive.scheduler.common.SortSpecifierContainer)5 GZIP (org.jboss.resteasy.annotations.GZIP)4 Matchers.containsString (org.hamcrest.Matchers.containsString)3