use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class HttpTransactionManagerTest method shouldGetEmptyTransactionFacadeForUnknownDatabase.
@Test
void shouldGetEmptyTransactionFacadeForUnknownDatabase() {
DatabaseManagementService managementService = mock(DatabaseManagementService.class);
var memoryPool = mock(MemoryPool.class);
var manager = newTransactionManager(managementService, memoryPool);
var transactionFacade = manager.getGraphDatabaseAPI("foo");
assertFalse(transactionFacade.isPresent());
verify(managementService).database("foo");
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class BoltStateMachineFactoryImplTest method newDbMock.
private static DatabaseManagementService newDbMock() {
GraphDatabaseFacade db = mock(GraphDatabaseFacade.class);
DependencyResolver dependencyResolver = mock(DependencyResolver.class);
when(db.getDependencyResolver()).thenReturn(dependencyResolver);
GraphDatabaseQueryService queryService = mock(GraphDatabaseQueryService.class);
when(queryService.getDependencyResolver()).thenReturn(dependencyResolver);
when(dependencyResolver.resolveDependency(GraphDatabaseQueryService.class)).thenReturn(queryService);
DatabaseManagementService managementService = mock(DatabaseManagementService.class);
when(managementService.database(CUSTOM_DB_NAME)).thenReturn(db);
return managementService;
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class DefaultDatabaseTransactionStateMachineSPIProviderTest method shouldErrorIfDatabaseNotFound.
@Test
void shouldErrorIfDatabaseNotFound() {
DatabaseManagementService managementService = managementServiceWithDatabase("database");
TransactionStateMachineSPIProvider spiProvider = newSpiProvider(managementService);
BoltProtocolBreachFatality error = assertThrows(BoltProtocolBreachFatality.class, () -> spiProvider.getTransactionStateMachineSPI("database", mock(StatementProcessorReleaseManager.class)));
assertThat(error.getMessage()).contains("Database selection by name not supported by Bolt protocol version lower than BoltV4.");
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class DefaultDatabaseTransactionStateMachineSPIProviderTest method managementServiceWithDatabase.
private DatabaseManagementService managementServiceWithDatabase(String databaseName) {
DatabaseManagementService managementService = mock(DatabaseManagementService.class);
GraphDatabaseFacade databaseFacade = mock(GraphDatabaseFacade.class);
when(databaseFacade.isAvailable(anyLong())).thenReturn(true);
when(managementService.database(databaseName)).thenReturn(databaseFacade);
DependencyResolver dependencyResolver = mock(DependencyResolver.class);
when(databaseFacade.getDependencyResolver()).thenReturn(dependencyResolver);
GraphDatabaseQueryService queryService = mock(GraphDatabaseQueryService.class);
when(dependencyResolver.resolveDependency(GraphDatabaseQueryService.class)).thenReturn(queryService);
when(queryService.getDependencyResolver()).thenReturn(dependencyResolver);
when(dependencyResolver.resolveDependency(Database.class)).thenReturn(mock(Database.class));
when(mockBoltChannel.defaultDatabase()).thenReturn("neo4j");
return managementService;
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class FulltextIndexConsistencyCheckIT method mustDiscoverNodeInIndexMissingFromStore.
@Disabled("Turns out that this is not something that the consistency checker actually looks for, currently. " + "The test is disabled until the consistency checker is extended with checks that will discover this sort of inconsistency.")
@Test
void mustDiscoverNodeInIndexMissingFromStore() throws Exception {
GraphDatabaseService db = createDatabase();
try (Transaction tx = db.beginTx()) {
tx.execute(format(NODE_CREATE, "nodes", asStrList("Label"), asStrList("prop"))).close();
tx.commit();
}
long nodeId;
try (Transaction tx = db.beginTx()) {
tx.schema().awaitIndexesOnline(2, TimeUnit.MINUTES);
Node node = tx.createNode(Label.label("Label"));
nodeId = node.getId();
node.setProperty("prop", "value");
tx.commit();
}
// Remove the property without updating the index
managementService.shutdown();
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(databaseLayout).setFileSystem(fs).removeExtensions(INDEX_PROVIDERS_FILTER).addExtension(new FailingGenericNativeIndexProviderFactory(SKIP_ONLINE_UPDATES)).addExtension(new TokenIndexProviderFactory()).build();
db = managementService.database(DEFAULT_DATABASE_NAME);
try (Transaction tx = db.beginTx()) {
tx.getNodeById(nodeId).removeProperty("prop");
tx.commit();
}
managementService.shutdown();
ConsistencyCheckService.Result result = checkConsistency();
assertFalse(result.isSuccessful());
}
Aggregations