@Test void testStartupNoIndex() { @SuppressWarnings("unchecked") Repository<Entity> repo1 = mock(Repository.class); EntityType entityType1 = mock(EntityType.class); when(repo1.getEntityType()).thenReturn(entityType1); @SuppressWarnings("unchecked") Repository<Entity> repo2 = mock(Repository.class); EntityType entityType2 = mock(EntityType.class); when(repo2.getEntityType()).thenReturn(entityType2); @SuppressWarnings("unchecked") Repository<Entity> repo3 = mock(Repository.class); EntityType entityType3 = mock(EntityType.class); when(repo3.getEntityType()).thenReturn(entityType3); List<Repository<Entity>> repos = Arrays.asList(repo1, repo2, repo3); when(indexService.hasIndex(attributeMetadata)).thenReturn(false); when(metaDataService.getRepositories()).thenReturn(repos.stream()); indexBootstrapper.bootstrap(); verify(indexActionRegisterService).register(entityType1, null); verify(indexActionRegisterService).register(entityType2, null); verify(indexActionRegisterService).register(entityType3, null); }
public void bootstrap() { if (!indexService.hasIndex(attrMetadata)) { LOG.debug( "No index for Attribute found, asuming missing index, schedule (re)index for all entities"); metaDataService .getRepositories() .forEach(repo -> indexActionRegisterService.register(repo.getEntityType(), null)); LOG.debug("Done scheduling (re)index jobs for all entities"); } else { LOG.debug("Index for Attribute found, index is present, no (re)index needed"); List<IndexJobExecution> failedIndexJobs = dataService .findAll( IndexJobExecutionMetadata.INDEX_JOB_EXECUTION, new QueryImpl<IndexJobExecution>().eq(JobExecutionMetaData.STATUS, FAILED), IndexJobExecution.class) .collect(Collectors.toList()); failedIndexJobs.forEach(this::registerNewIndexActionForDirtyJobs); } }
IndexBootstrapper { public void bootstrap() { if (!indexService.hasIndex(attrMetadata)) { LOG.debug( "No index for Attribute found, asuming missing index, schedule (re)index for all entities"); metaDataService .getRepositories() .forEach(repo -> indexActionRegisterService.register(repo.getEntityType(), null)); LOG.debug("Done scheduling (re)index jobs for all entities"); } else { LOG.debug("Index for Attribute found, index is present, no (re)index needed"); List<IndexJobExecution> failedIndexJobs = dataService .findAll( IndexJobExecutionMetadata.INDEX_JOB_EXECUTION, new QueryImpl<IndexJobExecution>().eq(JobExecutionMetaData.STATUS, FAILED), IndexJobExecution.class) .collect(Collectors.toList()); failedIndexJobs.forEach(this::registerNewIndexActionForDirtyJobs); } } }
IndexBootstrapper { public void bootstrap() { if (!indexService.hasIndex(attrMetadata)) { LOG.debug( "No index for Attribute found, asuming missing index, schedule (re)index for all entities"); metaDataService .getRepositories() .forEach(repo -> indexActionRegisterService.register(repo.getEntityType(), null)); LOG.debug("Done scheduling (re)index jobs for all entities"); } else { LOG.debug("Index for Attribute found, index is present, no (re)index needed"); List<IndexJobExecution> failedIndexJobs = dataService .findAll( IndexJobExecutionMetadata.INDEX_JOB_EXECUTION, new QueryImpl<IndexJobExecution>().eq(JobExecutionMetaData.STATUS, FAILED), IndexJobExecution.class) .collect(Collectors.toList()); failedIndexJobs.forEach(this::registerNewIndexActionForDirtyJobs); } } IndexBootstrapper(
      MetaDataService metaDataService,
      IndexService indexService,
      IndexActionRegisterService indexActionRegisterService,
      DataService dataService,
      AttributeMetadata attrMetadata); }
IndexBootstrapper { public void bootstrap() { if (!indexService.hasIndex(attrMetadata)) { LOG.debug( "No index for Attribute found, asuming missing index, schedule (re)index for all entities"); metaDataService .getRepositories() .forEach(repo -> indexActionRegisterService.register(repo.getEntityType(), null)); LOG.debug("Done scheduling (re)index jobs for all entities"); } else { LOG.debug("Index for Attribute found, index is present, no (re)index needed"); List<IndexJobExecution> failedIndexJobs = dataService .findAll( IndexJobExecutionMetadata.INDEX_JOB_EXECUTION, new QueryImpl<IndexJobExecution>().eq(JobExecutionMetaData.STATUS, FAILED), IndexJobExecution.class) .collect(Collectors.toList()); failedIndexJobs.forEach(this::registerNewIndexActionForDirtyJobs); } } IndexBootstrapper(
      MetaDataService metaDataService,
      IndexService indexService,
      IndexActionRegisterService indexActionRegisterService,
      DataService dataService,
      AttributeMetadata attrMetadata); void bootstrap(); }
IndexBootstrapper { public void bootstrap() { if (!indexService.hasIndex(attrMetadata)) { LOG.debug( "No index for Attribute found, asuming missing index, schedule (re)index for all entities"); metaDataService .getRepositories() .forEach(repo -> indexActionRegisterService.register(repo.getEntityType(), null)); LOG.debug("Done scheduling (re)index jobs for all entities"); } else { LOG.debug("Index for Attribute found, index is present, no (re)index needed"); List<IndexJobExecution> failedIndexJobs = dataService .findAll( IndexJobExecutionMetadata.INDEX_JOB_EXECUTION, new QueryImpl<IndexJobExecution>().eq(JobExecutionMetaData.STATUS, FAILED), IndexJobExecution.class) .collect(Collectors.toList()); failedIndexJobs.forEach(this::registerNewIndexActionForDirtyJobs); } } IndexBootstrapper(
      MetaDataService metaDataService,
      IndexService indexService,
      IndexActionRegisterService indexActionRegisterService,
      DataService dataService,
      AttributeMetadata attrMetadata); void bootstrap();  }