IndexUpdate implements Editor, PathSource { public IndexUpdate withMissingProviderStrategy( MissingIndexProviderStrategy missingProvider) { rootState.setMissingProvider(missingProvider); return this; } IndexUpdate(
            IndexEditorProvider provider, String async,
            NodeState root, NodeBuilder builder,
            IndexUpdateCallback updateCallback);  IndexUpdate(
            IndexEditorProvider provider, String async,
            NodeState root, NodeBuilder builder,
            IndexUpdateCallback updateCallback, CommitInfo commitInfo);  IndexUpdate(
            IndexEditorProvider provider, String async,
            NodeState root, NodeBuilder builder,
            IndexUpdateCallback updateCallback, NodeTraversalCallback traversalCallback,
            CommitInfo commitInfo, CorruptIndexHandler corruptIndexHandler); private  IndexUpdate(IndexUpdate parent, String name); @Override void enter(NodeState before, NodeState after); boolean isReindexingPerformed(); List<String> getReindexStats(); Set<String> getUpdatedIndexPaths(); void setTraversalRateEstimator(TraversalRateEstimator estimator); void setNodeCountEstimator(NodeCountEstimator nodeCountEstimator); String getIndexingStats(); void setIgnoreReindexFlags(boolean ignoreReindexFlag); @Override String getPath(); @Override void leave(NodeState before, NodeState after); @Override void propertyAdded(PropertyState after); @Override void propertyChanged(PropertyState before, PropertyState after); @Override void propertyDeleted(PropertyState before); @Override @NotNull Editor childNodeAdded(String name, NodeState after); @Override @NotNull Editor childNodeChanged(
            String name, NodeState before, NodeState after); @Override @Nullable Editor childNodeDeleted(String name, NodeState before); void commitProgress(IndexProgress indexProgress); IndexUpdate withMissingProviderStrategy(
            MissingIndexProviderStrategy missingProvider);  }
@Test public void testMissingProviderFailsCommit() throws Exception { final IndexUpdateCallback noop = new IndexUpdateCallback() { @Override public void indexUpdate() { } }; final MissingIndexProviderStrategy mips = new MissingIndexProviderStrategy(); mips.setFailOnMissingIndexProvider(true); EditorHook hook = new EditorHook(new EditorProvider() { @Override public Editor getRootEditor(NodeState before, NodeState after, NodeBuilder builder, CommitInfo info) throws CommitFailedException { return new IndexUpdate(emptyProvider(), null, after, builder, noop).withMissingProviderStrategy(mips); } }); NodeState before = builder.getNodeState(); createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null); builder.child(INDEX_DEFINITIONS_NAME).child("azerty"); builder.child("testRoot").setProperty("foo", "abc"); NodeState after = builder.getNodeState(); try { hook.processCommit(before, after, CommitInfo.EMPTY); fail("commit should fail on missing index provider"); } catch (CommitFailedException ex) { } }
@Test public void testMissingProviderWithAsyncDef() throws Exception { final MissingIndexProviderStrategy mips = new MissingIndexProviderStrategy(); mips.setFailOnMissingIndexProvider(true); EditorHook syncHook = new EditorHook((before, after, builder, info) -> new IndexUpdate(emptyProvider(), null, after, builder, NOOP) .withMissingProviderStrategy(mips)); EditorHook asyncHook = new EditorHook((before, after, builder, info) -> new IndexUpdate(emptyProvider(), "async-run", after, builder, NOOP) .withMissingProviderStrategy(mips)); EditorHook otherAsyncHook = new EditorHook((before, after, builder, info) -> new IndexUpdate(emptyProvider(), "other-async-run", after, builder, NOOP) .withMissingProviderStrategy(mips)); builder = EmptyNodeState.EMPTY_NODE.builder(); createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "asyncIndex", true, false, ImmutableSet.of("foo"), null) .setProperty(ASYNC_PROPERTY_NAME, ImmutableList.of("async-run"), Type.STRINGS) .setProperty(REINDEX_PROPERTY_NAME, false); createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "nrtIndex", true, false, ImmutableSet.of("foo"), null) .setProperty(ASYNC_PROPERTY_NAME, ImmutableList.of("async-run", "nrt"), Type.STRINGS) .setProperty(REINDEX_PROPERTY_NAME, false); createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "asyncSyncIndex", true, false, ImmutableSet.of("foo"), null) .setProperty(ASYNC_PROPERTY_NAME, ImmutableList.of("async-run", "sync"), Type.STRINGS) .setProperty(REINDEX_PROPERTY_NAME, false); NodeState before = builder.getNodeState(); builder.child("testRoot").setProperty("foo", "abc"); NodeState after = builder.getNodeState(); syncHook.processCommit(before, after, CommitInfo.EMPTY); otherAsyncHook.processCommit(before, after, CommitInfo.EMPTY); try { asyncHook.processCommit(before, after, CommitInfo.EMPTY); fail("commit should fail on missing index provider"); } catch (CommitFailedException ex) { } }