@Test
public void test1() {
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.drools.grid" );
UuidJobHandle handle = new UuidJobHandle();
ScheduledJob sj1 = new ScheduledJob( handle,
new MockJob(),
new MockJobContext( "xxx" ),
new MockTrigger( new Date( 1000 ) ) );
ScheduledJob sj2 = new ScheduledJob( handle,
new MockJob(),
new MockJobContext( "xxx" ),
new MockTrigger( new Date( 1000 ) ) );
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
em.persist( sj1 );
em.getTransaction().commit();
em.close();
em = emf.createEntityManager();
sj1 = em.find( ScheduledJob.class,
sj1.getId() );
assertEquals( sj2.getId(),
sj1.getId() );
assertEquals( sj2.getJob().getClass(),
sj1.getJob().getClass() );
assertEquals( "xxx",
((MockJobContext) sj1.getJobContext()).getText() );
assertEquals( new Date( 1000 ),
((MockTrigger) sj1.getTrigger()).hasNextFireTime() );