use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class PropertyIT method shouldRemoveSetNodePropertyAcrossTransactions.
@Test
public void shouldRemoveSetNodePropertyAcrossTransactions() throws Exception {
// GIVEN
int propertyKeyId;
long nodeId;
{
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
nodeId = statement.dataWriteOperations().nodeCreate();
propertyKeyId = statement.tokenWriteOperations().propertyKeyGetOrCreateForName("clown");
statement.dataWriteOperations().nodeSetProperty(nodeId, stringProperty(propertyKeyId, "bozo"));
commit();
}
{
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
// WHEN
Object previous = statement.dataWriteOperations().nodeRemoveProperty(nodeId, propertyKeyId).value();
// THEN
assertEquals("bozo", previous);
assertThat(statement.readOperations().nodeGetProperty(nodeId, propertyKeyId), nullValue());
// WHEN
commit();
}
// THEN
ReadOperations readOperations = readOperationsInNewTransaction();
assertThat(readOperations.nodeGetProperty(nodeId, propertyKeyId), nullValue());
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method getLabelIdsByName.
private Map<String, Integer> getLabelIdsByName(String... names) {
ThreadToStatementContextBridge transactionStatementContextBridge = getTransactionStatementContextBridge();
ReadOperations readOperations = transactionStatementContextBridge.get().readOperations();
Map<String, Integer> labelNameIdMap = new HashMap<>();
for (String name : names) {
labelNameIdMap.put(name, readOperations.labelGetForName(name));
}
return labelNameIdMap;
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method getPropertyIdByName.
private int getPropertyIdByName(String name) {
ThreadToStatementContextBridge transactionStatementContextBridge = getTransactionStatementContextBridge();
ReadOperations readOperations = transactionStatementContextBridge.get().readOperations();
return readOperations.propertyKeyGetForName(name);
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class IndexSamplingIntegrationTest method indexId.
private long indexId(GraphDatabaseAPI api) throws IndexNotFoundKernelException {
try (Transaction tx = api.beginTx()) {
IndexingService indexingService = api.getDependencyResolver().resolveDependency(IndexingService.class);
ReadOperations readOperations = api.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class).get().readOperations();
int labelId = readOperations.labelGetForName(label.name());
int propertyKeyId = readOperations.propertyKeyGetForName(property);
long indexId = indexingService.getIndexId(SchemaDescriptorFactory.forLabel(labelId, propertyKeyId));
tx.success();
return indexId;
}
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class CompiledExpandUtilsTest method shouldUseGivenOrderIfItHasLowerDegreeWithTypes.
@Test
public void shouldUseGivenOrderIfItHasLowerDegreeWithTypes() throws EntityNotFoundException {
// GIVEN
ReadOperations readOperations = mock(ReadOperations.class);
when(readOperations.nodeGetDegree(1L, Direction.OUTGOING, 1)).thenReturn(1);
when(readOperations.nodeGetDegree(2L, Direction.INCOMING, 1)).thenReturn(3);
// WHEN
connectingRelationships(readOperations, 1L, Direction.OUTGOING, 2L, new int[] { 1 });
// THEN
verify(readOperations, times(1)).nodeGetRelationships(1L, Direction.OUTGOING, new int[] { 1 });
}
Aggregations