private LoadCountingListener loadCountListener;
@Test
public void testScenario() {
FullTextSessionBuilder fullTextSessionBuilder = createSearchFactory();
try {
//check no operations are done:
assertOperationsPerformed( 0 );
assertLocationsLoaded( 0 );
//create initial data
initializeData( fullTextSessionBuilder );
//this should have triggered 5 indexing operations, no entity loadings:
assertOperationsPerformed( 5 );
assertLocationsLoaded( 0 );
FullTextSession fullTextSession = fullTextSessionBuilder.openFullTextSession();
//now check index state:
assertFoundLocations( fullTextSession, "floor", 5 );
assertFoundLocations( fullTextSession, "airport", 0 );
fullTextSession.clear();
try {
//we add a new Location to the group:
addLocationToGroupCollection( fullTextSession );
//NOTHING else should be loaded, there was no need to reindex unrelated Locations!
assertLocationsLoaded( 0 );
//of course the new Location should have been indexed:
assertOperationsPerformed( 1 );
fullTextSession.clear();
//so now we have 6 Locations in the index, in LocationGroup "floor":
assertFoundLocations( fullTextSession, "floor", 6 );
assertFoundLocations( fullTextSession, "airport", 0 );
//changing the locationGroup name to Airport:
updateLocationGroupName( fullTextSession );
fullTextSession.clear();
//check index functionality:
assertFoundLocations( fullTextSession, "floor", 0 );
assertFoundLocations( fullTextSession, "airport", 6 );
//six locations have been loaded for re-indexing:
assertLocationsLoaded( 6 );
//and six update operations have been sent to the backend:
assertOperationsPerformed( 6 );
}
finally {
fullTextSession.close();
}
}
finally {
fullTextSessionBuilder.close();
}
}