*/
@SuppressWarnings( "unchecked" )
public void testAddWorkGetReplacedByDeleteWork() throws Exception {
FullTextSession fullTextSession = org.hibernate.search.Search.getFullTextSession( openSession() );
SearchFactoryImpl searchFactory = ( SearchFactoryImpl ) fullTextSession.getSearchFactory();
DocumentBuilderIndexedEntity builder = searchFactory.getDocumentBuilderIndexedEntity( SpecialPerson.class );
// create test entity
SpecialPerson person = new SpecialPerson();
person.setName( "Joe Smith" );
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress( "foo@foobar.com" );
emailAddress.setDefaultAddress(true);
person.addEmailAddress( emailAddress );
List<LuceneWork> queue = new ArrayList<LuceneWork>();
builder.addWorkToQueue( SpecialPerson.class, person, 1, WorkType.ADD, queue, searchFactory );
assertEquals("There should only be one job in the queue", 1, queue.size());
assertTrue("Wrong job type", queue.get(0) instanceof AddLuceneWork );
builder.addWorkToQueue( SpecialPerson.class, person, 1, WorkType.DELETE, queue, searchFactory );
assertEquals("There should only be one job in the queue", 1, queue.size());
assertTrue("Wrong job type. Add job should have been replaced by delete.", queue.get(0) instanceof DeleteLuceneWork );
fullTextSession.close();