Search in sources :

Example 1 with BlockStatusProxy

use of org.pentaho.platform.web.http.api.resources.proxies.BlockStatusProxy in project pentaho-platform by pentaho.

the class SchedulerResourceTest method testGetBlockStatus.

@Test
public void testGetBlockStatus() throws Exception {
    JobScheduleRequest mockJobScheduleRequest = mock(JobScheduleRequest.class);
    BlockStatusProxy mockBlockStatusProxy = mock(BlockStatusProxy.class);
    doReturn(mockBlockStatusProxy).when(schedulerResource.schedulerService).getBlockStatus(mockJobScheduleRequest);
    Response mockResponse = mock(Response.class);
    doReturn(mockResponse).when(schedulerResource).buildOkResponse(mockBlockStatusProxy);
    Response testResponse = schedulerResource.getBlockStatus(mockJobScheduleRequest);
    assertEquals(mockResponse, testResponse);
    verify(schedulerResource.schedulerService, times(1)).getBlockStatus(mockJobScheduleRequest);
    verify(schedulerResource, times(1)).buildOkResponse(mockBlockStatusProxy);
}
Also used : Response(javax.ws.rs.core.Response) BlockStatusProxy(org.pentaho.platform.web.http.api.resources.proxies.BlockStatusProxy) Test(org.junit.Test)

Example 2 with BlockStatusProxy

use of org.pentaho.platform.web.http.api.resources.proxies.BlockStatusProxy in project pentaho-platform by pentaho.

the class SchedulerServiceTest method testGetBlockStatus.

@Test
public void testGetBlockStatus() throws Exception {
    JobScheduleRequest jobScheduleRequestMock = mock(JobScheduleRequest.class);
    BlockStatusProxy blockStatusProxyMock = mock(BlockStatusProxy.class);
    IJobTrigger jobTrigger = mock(IJobTrigger.class);
    doReturn(jobTrigger).when(schedulerService).convertScheduleRequestToJobTrigger(jobScheduleRequestMock);
    doReturn(true).when(schedulerService.blockoutManager).isPartiallyBlocked(jobTrigger);
    doReturn(true).when(schedulerService.blockoutManager).willFire(jobTrigger);
    doReturn(blockStatusProxyMock).when(schedulerService).getBlockStatusProxy(anyBoolean(), anyBoolean());
    // Test 1
    BlockStatusProxy blockStatusProxy = schedulerService.getBlockStatus(jobScheduleRequestMock);
    assertNotNull(blockStatusProxy);
    // Test 2
    doReturn(false).when(schedulerService.blockoutManager).isPartiallyBlocked(jobTrigger);
    blockStatusProxy = schedulerService.getBlockStatus(jobScheduleRequestMock);
    assertNotNull(blockStatusProxy);
    verify(schedulerService, times(2)).convertScheduleRequestToJobTrigger(jobScheduleRequestMock);
    verify(schedulerService.blockoutManager, times(2)).isPartiallyBlocked(jobTrigger);
    verify(schedulerService, times(2)).getBlockStatusProxy(anyBoolean(), anyBoolean());
    verify(schedulerService.blockoutManager, times(1)).willFire(jobTrigger);
}
Also used : BlockStatusProxy(org.pentaho.platform.web.http.api.resources.proxies.BlockStatusProxy) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) JobScheduleRequest(org.pentaho.platform.web.http.api.resources.JobScheduleRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 BlockStatusProxy (org.pentaho.platform.web.http.api.resources.proxies.BlockStatusProxy)2 Response (javax.ws.rs.core.Response)1 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)1 JobScheduleRequest (org.pentaho.platform.web.http.api.resources.JobScheduleRequest)1