SepTestUtil.waitOnReplicationPeerReady(peerId("indexer1"));
checkLifecycleEvents(1,0,0,0, indexerLifecycleListener);
Mockito.reset(indexerLifecycleListener);
IndexerDefinition indexerDefinition = main.getIndexerModel().getIndexer("indexer1");
markEventCounts();
indexerDefinitionBuilder = new IndexerDefinitionBuilder().startFrom(indexerDefinition);
indexerDefinitionBuilder.incrementalIndexingState(IncrementalIndexingState.DO_NOT_SUBSCRIBE);
String lock = main.getIndexerModel().lockIndexer(indexerDefinition.getName());
main.getIndexerModel().updateIndexer(indexerDefinitionBuilder.build(), lock);
main.getIndexerModel().unlockIndexer(lock);
waitOnEventsProcessed(1);
checkLifecycleEvents(0, 1, 0, 0, indexerLifecycleListener);
Mockito.reset(indexerLifecycleListener);
markEventCounts();
indexerDefinition = main.getIndexerModel().getIndexer("indexer1");
indexerDefinitionBuilder = new IndexerDefinitionBuilder().startFrom(indexerDefinition);
indexerDefinitionBuilder.batchIndexingState(IndexerDefinition.BatchIndexingState.BUILD_REQUESTED);
lock = main.getIndexerModel().lockIndexer(indexerDefinition.getName());
main.getIndexerModel().updateIndexer(indexerDefinitionBuilder.build(), lock);
main.getIndexerModel().unlockIndexer(lock);
waitOnEventsProcessed(1);
checkLifecycleEvents(0, 0, 0, 1, indexerLifecycleListener);
Mockito.reset(indexerLifecycleListener);
markEventCounts();
indexerDefinition = main.getIndexerModel().getIndexer("indexer1");
indexerDefinitionBuilder = new IndexerDefinitionBuilder().startFrom(indexerDefinition);
indexerDefinitionBuilder.lifecycleState(IndexerDefinition.LifecycleState.DELETE_REQUESTED);
lock = main.getIndexerModel().lockIndexer(indexerDefinition.getName());
main.getIndexerModel().updateIndexer(indexerDefinitionBuilder.build(), lock);
main.getIndexerModel().unlockIndexer(lock);
waitOnEventsProcessed(1);
checkLifecycleEvents(0, 0, 1, 0, indexerLifecycleListener);