/** * Returns specified store by type from already opened store array. If store is not opened exception will be * thrown. * * @see #getOrCreateStore * @param storeType store type to retrieve * @return store of requested type * @throws IllegalStateException if opened store not found */ private Object getStore( StoreType storeType ) { Object store = stores[storeType.ordinal()]; if ( store == null ) { String message = ArrayUtil.contains( initializedStores, storeType ) ? STORE_ALREADY_CLOSED_MESSAGE : String.format( STORE_NOT_INITIALIZED_TEMPLATE, storeType.name() ); throw new IllegalStateException( message ); } return store; }
@Test public void impossibleToGetNotRequestedStore() { Config config = Config.defaults(); StoreFactory sf = getStoreFactory( config, databaseLayout, fs.get(), NullLogProvider.getInstance() ); exception.expect( IllegalStateException.class ); exception.expectMessage( "Specified store was not initialized. Please specify " + StoreType.META_DATA.name() + " as one of the stores types that should be open to be able to use it." ); try ( NeoStores neoStores = sf.openNeoStores( true, StoreType.NODE_LABEL ) ) { neoStores.getMetaDataStore(); } }
/** * Returns specified store by type from already opened store array. If store is not opened exception will be * thrown. * * @see #getOrCreateStore * @param storeType store type to retrieve * @return store of requested type * @throws IllegalStateException if opened store not found */ private Object getStore( StoreType storeType ) { Object store = stores[storeType.ordinal()]; if ( store == null ) { String message = ArrayUtil.contains( initializedStores, storeType ) ? STORE_ALREADY_CLOSED_MESSAGE : String.format( STORE_NOT_INITIALIZED_TEMPLATE, storeType.name() ); throw new IllegalStateException( message ); } return store; }