use of org.neo4j.kernel.availability.CompositeDatabaseAvailabilityGuard in project neo4j by neo4j.
the class DatabaseAvailabilityIT method anyOfDatabaseUnavailabilityIsGlobalUnavailability.
@Test
void anyOfDatabaseUnavailabilityIsGlobalUnavailability() {
AvailabilityRequirement outerSpaceRequirement = () -> "outer space";
DependencyResolver dependencyResolver = database.getDependencyResolver();
DatabaseManager<?> databaseManager = getDatabaseManager(dependencyResolver);
CompositeDatabaseAvailabilityGuard compositeGuard = dependencyResolver.resolveDependency(CompositeDatabaseAvailabilityGuard.class);
assertTrue(compositeGuard.isAvailable());
DatabaseContext systemContext = databaseManager.getDatabaseContext(NAMED_SYSTEM_DATABASE_ID).get();
DatabaseContext defaultContext = databaseManager.getDatabaseContext(defaultNamedDatabaseId).get();
AvailabilityGuard systemGuard = systemContext.dependencies().resolveDependency(DatabaseAvailabilityGuard.class);
systemGuard.require(outerSpaceRequirement);
assertFalse(compositeGuard.isAvailable());
systemGuard.fulfill(outerSpaceRequirement);
assertTrue(compositeGuard.isAvailable());
AvailabilityGuard defaultGuard = defaultContext.dependencies().resolveDependency(DatabaseAvailabilityGuard.class);
defaultGuard.require(outerSpaceRequirement);
assertFalse(compositeGuard.isAvailable());
defaultGuard.fulfill(outerSpaceRequirement);
assertTrue(compositeGuard.isAvailable());
}
Aggregations