Search in sources :

Example 1 with JpaJob

use of org.opencastproject.job.jpa.JpaJob in project opencast by opencast.

the class DispatchableComparatorTest method testLessThanByDateCreated.

@Test
public void testLessThanByDateCreated() {
    // Test first less than second: same job type, same status, different date
    JpaJob j5 = createJob(5L, "non-wf", Status.RESTART, dtPlusOneHour);
    assertEquals("Jobs with earlier created date should be less than jobs with later created date", -1, dispatchableComparator.compare(j1, j5));
}
Also used : JpaJob(org.opencastproject.job.jpa.JpaJob) Test(org.junit.Test)

Example 2 with JpaJob

use of org.opencastproject.job.jpa.JpaJob in project opencast by opencast.

the class DispatchableComparatorTest method testEquals.

@Test
public void testEquals() {
    // Test equals: same job type, same status, same date
    JpaJob j2 = createJob(2L, "non-wf", Status.RESTART, dt);
    assertEquals("Two jobs with equal type, status and creation date must be considered equal", 0, dispatchableComparator.compare(j1, j2));
}
Also used : JpaJob(org.opencastproject.job.jpa.JpaJob) Test(org.junit.Test)

Example 3 with JpaJob

use of org.opencastproject.job.jpa.JpaJob in project opencast by opencast.

the class DispatchableComparatorTest method testLessThanByJobType.

@Test
public void testLessThanByJobType() {
    // Test first less than second: different job type, same status, same date
    JpaJob j4 = createJob(4L, ServiceRegistryJpaImpl.TYPE_WORKFLOW, Status.RESTART, dt);
    assertEquals("Non-workflow jobs should be less than workflow jobs", -1, dispatchableComparator.compare(j1, j4));
}
Also used : JpaJob(org.opencastproject.job.jpa.JpaJob) Test(org.junit.Test)

Example 4 with JpaJob

use of org.opencastproject.job.jpa.JpaJob in project opencast by opencast.

the class DispatchableComparatorTest method testGreaterThanByJobStatus.

@Test
public void testGreaterThanByJobStatus() {
    // Test first greater than second: same job type, different status, same date
    JpaJob j3 = createJob(3L, "non-wf", Status.QUEUED, dt);
    assertEquals("Jobs with RESTART status should be less than those with QUEUED status", 1, dispatchableComparator.compare(j3, j1));
}
Also used : JpaJob(org.opencastproject.job.jpa.JpaJob) Test(org.junit.Test)

Example 5 with JpaJob

use of org.opencastproject.job.jpa.JpaJob in project opencast by opencast.

the class DispatchableComparatorTest method testLessThanByJobStatus.

@Test
public void testLessThanByJobStatus() {
    // Test first less than second: same job type, different status, same date
    JpaJob j3 = createJob(3L, "non-wf", Status.QUEUED, dt);
    assertEquals("Jobs with RESTART status should be less than those with QUEUED status", -1, dispatchableComparator.compare(j1, j3));
}
Also used : JpaJob(org.opencastproject.job.jpa.JpaJob) Test(org.junit.Test)

Aggregations

JpaJob (org.opencastproject.job.jpa.JpaJob)29 NotFoundException (org.opencastproject.util.NotFoundException)13 PersistenceException (javax.persistence.PersistenceException)11 ServiceRegistryException (org.opencastproject.serviceregistry.api.ServiceRegistryException)11 EntityManager (javax.persistence.EntityManager)10 NoResultException (javax.persistence.NoResultException)10 RollbackException (javax.persistence.RollbackException)10 URISyntaxException (java.net.URISyntaxException)9 Test (org.junit.Test)9 TrustedHttpClientException (org.opencastproject.security.api.TrustedHttpClientException)9 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)9 ConfigurationException (org.osgi.service.cm.ConfigurationException)9 Job (org.opencastproject.job.api.Job)7 ArrayList (java.util.ArrayList)6 EntityTransaction (javax.persistence.EntityTransaction)6 JpaJob.fnToJob (org.opencastproject.job.jpa.JpaJob.fnToJob)6 HttpStatus (org.apache.http.HttpStatus)4 Status (org.opencastproject.job.api.Job.Status)4 Date (java.util.Date)3 Query (javax.persistence.Query)2