@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();
    }
  }
  /**
   * Initialize the test data.
   *
   * @param fulltextSessionBuilder
   */
  private void initializeData(FullTextSessionBuilder fulltextSessionBuilder) {
    FullTextSession fullTextSession = fulltextSessionBuilder.openFullTextSession();
    try {
      final Transaction transaction = fullTextSession.beginTransaction();

      LocationGroup group = new LocationGroup("Floor 1");
      fullTextSession.persist(group);

      for (int i = 0; i < 5; i++) {
        Location location = new Location("Room 10" + i);
        fullTextSession.persist(location);

        group.getLocations().add(location);
        location.setLocationGroup(group);
        fullTextSession.merge(group);
      }
      transaction.commit();
    } finally {
      fullTextSession.close();
    }
  }