agave-jobs/jobs-core/src/test/java/org/iplantc/service/jobs/queue/SubmissionWatchTest.java
/**
     * Generic submission test used by all the methods testing job submission is some
     * form or fashion.
     * 
     * @param job
     * @param message
     * @param shouldThrowException
     */
Generic submission test used by all the methods testing job submission is some
form or fashion.


Generic submission test used by all the methods testing job submission is some form or fashion .
@Override
    protected Job genericRemoteSubmissionTestCase(Job job, JobStatusType expectedStatus, String message, boolean shouldThrowException) 
    {
        boolean actuallyThrewException = false;
        String exceptionMsg = message;
        SubmissionWatch submissionWatch = new SubmissionWatch();
        try
        {
JobDao.persist(job);
            submissionWatch.setJob(job);
            submissionWatch.doExecute();
            job = submissionWatch.getJob();
            Assert.assertEquals(job.getStatus(), expectedStatus,
                    "Job status did not match " + expectedStatus + " after submission");
            if (expectedStatus == JobStatusType.RUNNING || 
                    expectedStatus == JobStatusType.QUEUED ) {
                Assert.assertNotNull(job.getLocalJobId(),
                        "Local job id was not obtained during submission");
                Assert.assertTrue(job.getRetries() == 0,
                        "Job should only submit once when it does not fail during submission");
                Assert.assertNotNull(job.getSubmitTime(),
                    "Job submit time was not updated during job submission");
            } else {
                Assert.assertNull(job.getLocalJobId(),
                        "Local job id should be null if submission fails");
                Assert.assertNull(job.getSubmitTime(),
                    "Job submit time should not be updated if the job did not submit.");
            }
        }
        catch (Exception e)
        {
            actuallyThrewException = true;
            exceptionMsg = "Error placing job into queue on " + job.getSystem() + ": " + message;
            if (actuallyThrewException != shouldThrowException) e.printStackTrace();
            job = submissionWatch.getJob();
        }
        Assert.assertTrue(actuallyThrewException == shouldThrowException, exceptionMsg);
        return job;
    }
@ Override protected Job genericRemoteSubmissionTestCase ( Job job , JobStatusType expectedStatus , String message , boolean shouldThrowException ) { boolean actuallyThrewException = false ; String exceptionMsg = message ; SubmissionWatch submissionWatch = new SubmissionWatch ( ) ; try { submissionWatch . setJob ( job ) ; submissionWatch . doExecute ( ) ; job = submissionWatch . getJob ( ) ; Assert . assertEquals ( job . getStatus ( ) , expectedStatus , "Job status did not match " + expectedStatus + " after submission" ) ; if ( expectedStatus == JobStatusType . RUNNING || expectedStatus == JobStatusType . QUEUED ) { Assert . assertNotNull ( job . getLocalJobId ( ) , "Local job id was not obtained during submission" ) ; Assert . assertTrue ( job . getRetries ( ) == 0 , "Job should only submit once when it does not fail during submission" ) ; Assert . assertNotNull ( job . getSubmitTime ( ) , "Job submit time was not updated during job submission" ) ; } else { Assert . assertNull ( job . getLocalJobId ( ) , "Local job id should be null if submission fails" ) ; Assert . assertNull ( job . getSubmitTime ( ) , "Job submit time should not be updated if the job did not submit." ) ; } } catch ( Exception e ) { actuallyThrewException = true ; exceptionMsg = "Error placing job into queue on " + job . getSystem ( ) + ": " + message ; if ( actuallyThrewException != shouldThrowException ) e . printStackTrace ( ) ; job = submissionWatch . getJob ( ) ; } Assert . assertTrue ( actuallyThrewException == shouldThrowException , exceptionMsg ) ; return job ; }
Generic submission test used by all the methods testing job submission is some
 form or fashion.
Generic submission test used by all the methods testing job submission is some form or fashion .
//          job.setArchivePath(job.getOwner() + "/archive/jobs/job-" + job.getUuid() + "-" + Slug.toSlug(job.getName())); //           //          JobDao.persist(job); //           //        System.out.println(" exception thrown?  expected " + shouldThrowException + " actual " + actuallyThrewException);