Search in sources :

Example 46 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class StorageLayerRelTypesAndDegreeTest method relTypeForId.

private TestRelType relTypeForId(int id) {
    DependencyResolver resolver = db.getDependencyResolver();
    RelationshipTypeTokenHolder relTypeHolder = resolver.resolveDependency(RelationshipTypeTokenHolder.class);
    try {
        String typeName = relTypeHolder.getTokenById(id).name();
        return TestRelType.valueOf(typeName);
    } catch (TokenNotFoundException e) {
        throw new RuntimeException(e);
    }
}
Also used : RelationshipTypeTokenHolder(org.neo4j.kernel.impl.core.RelationshipTypeTokenHolder) TokenNotFoundException(org.neo4j.kernel.impl.core.TokenNotFoundException) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 47 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class GraphDatabaseFacadeTest method setUp.

@Before
public void setUp() {
    queryService = mock(GraphDatabaseQueryService.class);
    DependencyResolver resolver = mock(DependencyResolver.class);
    Statement statement = mock(Statement.class, RETURNS_DEEP_STUBS);
    ThreadToStatementContextBridge contextBridge = mock(ThreadToStatementContextBridge.class);
    when(spi.queryService()).thenReturn(queryService);
    when(spi.resolver()).thenReturn(resolver);
    when(resolver.resolveDependency(ThreadToStatementContextBridge.class)).thenReturn(contextBridge);
    when(resolver.resolveDependency(Guard.class)).thenReturn(mock(Guard.class));
    when(contextBridge.get()).thenReturn(statement);
    when(resolver.resolveDependency(Config.class)).thenReturn(Config.embeddedDefaults());
    graphDatabaseFacade.init(spi);
}
Also used : GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) Statement(org.neo4j.kernel.api.Statement) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge) Guard(org.neo4j.kernel.guard.Guard) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Before(org.junit.Before)

Example 48 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class Neo4jTransactionalContextTest method setUpMocks.

private void setUpMocks() {
    queryService = mock(GraphDatabaseQueryService.class);
    DependencyResolver resolver = mock(DependencyResolver.class);
    ThreadToStatementContextBridge txBridge = mock(ThreadToStatementContextBridge.class);
    guard = mock(Guard.class);
    initialStatement = mock(KernelStatement.class);
    QueryRegistryOperations queryRegistryOperations = mock(QueryRegistryOperations.class);
    when(initialStatement.queryRegistration()).thenReturn(queryRegistryOperations);
    when(queryService.getDependencyResolver()).thenReturn(resolver);
    when(resolver.resolveDependency(ThreadToStatementContextBridge.class)).thenReturn(txBridge);
    when(resolver.resolveDependency(Guard.class)).thenReturn(guard);
}
Also used : KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) QueryRegistryOperations(org.neo4j.kernel.api.QueryRegistryOperations) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge) Guard(org.neo4j.kernel.guard.Guard) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 49 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class SchemaStorageTest method readOps.

private ReadOperations readOps() {
    DependencyResolver dependencyResolver = dependencyResolver();
    Statement statement = dependencyResolver.resolveDependency(ThreadToStatementContextBridge.class).get();
    return statement.readOperations();
}
Also used : Statement(org.neo4j.kernel.api.Statement) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 50 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class NonIndexedConflictResolverTest method setUp.

@Before
public void setUp() {
    api = dbRule.getGraphDatabaseAPI();
    String propKeyA = "keyA";
    String propKeyB = "keyB";
    String propKeyC = "keyC";
    String propKeyD = "keyD";
    String propKeyE = "keyE";
    try (Transaction transaction = api.beginTx()) {
        Node nodeA = api.createNode();
        nodeA.setProperty(propKeyA, "value");
        nodeA.setProperty(propKeyB, "value");
        nodeIdA = nodeA.getId();
        Node nodeB = api.createNode();
        nodeB.setProperty(propKeyA, "value");
        nodeB.setProperty(propKeyB, "value");
        nodeIdB = nodeB.getId();
        Node nodeC = api.createNode();
        nodeC.setProperty(propKeyA, "longer val");
        nodeC.setProperty(propKeyB, "longer val");
        nodeC.setProperty(propKeyC, "longer val");
        nodeC.setProperty(propKeyD, "longer val");
        nodeC.setProperty(propKeyE, "longer val");
        nodeIdC = nodeC.getId();
        transaction.success();
    }
    DependencyResolver resolver = api.getDependencyResolver();
    NeoStores neoStores = resolver.resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
    nodeStore = neoStores.getNodeStore();
    propertyStore = neoStores.getPropertyStore();
    propertyKeyTokenStore = neoStores.getPropertyKeyTokenStore();
    tokenA = findTokenFor(propertyKeyTokenStore, propKeyA);
    Token tokenB = findTokenFor(propertyKeyTokenStore, propKeyB);
    Token tokenC = findTokenFor(propertyKeyTokenStore, propKeyC);
    Token tokenD = findTokenFor(propertyKeyTokenStore, propKeyD);
    Token tokenE = findTokenFor(propertyKeyTokenStore, propKeyE);
    replacePropertyKey(propertyStore, nodeStore.getRecord(nodeIdA, nodeStore.newRecord(), FORCE), tokenB, tokenA);
    replacePropertyKey(propertyStore, nodeStore.getRecord(nodeIdB, nodeStore.newRecord(), FORCE), tokenB, tokenA);
    NodeRecord nodeRecordC = nodeStore.getRecord(nodeIdC, nodeStore.newRecord(), FORCE);
    replacePropertyKey(propertyStore, nodeRecordC, tokenB, tokenA);
    replacePropertyKey(propertyStore, nodeRecordC, tokenC, tokenA);
    replacePropertyKey(propertyStore, nodeRecordC, tokenD, tokenA);
    replacePropertyKey(propertyStore, nodeRecordC, tokenE, tokenA);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Transaction(org.neo4j.graphdb.Transaction) RecordStorageEngine(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine) Node(org.neo4j.graphdb.Node) NeoStores(org.neo4j.kernel.impl.store.NeoStores) Token(org.neo4j.storageengine.api.Token) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Before(org.junit.Before)

Aggregations

DependencyResolver (org.neo4j.graphdb.DependencyResolver)51 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)18 Test (org.junit.Test)15 Transaction (org.neo4j.graphdb.Transaction)10 ThreadToStatementContextBridge (org.neo4j.kernel.impl.core.ThreadToStatementContextBridge)9 Before (org.junit.Before)8 RecordStorageEngine (org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine)8 GraphDatabaseQueryService (org.neo4j.kernel.GraphDatabaseQueryService)7 NeoStores (org.neo4j.kernel.impl.store.NeoStores)7 Monitors (org.neo4j.kernel.monitoring.Monitors)7 Node (org.neo4j.graphdb.Node)6 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)6 NeoStoreDataSource (org.neo4j.kernel.NeoStoreDataSource)5 Statement (org.neo4j.kernel.api.Statement)5 File (java.io.File)4 IOException (java.io.IOException)4 Label (org.neo4j.graphdb.Label)4 PageCache (org.neo4j.io.pagecache.PageCache)4 Guard (org.neo4j.kernel.guard.Guard)4 QueryExecutionEngine (org.neo4j.kernel.impl.query.QueryExecutionEngine)4