agave-jobs/jobs-core/src/test/java/org/iplantc/service/jobs/managers/monitors/DefaultJobMonitorTest.java
/**
     * Sets up a mock job and tests that the call to the {@link DefaultJobMonitor#monitor()} method updates the status to the {@code expectedJobStatus}.
     * @param executionType the type of job to test
     * @param initialJobStatus the initial job status of the job before running the monitor.
     * @param status the remote job status that should be returned from the remote scheduler
     * @param expectedJobStatus the resulting status that should be had after update.
     */
Sets up a mock job and tests that the call to the  DefaultJobMonitor#monitor() method updates the status to the  expectedJobStatus.
@param executionType the type of job to test
@param initialJobStatus the initial job status of the job before running the monitor.
@param status the remote job status that should be returned from the remote scheduler
@param expectedJobStatus the resulting status that should be had after update.
Sets up a mock job and tests that the call to the DefaultJobMonitor#monitor () method updates the status to the expectedJobStatus . @param executionType the type of job to test @param initialJobStatus the initial job status of the job before running the monitor . @param status the remote job status that should be returned from the remote scheduler @param expectedJobStatus the resulting status that should be had after update .
protected void _genericTestRemoteJobStatusUpdates(ExecutionType executionType, JobStatusType initialJobStatus, RemoteSchedulerJobStatus<?> status, JobStatusType expectedJobStatus) {
        try {
            DefaultJobMonitor monitor = _genericMonitorMockTestHandler(executionType, initialJobStatus, status, expectedJobStatus);
            String initalJobErrorMessage = "Mock job " + monitor.getJob().getUuid() + " " + initialJobStatus.name();
            if (initialJobStatus == expectedJobStatus && status.getMappedJobStatusType() != null) {
                verify(monitor, times(2)).updateJobStatus(eq(initialJobStatus), eq(initalJobErrorMessage));
            } else {
                verify(monitor, times(1)).updateJobStatus(eq(initialJobStatus), eq(initalJobErrorMessage));
                verify(monitor).updateJobStatus(eq(expectedJobStatus), not(eq(initalJobErrorMessage)));
            }
        } catch (SystemUnavailableException e) {
            fail("Mock execution system should not be unavailable", e);
        } catch (RemoteJobMonitorEmptyResponseException e) {
            fail("Mock response should be " + status.toString(), e);
        } catch (RemoteJobMonitorResponseParsingException e) {
            fail("Mock response should not throw a parsing exception", e);
        } catch (RemoteJobMonitoringException e) {
            fail("RemoteJobMonitoringException should not be thrown in mock response. No remote call should be made.", e);
        } catch (ClosedByInterruptException e) {
            fail("No interrupt should occur during test", e);
        } catch (JobException e) {
            fail("Handling an active response of " + status.toString() + " should not throw an exception.", e);
        }
    }
protected void _genericTestRemoteJobStatusUpdates ( ExecutionType executionType , JobStatusType initialJobStatus , RemoteSchedulerJobStatus < ? > status , JobStatusType expectedJobStatus ) { try { DefaultJobMonitor monitor = _genericMonitorMockTestHandler ( executionType , initialJobStatus , status , expectedJobStatus ) ; String initalJobErrorMessage = "Mock job " + monitor . getJob ( ) . getUuid ( ) + " " + initialJobStatus . name ( ) ; if ( initialJobStatus == expectedJobStatus && status . getMappedJobStatusType ( ) != null ) { verify ( monitor , times ( 2 ) ) . updateJobStatus ( eq ( initialJobStatus ) , eq ( initalJobErrorMessage ) ) ; } else { verify ( monitor , times ( 1 ) ) . updateJobStatus ( eq ( initialJobStatus ) , eq ( initalJobErrorMessage ) ) ; verify ( monitor ) . updateJobStatus ( eq ( expectedJobStatus ) , not ( eq ( initalJobErrorMessage ) ) ) ; } } catch ( SystemUnavailableException e ) { fail ( "Mock execution system should not be unavailable" , e ) ; } catch ( RemoteJobMonitorEmptyResponseException e ) { fail ( "Mock response should be " + status . toString ( ) , e ) ; } catch ( RemoteJobMonitorResponseParsingException e ) { fail ( "Mock response should not throw a parsing exception" , e ) ; } catch ( RemoteJobMonitoringException e ) { fail ( "RemoteJobMonitoringException should not be thrown in mock response. No remote call should be made." , e ) ; } catch ( ClosedByInterruptException e ) { fail ( "No interrupt should occur during test" , e ) ; } catch ( JobException e ) { fail ( "Handling an active response of " + status . toString ( ) + " should not throw an exception." , e ) ; } }
Sets up a mock job and tests that the call to the {@link DefaultJobMonitor#monitor()} method updates the status to the {@code expectedJobStatus}.
Sets up a mock job and tests that the call to the { @link DefaultJobMonitor#monitor () } method updates the status to the { @code expectedJobStatus } .
//            JobStatusType initialJobStatus = JobStatusType.QUEUED; // job should be "touched" with the original status and error message when the method is first called // job should be "touched" with the original status and error message when the method is first called // check that update status is called with the expected status for this test