@Test void indexSingleEntityindexServiceThrowsExceptionOnSecondEntityId() { IndexAction indexAction1 = indexActionFactory .create() .setIndexActionGroup(indexActionGroup) .setEntityTypeId("entityType") .setEntityId("entityId1") .setActionOrder(0) .setIndexStatus(IndexActionMetadata.IndexStatus.PENDING); IndexAction indexAction2 = indexActionFactory .create() .setIndexActionGroup(indexActionGroup) .setEntityTypeId("entityType") .setEntityId("entityId2") .setActionOrder(1) .setIndexStatus(IndexActionMetadata.IndexStatus.PENDING); IndexAction indexAction3 = indexActionFactory .create() .setIndexActionGroup(indexActionGroup) .setEntityTypeId("entityType") .setEntityId("entityId3") .setActionOrder(2) .setIndexStatus(IndexActionMetadata.IndexStatus.PENDING); mockGetAllIndexActions(of(indexAction1, indexAction2, indexAction3)); indexActionGroup.setCount(3); MolgenisDataException mde = new MolgenisDataException("Random unrecoverable exception"); doThrow(mde).when(indexService).deleteById(testEntityType, "entityId2"); when(dataService.hasRepository("TypeTestRefDynamic")).thenReturn(true); try { indexJobService.executeJob(progress, transactionId); } catch (Exception expected) { assertSame(expected, mde); } verify(indexService).deleteById(testEntityType, "entityId1"); verify(indexService).deleteById(testEntityType, "entityId2"); verify(indexService).deleteById(testEntityType, "entityId3"); verify(indexService).refreshIndex(); assertEquals(FINISHED, indexAction1.getIndexStatus()); assertEquals(FAILED, indexAction2.getIndexStatus()); verify(dataService, atLeast(1)).update(INDEX_ACTION, indexAction1); verify(dataService, atLeast(1)).update(INDEX_ACTION, indexAction2); verify(dataService, never()).delete(INDEX_ACTION_GROUP, indexActionGroup); }
@Timed( value = "service.index", description = "Timing information for the index service.", histogram = true) public Void executeJob(Progress progress, String transactionId) { requireNonNull(progress); IndexActionGroup indexActionGroup = dataService.findOneById(INDEX_ACTION_GROUP, transactionId, IndexActionGroup.class); if (indexActionGroup != null && indexActionGroup.getCount() > 0) { progress.setProgressMax(indexActionGroup.getCount()); progress.status(format("Start indexing for transaction id: [{0}]", transactionId)); performIndexActions(progress, transactionId); progress.status(format("Finished indexing for transaction id: [{0}]", transactionId)); } else { progress.status(format("No index actions found for transaction id: [{0}]", transactionId)); } return null; }
IndexJobService { @Timed( value = "service.index", description = "Timing information for the index service.", histogram = true) public Void executeJob(Progress progress, String transactionId) { requireNonNull(progress); IndexActionGroup indexActionGroup = dataService.findOneById(INDEX_ACTION_GROUP, transactionId, IndexActionGroup.class); if (indexActionGroup != null && indexActionGroup.getCount() > 0) { progress.setProgressMax(indexActionGroup.getCount()); progress.status(format("Start indexing for transaction id: [{0}]", transactionId)); performIndexActions(progress, transactionId); progress.status(format("Finished indexing for transaction id: [{0}]", transactionId)); } else { progress.status(format("No index actions found for transaction id: [{0}]", transactionId)); } return null; } }
IndexJobService { @Timed( value = "service.index", description = "Timing information for the index service.", histogram = true) public Void executeJob(Progress progress, String transactionId) { requireNonNull(progress); IndexActionGroup indexActionGroup = dataService.findOneById(INDEX_ACTION_GROUP, transactionId, IndexActionGroup.class); if (indexActionGroup != null && indexActionGroup.getCount() > 0) { progress.setProgressMax(indexActionGroup.getCount()); progress.status(format("Start indexing for transaction id: [{0}]", transactionId)); performIndexActions(progress, transactionId); progress.status(format("Finished indexing for transaction id: [{0}]", transactionId)); } else { progress.status(format("No index actions found for transaction id: [{0}]", transactionId)); } return null; } IndexJobService(
      DataService dataService, IndexService indexService, EntityTypeFactory entityTypeFactory); }
IndexJobService { @Timed( value = "service.index", description = "Timing information for the index service.", histogram = true) public Void executeJob(Progress progress, String transactionId) { requireNonNull(progress); IndexActionGroup indexActionGroup = dataService.findOneById(INDEX_ACTION_GROUP, transactionId, IndexActionGroup.class); if (indexActionGroup != null && indexActionGroup.getCount() > 0) { progress.setProgressMax(indexActionGroup.getCount()); progress.status(format("Start indexing for transaction id: [{0}]", transactionId)); performIndexActions(progress, transactionId); progress.status(format("Finished indexing for transaction id: [{0}]", transactionId)); } else { progress.status(format("No index actions found for transaction id: [{0}]", transactionId)); } return null; } IndexJobService(
      DataService dataService, IndexService indexService, EntityTypeFactory entityTypeFactory); @Timed( value = "service.index", description = "Timing information for the index service.", histogram = true) Void executeJob(Progress progress, String transactionId); }
IndexJobService { @Timed( value = "service.index", description = "Timing information for the index service.", histogram = true) public Void executeJob(Progress progress, String transactionId) { requireNonNull(progress); IndexActionGroup indexActionGroup = dataService.findOneById(INDEX_ACTION_GROUP, transactionId, IndexActionGroup.class); if (indexActionGroup != null && indexActionGroup.getCount() > 0) { progress.setProgressMax(indexActionGroup.getCount()); progress.status(format("Start indexing for transaction id: [{0}]", transactionId)); performIndexActions(progress, transactionId); progress.status(format("Finished indexing for transaction id: [{0}]", transactionId)); } else { progress.status(format("No index actions found for transaction id: [{0}]", transactionId)); } return null; } IndexJobService(
      DataService dataService, IndexService indexService, EntityTypeFactory entityTypeFactory); @Timed( value = "service.index", description = "Timing information for the index service.", histogram = true) Void executeJob(Progress progress, String transactionId);  }