use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.
the class CheckPointerIntegrationTest method checkPointInTxLog.
private static List<CheckpointInfo> checkPointInTxLog(GraphDatabaseService db) throws IOException {
DependencyResolver dependencyResolver = ((GraphDatabaseAPI) db).getDependencyResolver();
LogFiles logFiles = dependencyResolver.resolveDependency(LogFiles.class);
return logFiles.getCheckpointFile().reachableCheckpoints();
}
use of org.neo4j.common.DependencyResolver 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.common.DependencyResolver 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.common.DependencyResolver in project neo4j by neo4j.
the class BuiltInProceduresTest method setup.
@BeforeEach
void setup() throws Exception {
procs.registerComponent(KernelTransaction.class, ctx -> ctx.internalTransaction().kernelTransaction(), false);
procs.registerComponent(DependencyResolver.class, Context::dependencyResolver, false);
procs.registerComponent(GraphDatabaseAPI.class, Context::graphDatabaseAPI, false);
procs.registerComponent(Transaction.class, Context::internalTransaction, true);
procs.registerComponent(SecurityContext.class, Context::securityContext, true);
procs.registerComponent(ProcedureCallContext.class, Context::procedureCallContext, true);
procs.registerComponent(SystemGraphComponents.class, ctx -> systemGraphComponents, false);
procs.registerComponent(Log.class, ctx -> log, false);
procs.registerType(Node.class, NTNode);
procs.registerType(Relationship.class, NTRelationship);
procs.registerType(Path.class, NTPath);
new SpecialBuiltInProcedures("1.3.37", Edition.COMMUNITY.toString()).accept(procs);
procs.registerProcedure(BuiltInProcedures.class);
procs.registerProcedure(BuiltInDbmsProcedures.class);
when(transaction.kernelTransaction()).thenReturn(tx);
when(tx.tokenRead()).thenReturn(tokens);
when(tx.dataRead()).thenReturn(read);
when(tx.schemaRead()).thenReturn(schemaRead);
when(tx.securityContext()).thenReturn(SecurityContext.AUTH_DISABLED);
when(callContext.isCalledFromCypher()).thenReturn(false);
when(schemaRead.snapshot()).thenReturn(schemaReadCore);
when(tokens.propertyKeyGetAllTokens()).thenAnswer(asTokens(propKeys));
when(tokens.labelsGetAllTokens()).thenAnswer(asTokens(labels));
when(tokens.relationshipTypesGetAllTokens()).thenAnswer(asTokens(relTypes));
when(schemaReadCore.indexesGetAll()).thenAnswer(i -> Iterators.concat(indexes.iterator(), uniqueIndexes.iterator()));
when(schemaReadCore.index(any(SchemaDescriptor.class))).thenAnswer((Answer<IndexDescriptor>) invocationOnMock -> {
SchemaDescriptor schema = invocationOnMock.getArgument(0);
return getIndexReference(schema);
});
when(schemaReadCore.constraintsGetAll()).thenAnswer(i -> constraints.iterator());
when(tokens.propertyKeyName(anyInt())).thenAnswer(invocation -> propKeys.get(invocation.getArgument(0)));
when(tokens.nodeLabelName(anyInt())).thenAnswer(invocation -> labels.get(invocation.getArgument(0)));
when(tokens.relationshipTypeName(anyInt())).thenAnswer(invocation -> relTypes.get(invocation.getArgument(0)));
when(tokens.propertyKeyGetName(anyInt())).thenAnswer(invocation -> propKeys.get(invocation.getArgument(0)));
when(tokens.labelGetName(anyInt())).thenAnswer(invocation -> labels.get(invocation.getArgument(0)));
when(tokens.relationshipTypeGetName(anyInt())).thenAnswer(invocation -> relTypes.get(invocation.getArgument(0)));
when(tokens.entityTokensGetNames(any(), any())).then(invocation -> {
EntityType type = invocation.getArgument(0);
int[] ids = invocation.getArgument(1);
Map<Integer, String> mapping = type == EntityType.NODE ? labels : relTypes;
return Arrays.stream(ids).mapToObj(mapping::get).toArray(String[]::new);
});
when(schemaReadCore.constraintsGetForRelationshipType(anyInt())).thenReturn(emptyIterator());
when(schemaReadCore.indexesGetForLabel(anyInt())).thenReturn(emptyIterator());
when(schemaReadCore.indexesGetForRelationshipType(anyInt())).thenReturn(emptyIterator());
when(schemaReadCore.constraintsGetForLabel(anyInt())).thenReturn(emptyIterator());
when(read.countsForNode(anyInt())).thenReturn(1L);
when(read.countsForRelationship(anyInt(), anyInt(), anyInt())).thenReturn(1L);
when(schemaReadCore.indexGetState(any(IndexDescriptor.class))).thenReturn(InternalIndexState.ONLINE);
}
use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.
the class DatabaseAvailabilityIT method restartedDatabaseIsAvailable.
@Test
void restartedDatabaseIsAvailable() {
DependencyResolver dependencyResolver = database.getDependencyResolver();
DatabaseManager<?> databaseManager = getDatabaseManager(dependencyResolver);
DatabaseContext databaseContext = databaseManager.getDatabaseContext(defaultNamedDatabaseId).get();
Database database = databaseContext.database();
executeTransactionOnDefaultDatabase();
database.stop();
assertThrows(DatabaseShutdownException.class, () -> this.database.beginTx());
database.start();
executeTransactionOnDefaultDatabase();
}
Aggregations