### Question:
LocalDatabase implements Lifecycle { @Override public void stop() throws Throwable { stopWithRequirement( NOT_STOPPED ); } LocalDatabase( DatabaseLayout databaseLayout,
            StoreFiles storeFiles,
            LogFiles logFiles,
            DataSourceManager dataSourceManager,
            Supplier<DatabaseHealth> databaseHealthSupplier,
            AvailabilityGuard availabilityGuard,
            LogProvider logProvider ); @Override void init(); @Override synchronized void start(); @Override void stop(); void stopForStoreCopy(); boolean isAvailable(); @Override void shutdown(); synchronized StoreId storeId(); void panic( Throwable cause ); void assertHealthy( Class<EXCEPTION> cause ); void delete(); boolean isEmpty(); DatabaseLayout databaseLayout(); NeoStoreDataSource dataSource(); void registerCommitProcessDependencies( TransactionAppender appender, StorageEngine applier ); TransactionCommitProcess getCommitProcess();  }### Answer:
@Test public void availabilityGuardRaisedBeforeDataSourceManagerIsStopped() throws Throwable { AvailabilityGuard guard = mock( DatabaseAvailabilityGuard.class ); DataSourceManager dataSourceManager = mock( DataSourceManager.class ); LocalDatabase localDatabase = newLocalDatabase( guard, dataSourceManager ); localDatabase.stop(); InOrder inOrder = inOrder( guard, dataSourceManager ); inOrder.verify( guard, times( 2 ) ).require( any() ); inOrder.verify( dataSourceManager ).stop(); }