@Test void onEventApplicationReadyForWiki() throws SolrIndexerException, WikiManagerException { when(this.configuration.synchronizeAtStartupMode()).thenReturn(SolrConfiguration.SynchronizeAtStartupMode.WIKI); WikiReference wikiReference = new WikiReference("foo"); WikiDescriptor wikiDescriptor = mock(WikiDescriptor.class); when(this.wikiDescriptorManager.getMainWikiDescriptor()).thenReturn(wikiDescriptor); when(wikiDescriptor.getReference()).thenReturn(wikiReference); when(this.entityReferenceSerializer.serialize(wikiReference)).thenReturn("wiki:foo"); when(this.configuration.synchronizeAtStartup()).thenReturn(false); this.solrIndexInitializeListener.onEvent(new ApplicationReadyEvent(), null, null); verify(this.solrIndexer, never()).startIndex(any()); when(this.configuration.synchronizeAtStartup()).thenReturn(true); this.solrIndexInitializeListener.onEvent(new ApplicationReadyEvent(), null, null); IndexerRequest indexerRequest = new IndexerRequest(); indexerRequest.setRootReference(wikiReference); indexerRequest.setId(Arrays.asList("solr", "indexer", "wiki:foo")); verify(this.solrIndexer).startIndex(indexerRequest); }
@Override public void onEvent(Event event, Object source, Object data) { if (this.configuration.synchronizeAtStartup()) { SolrConfiguration.SynchronizeAtStartupMode startupMode = this.configuration.synchronizeAtStartupMode(); IndexerRequest request = null; ArrayList<String> requestId = new ArrayList<>(REQUEST_DEFAULT_ID); try { if (event instanceof ApplicationReadyEvent) { if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.FARM) { request = new IndexerRequest(); request.setId(requestId); } else if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.WIKI) { request = new IndexerRequest(); WikiReference wikiReference = this.wikiDescriptorManager.getMainWikiDescriptor().getReference(); request.setRootReference(wikiReference); requestId.add(this.entityReferenceSerializer.serialize(wikiReference)); request.setId(requestId); } } else if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.WIKI && event instanceof WikiReadyEvent) { WikiReadyEvent wikiReadyEvent = (WikiReadyEvent) event; WikiReference wikiReference = new WikiReference(wikiReadyEvent.getWikiId()); request = new IndexerRequest(); request.setRootReference(wikiReference); requestId.add(this.entityReferenceSerializer.serialize(wikiReference)); request.setId(requestId); } if (request != null) { this.solrIndexer.get().startIndex(request); } } catch (SolrIndexerException | WikiManagerException e) { this.logger.error("Failed to start initial Solr index synchronization", e); } } }
SolrIndexInitializeListener implements EventListener { @Override public void onEvent(Event event, Object source, Object data) { if (this.configuration.synchronizeAtStartup()) { SolrConfiguration.SynchronizeAtStartupMode startupMode = this.configuration.synchronizeAtStartupMode(); IndexerRequest request = null; ArrayList<String> requestId = new ArrayList<>(REQUEST_DEFAULT_ID); try { if (event instanceof ApplicationReadyEvent) { if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.FARM) { request = new IndexerRequest(); request.setId(requestId); } else if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.WIKI) { request = new IndexerRequest(); WikiReference wikiReference = this.wikiDescriptorManager.getMainWikiDescriptor().getReference(); request.setRootReference(wikiReference); requestId.add(this.entityReferenceSerializer.serialize(wikiReference)); request.setId(requestId); } } else if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.WIKI && event instanceof WikiReadyEvent) { WikiReadyEvent wikiReadyEvent = (WikiReadyEvent) event; WikiReference wikiReference = new WikiReference(wikiReadyEvent.getWikiId()); request = new IndexerRequest(); request.setRootReference(wikiReference); requestId.add(this.entityReferenceSerializer.serialize(wikiReference)); request.setId(requestId); } if (request != null) { this.solrIndexer.get().startIndex(request); } } catch (SolrIndexerException | WikiManagerException e) { this.logger.error("Failed to start initial Solr index synchronization", e); } } } }
SolrIndexInitializeListener implements EventListener { @Override public void onEvent(Event event, Object source, Object data) { if (this.configuration.synchronizeAtStartup()) { SolrConfiguration.SynchronizeAtStartupMode startupMode = this.configuration.synchronizeAtStartupMode(); IndexerRequest request = null; ArrayList<String> requestId = new ArrayList<>(REQUEST_DEFAULT_ID); try { if (event instanceof ApplicationReadyEvent) { if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.FARM) { request = new IndexerRequest(); request.setId(requestId); } else if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.WIKI) { request = new IndexerRequest(); WikiReference wikiReference = this.wikiDescriptorManager.getMainWikiDescriptor().getReference(); request.setRootReference(wikiReference); requestId.add(this.entityReferenceSerializer.serialize(wikiReference)); request.setId(requestId); } } else if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.WIKI && event instanceof WikiReadyEvent) { WikiReadyEvent wikiReadyEvent = (WikiReadyEvent) event; WikiReference wikiReference = new WikiReference(wikiReadyEvent.getWikiId()); request = new IndexerRequest(); request.setRootReference(wikiReference); requestId.add(this.entityReferenceSerializer.serialize(wikiReference)); request.setId(requestId); } if (request != null) { this.solrIndexer.get().startIndex(request); } } catch (SolrIndexerException | WikiManagerException e) { this.logger.error("Failed to start initial Solr index synchronization", e); } } }  }
SolrIndexInitializeListener implements EventListener { @Override public void onEvent(Event event, Object source, Object data) { if (this.configuration.synchronizeAtStartup()) { SolrConfiguration.SynchronizeAtStartupMode startupMode = this.configuration.synchronizeAtStartupMode(); IndexerRequest request = null; ArrayList<String> requestId = new ArrayList<>(REQUEST_DEFAULT_ID); try { if (event instanceof ApplicationReadyEvent) { if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.FARM) { request = new IndexerRequest(); request.setId(requestId); } else if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.WIKI) { request = new IndexerRequest(); WikiReference wikiReference = this.wikiDescriptorManager.getMainWikiDescriptor().getReference(); request.setRootReference(wikiReference); requestId.add(this.entityReferenceSerializer.serialize(wikiReference)); request.setId(requestId); } } else if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.WIKI && event instanceof WikiReadyEvent) { WikiReadyEvent wikiReadyEvent = (WikiReadyEvent) event; WikiReference wikiReference = new WikiReference(wikiReadyEvent.getWikiId()); request = new IndexerRequest(); request.setRootReference(wikiReference); requestId.add(this.entityReferenceSerializer.serialize(wikiReference)); request.setId(requestId); } if (request != null) { this.solrIndexer.get().startIndex(request); } } catch (SolrIndexerException | WikiManagerException e) { this.logger.error("Failed to start initial Solr index synchronization", e); } } }  @Override List<Event> getEvents(); @Override String getName(); @Override void onEvent(Event event, Object source, Object data); }
SolrIndexInitializeListener implements EventListener { @Override public void onEvent(Event event, Object source, Object data) { if (this.configuration.synchronizeAtStartup()) { SolrConfiguration.SynchronizeAtStartupMode startupMode = this.configuration.synchronizeAtStartupMode(); IndexerRequest request = null; ArrayList<String> requestId = new ArrayList<>(REQUEST_DEFAULT_ID); try { if (event instanceof ApplicationReadyEvent) { if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.FARM) { request = new IndexerRequest(); request.setId(requestId); } else if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.WIKI) { request = new IndexerRequest(); WikiReference wikiReference = this.wikiDescriptorManager.getMainWikiDescriptor().getReference(); request.setRootReference(wikiReference); requestId.add(this.entityReferenceSerializer.serialize(wikiReference)); request.setId(requestId); } } else if (startupMode == SolrConfiguration.SynchronizeAtStartupMode.WIKI && event instanceof WikiReadyEvent) { WikiReadyEvent wikiReadyEvent = (WikiReadyEvent) event; WikiReference wikiReference = new WikiReference(wikiReadyEvent.getWikiId()); request = new IndexerRequest(); request.setRootReference(wikiReference); requestId.add(this.entityReferenceSerializer.serialize(wikiReference)); request.setId(requestId); } if (request != null) { this.solrIndexer.get().startIndex(request); } } catch (SolrIndexerException | WikiManagerException e) { this.logger.error("Failed to start initial Solr index synchronization", e); } } }  @Override List<Event> getEvents(); @Override String getName(); @Override void onEvent(Event event, Object source, Object data);  }