use of org.neo4j.kernel.api.Kernel in project neo4j by neo4j.
the class IndexingServiceIntegrationTest method testManualRelationshipIndexPopulation.
@ParameterizedTest
@MethodSource("parameters")
void testManualRelationshipIndexPopulation(GraphDatabaseSettings.SchemaIndex schemaIndex) throws Exception {
setUp(schemaIndex);
IndexDescriptor index;
Kernel kernel = ((GraphDatabaseAPI) database).getDependencyResolver().resolveDependency(Kernel.class);
try (KernelTransaction tx = kernel.beginTransaction(EXPLICIT, AUTH_DISABLED)) {
int foodId = tx.tokenWrite().relationshipTypeGetOrCreateForName(FOOD_LABEL);
int propertyId = tx.tokenWrite().propertyKeyGetOrCreateForName(PROPERTY_NAME);
RelationTypeSchemaDescriptor schema = forRelType(foodId, propertyId);
index = tx.schemaWrite().indexCreate(schema, "food names");
tx.commit();
}
IndexingService indexingService = getIndexingService(database);
IndexProxy indexProxy = indexingService.getIndexProxy(index);
waitIndexOnline(indexProxy);
assertEquals(InternalIndexState.ONLINE, indexProxy.getState());
PopulationProgress progress = indexProxy.getIndexPopulationProgress();
assertEquals(progress.getCompleted(), progress.getTotal());
}
use of org.neo4j.kernel.api.Kernel in project neo4j by neo4j.
the class GraphDatabaseFacadeTest method setUp.
@BeforeEach
void setUp() {
queryService = mock(GraphDatabaseQueryService.class);
Database database = mock(Database.class, RETURNS_MOCKS);
Dependencies resolver = mock(Dependencies.class);
kernel = mock(Kernel.class, RETURNS_MOCKS);
when(database.getKernel()).thenReturn(kernel);
when(database.getDependencyResolver()).thenReturn(resolver);
when(resolver.resolveDependency(GraphDatabaseQueryService.class)).thenReturn(queryService);
Config config = Config.defaults();
when(resolver.resolveDependency(Config.class)).thenReturn(config);
graphDatabaseFacade = new GraphDatabaseFacade(database, config, DbmsInfo.COMMUNITY, mock(DatabaseAvailabilityGuard.class));
}
use of org.neo4j.kernel.api.Kernel in project neo4j by neo4j.
the class CheckerTestBase method setUpDb.
@BeforeEach
void setUpDb() throws Exception {
TestDatabaseManagementServiceBuilder builder = new TestDatabaseManagementServiceBuilder(directory.homePath());
builder.setFileSystem(directory.getFileSystem());
dbms = builder.build();
db = (GraphDatabaseAPI) dbms.database(GraphDatabaseSettings.DEFAULT_DATABASE_NAME);
// Create our tokens
Kernel kernel = db.getDependencyResolver().resolveDependency(Kernel.class);
try (KernelTransaction tx = kernel.beginTransaction(KernelTransaction.Type.EXPLICIT, LoginContext.AUTH_DISABLED)) {
initialData(tx);
tx.commit();
}
DependencyResolver dependencies = db.getDependencyResolver();
neoStores = dependencies.resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
nodeStore = neoStores.getNodeStore();
relationshipGroupStore = neoStores.getRelationshipGroupStore();
propertyStore = neoStores.getPropertyStore();
relationshipStore = neoStores.getRelationshipStore();
schemaStore = neoStores.getSchemaStore();
tokenHolders = dependencies.resolveDependency(TokenHolders.class);
schemaStorage = new SchemaStorage(schemaStore, tokenHolders, neoStores.getMetaDataStore());
cacheAccess = new DefaultCacheAccess(NumberArrayFactories.HEAP.newDynamicByteArray(10_000, new byte[MAX_BYTES], INSTANCE), Counts.NONE, NUMBER_OF_THREADS);
cacheAccess.setCacheSlotSizes(DEFAULT_SLOT_SIZES);
pageCache = dependencies.resolveDependency(PageCache.class);
}
use of org.neo4j.kernel.api.Kernel in project neo4j by neo4j.
the class KernelAPIReadTestBase method changeUser.
protected void changeUser(LoginContext loginContext) throws KernelException {
Kernel kernel = testSupport.kernelToTest();
tx = beginTransaction(kernel, loginContext);
token = tx.token();
read = tx.dataRead();
schemaRead = tx.schemaRead();
cursors = new ManagedTestCursors(tx.cursors());
}
Aggregations