Skip to content

Commit

Permalink
Cleanup FailingGenericNativeIndexProviderFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen authored and tinwelint committed Sep 24, 2018
1 parent 10bd5f8 commit 73f9aa8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Expand Up @@ -42,7 +42,7 @@
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.neo4j.graphdb.Label.label; import static org.neo4j.graphdb.Label.label;
import static org.neo4j.kernel.impl.index.schema.FailingGenericNativeIndexProviderFactory.FailureType.INITIAL_STATE; import static org.neo4j.kernel.impl.index.schema.FailingGenericNativeIndexProviderFactory.FailureType.INITIAL_STATE;
import static org.neo4j.kernel.impl.index.schema.FailingGenericNativeIndexProviderFactory.POPULATION_FAILURE_OVERRIDE; import static org.neo4j.kernel.impl.index.schema.FailingGenericNativeIndexProviderFactory.INITIAL_STATE_FAILURE_MESSAGE;
import static org.neo4j.test.TestGraphDatabaseFactory.INDEX_PROVIDERS_FILTER; import static org.neo4j.test.TestGraphDatabaseFactory.INDEX_PROVIDERS_FILTER;


public class ConstraintIndexFailureIT public class ConstraintIndexFailureIT
Expand Down Expand Up @@ -87,7 +87,7 @@ public void shouldFailToValidateConstraintsIfUnderlyingIndexIsFailed() throws Ex
assertThat( e.getCause(), instanceOf( UnableToValidateConstraintException.class ) ); assertThat( e.getCause(), instanceOf( UnableToValidateConstraintException.class ) );
assertThat( e.getCause().getCause().getMessage(), allOf( assertThat( e.getCause().getCause().getMessage(), allOf(
containsString( "The index is in a failed state:" ), containsString( "The index is in a failed state:" ),
containsString( POPULATION_FAILURE_OVERRIDE ) ) ); containsString( INITIAL_STATE_FAILURE_MESSAGE ) ) );
} }
finally finally
{ {
Expand Down
Expand Up @@ -62,12 +62,13 @@
*/ */
public class FailingGenericNativeIndexProviderFactory extends KernelExtensionFactory<GenericNativeIndexProviderFactory.Dependencies> public class FailingGenericNativeIndexProviderFactory extends KernelExtensionFactory<GenericNativeIndexProviderFactory.Dependencies>
{ {
public static final String POPULATION_FAILURE_OVERRIDE = "Was told to fail"; public static final String INITIAL_STATE_FAILURE_MESSAGE = "Override initial state as failed";
private static final String POPULATION_FAILURE_MESSAGE = "Fail on update during population";


public enum FailureType public enum FailureType
{ {
POPULATION, POPULATION,
INITIAL_STATE; INITIAL_STATE
} }


private final GenericNativeIndexProviderFactory actual; private final GenericNativeIndexProviderFactory actual;
Expand All @@ -79,7 +80,7 @@ public FailingGenericNativeIndexProviderFactory( FailureType... failureTypes )
this( new GenericNativeIndexProviderFactory(), 10_000, failureTypes ); this( new GenericNativeIndexProviderFactory(), 10_000, failureTypes );
} }


public FailingGenericNativeIndexProviderFactory( GenericNativeIndexProviderFactory actual, int priority, FailureType... failureTypes ) private FailingGenericNativeIndexProviderFactory( GenericNativeIndexProviderFactory actual, int priority, FailureType... failureTypes )
{ {
super( ExtensionType.DATABASE, actual.getKeys().iterator().next() ); super( ExtensionType.DATABASE, actual.getKeys().iterator().next() );
if ( failureTypes.length == 0 ) if ( failureTypes.length == 0 )
Expand Down Expand Up @@ -118,9 +119,9 @@ public void drop()
} }


@Override @Override
public void add( Collection<? extends IndexEntryUpdate<?>> updates ) throws IndexEntryConflictException public void add( Collection<? extends IndexEntryUpdate<?>> updates )
{ {
throw new RuntimeException( "Failing index population on purpose" ); throw new RuntimeException( POPULATION_FAILURE_MESSAGE );
} }


@Override @Override
Expand Down Expand Up @@ -172,7 +173,7 @@ public IndexAccessor getOnlineAccessor( StoreIndexDescriptor descriptor, IndexSa
@Override @Override
public String getPopulationFailure( StoreIndexDescriptor descriptor ) throws IllegalStateException public String getPopulationFailure( StoreIndexDescriptor descriptor ) throws IllegalStateException
{ {
return failureTypes.contains( FailureType.INITIAL_STATE ) ? POPULATION_FAILURE_OVERRIDE : actualProvider.getPopulationFailure( descriptor ); return failureTypes.contains( FailureType.INITIAL_STATE ) ? INITIAL_STATE_FAILURE_MESSAGE : actualProvider.getPopulationFailure( descriptor );
} }


@Override @Override
Expand Down

0 comments on commit 73f9aa8

Please sign in to comment.