@Test public void testReindexModelsFromClassAndEntityName() { final int fetchSize = 8; final int flushSize = 2; context.checking(new Expectations() { { one(fullTextSessionMock).purgeAll(SearchIndexManagerTest.class); one(fullTextSessionMock).flushToIndexes(); one(fullTextSessionMock).getSearchFactory(); will(returnValue(searchFactoryMock)); one(searchFactoryMock).optimize(SearchIndexManagerTest.class); one(fullTextSessionMock).flushToIndexes(); one(fullTextSessionMock).createQuery("FROM HeyNow"); will(returnValue(queryMock)); will(returnValue(queryMock)); one(queryMock).setCacheMode(CacheMode.IGNORE); will(returnValue(queryMock)); one(queryMock).setFetchSize(fetchSize); will(returnValue(queryMock)); one(queryMock).scroll(ScrollMode.FORWARD_ONLY); will(returnValue(scrollMock)); Object entity1 = new Object(); Object entity2 = new Object(); Object entity3 = new Object(); one(scrollMock).next(); will(returnValue(true)); one(scrollMock).get(0); will(returnValue(entity1)); one(fullTextSessionMock).index(entity1); one(scrollMock).next(); will(returnValue(true)); one(scrollMock).get(0); will(returnValue(entity2)); one(fullTextSessionMock).index(entity2); one(fullTextSessionMock).flushToIndexes(); one(fullTextSessionMock).clear(); one(scrollMock).next(); will(returnValue(true)); one(scrollMock).get(0); will(returnValue(entity3)); one(fullTextSessionMock).index(entity3); one(scrollMock).next(); will(returnValue(false)); one(fullTextSessionMock).clear(); one(fullTextSessionMock).flushToIndexes(); one(fullTextSessionMock).getSearchFactory(); will(returnValue(searchFactoryMock)); one(searchFactoryMock).optimize(SearchIndexManagerTest.class); } }); SearchIndexManager indexer = new SearchIndexManager(fetchSize, flushSize); indexer.reindexEntities(SearchIndexManagerTest.class, "HeyNow", fullTextSessionMock); context.assertIsSatisfied(); }
@SuppressWarnings("unchecked") public void reindexEntities(final Class entityClass, final FullTextSession search) { log.info("reindexEntities(" + entityClass.toString() + ")"); String entityName = entityClass.toString().substring(entityClass.toString().lastIndexOf('.') + 1); reindexEntities(entityClass, entityName, search); }
SearchIndexManager { @SuppressWarnings("unchecked") public void reindexEntities(final Class entityClass, final FullTextSession search) { log.info("reindexEntities(" + entityClass.toString() + ")"); String entityName = entityClass.toString().substring(entityClass.toString().lastIndexOf('.') + 1); reindexEntities(entityClass, entityName, search); } }
SearchIndexManager { @SuppressWarnings("unchecked") public void reindexEntities(final Class entityClass, final FullTextSession search) { log.info("reindexEntities(" + entityClass.toString() + ")"); String entityName = entityClass.toString().substring(entityClass.toString().lastIndexOf('.') + 1); reindexEntities(entityClass, entityName, search); } SearchIndexManager(final Integer inFetchBatchSize, final Integer inFlushBatchSize); }
SearchIndexManager { @SuppressWarnings("unchecked") public void reindexEntities(final Class entityClass, final FullTextSession search) { log.info("reindexEntities(" + entityClass.toString() + ")"); String entityName = entityClass.toString().substring(entityClass.toString().lastIndexOf('.') + 1); reindexEntities(entityClass, entityName, search); } SearchIndexManager(final Integer inFetchBatchSize, final Integer inFlushBatchSize); @SuppressWarnings("unchecked") void reindexEntities(final Class entityClass, final FullTextSession search); @SuppressWarnings("unchecked") void reindexEntities(final Class entityClass, final String entityName, final FullTextSession search); @SuppressWarnings("unchecked") void purgeSearchIndex(final Class entityClass, final FullTextSession search); }
SearchIndexManager { @SuppressWarnings("unchecked") public void reindexEntities(final Class entityClass, final FullTextSession search) { log.info("reindexEntities(" + entityClass.toString() + ")"); String entityName = entityClass.toString().substring(entityClass.toString().lastIndexOf('.') + 1); reindexEntities(entityClass, entityName, search); } SearchIndexManager(final Integer inFetchBatchSize, final Integer inFlushBatchSize); @SuppressWarnings("unchecked") void reindexEntities(final Class entityClass, final FullTextSession search); @SuppressWarnings("unchecked") void reindexEntities(final Class entityClass, final String entityName, final FullTextSession search); @SuppressWarnings("unchecked") void purgeSearchIndex(final Class entityClass, final FullTextSession search);  }