### Question:
LuceneIndexProvider extends IndexProvider { @Override public IndexPopulator getPopulator( StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig, ByteBufferFactory bufferFactory ) { SchemaIndex luceneIndex = LuceneSchemaIndexBuilder.create( descriptor, config ) .withFileSystem( fileSystem ) .withOperationalMode( operationalMode ) .withSamplingConfig( samplingConfig ) .withIndexStorage( getIndexStorage( descriptor.getId() ) ) .withWriterConfig( IndexWriterConfigs::population ) .build(); if ( luceneIndex.isReadOnly() ) { throw new UnsupportedOperationException( "Can't create populator for read only index" ); } if ( descriptor.type() == UNIQUE ) { return new UniqueLuceneIndexPopulator( luceneIndex, descriptor ); } else { return new NonUniqueLuceneIndexPopulator( luceneIndex, samplingConfig ); } } LuceneIndexProvider( FileSystemAbstraction fileSystem, DirectoryFactory directoryFactory,
                                IndexDirectoryStructure.Factory directoryStructureFactory, Monitor monitor, Config config,
                                OperationalMode operationalMode ); static IndexDirectoryStructure.Factory defaultDirectoryStructure( File storeDir ); @Override IndexPopulator getPopulator( StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig, ByteBufferFactory bufferFactory ); @Override IndexAccessor getOnlineAccessor( StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig ); @Override InternalIndexState getInitialState( StoreIndexDescriptor descriptor ); @Override IndexCapability getCapability( StoreIndexDescriptor descriptor ); @Override StoreMigrationParticipant storeMigrationParticipant( final FileSystemAbstraction fs, PageCache pageCache ); @Override String getPopulationFailure( StoreIndexDescriptor descriptor );  }### Answer:
@Test void shouldFailToInvokePopulatorInReadOnlyMode() { Config readOnlyConfig = Config.defaults( GraphDatabaseSettings.read_only, Settings.TRUE ); LuceneIndexProvider readOnlyIndexProvider = getLuceneIndexProvider( readOnlyConfig, new DirectoryFactory.InMemoryDirectoryFactory(), fileSystem, graphDbDir ); assertThrows( UnsupportedOperationException.class, () -> readOnlyIndexProvider.getPopulator( descriptor, new IndexSamplingConfig( readOnlyConfig ), heapBufferFactory( 1024 ) ) ); }