use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class RelationshipIT method assertRelsInSeparateTx.
private void assertRelsInSeparateTx(final long refNode, final Direction both, final long... longs) throws InterruptedException, ExecutionException, TimeoutException {
assertTrue(otherThread.execute(state -> {
try (Transaction tx = db.beginTx()) {
ReadOperations stmt = statementContextSupplier.get().readOperations();
assertRels(stmt.nodeGetRelationships(refNode, both), longs);
}
return true;
}).get(10, TimeUnit.SECONDS));
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class UniquenessConstraintValidationIT method addingUniqueNodeWithUnrelatedValueShouldNotAffectLookup.
@Test
public void addingUniqueNodeWithUnrelatedValueShouldNotAffectLookup() throws Exception {
// given
createConstraint("Person", "id");
long ourNode;
{
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
ourNode = createLabeledNode(statement, "Person", "id", 1);
commit();
}
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
ReadOperations readOps = statement.readOperations();
int person = readOps.labelGetForName("Person");
int propId = readOps.propertyKeyGetForName("id");
NewIndexDescriptor idx = readOps.uniqueIndexGetForLabelAndPropertyKey(new NodePropertyDescriptor(person, propId));
// when
createLabeledNode(statement, "Person", "id", 2);
// then I should find the original node
assertThat(readOps.nodeGetFromUniqueIndexSeek(idx, exact(propId, 1)), equalTo(ourNode));
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class UniquenessConstraintValidationIT method unrelatedNodesWithSamePropertyShouldNotInterfereWithUniquenessCheck.
@Test
public void unrelatedNodesWithSamePropertyShouldNotInterfereWithUniquenessCheck() throws Exception {
// given
createConstraint("Person", "id");
long ourNode;
{
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
ourNode = createLabeledNode(statement, "Person", "id", 1);
createLabeledNode(statement, "Item", "id", 2);
commit();
}
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
ReadOperations readOps = statement.readOperations();
int person = readOps.labelGetForName("Person");
int propId = readOps.propertyKeyGetForName("id");
NewIndexDescriptor idx = readOps.uniqueIndexGetForLabelAndPropertyKey(new NodePropertyDescriptor(person, propId));
// when
createLabeledNode(statement, "Item", "id", 2);
// then I should find the original node
assertThat(readOps.nodeGetFromUniqueIndexSeek(idx, exact(propId, 1)), equalTo(ourNode));
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class NodeGetUniqueFromIndexSeekIT method shouldCompositeFindMatchingNode.
@Test
public void shouldCompositeFindMatchingNode() throws Exception {
// given
NewIndexDescriptor index = createUniquenessConstraint(labelId, propertyId1, propertyId2);
String value1 = "value1";
String value2 = "value2";
long nodeId = createNodeWithValues(value1, value2);
// when looking for it
ReadOperations readOperations = readOperationsInNewTransaction();
long foundId = readOperations.nodeGetFromUniqueIndexSeek(index, exact(propertyId1, value1), exact(propertyId2, value2));
commit();
// then
assertTrue("Created node was not found", nodeId == foundId);
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class NodeGetUniqueFromIndexSeekIT method shouldNotFindNonMatchingNode.
@Test
public void shouldNotFindNonMatchingNode() throws Exception {
// given
NewIndexDescriptor index = createUniquenessConstraint(labelId, propertyId1);
String value = "value";
createNodeWithValue("other_" + value);
// when looking for it
ReadOperations readOperations = readOperationsInNewTransaction();
long foundId = readOperations.nodeGetFromUniqueIndexSeek(index, exact(propertyId1, value));
commit();
// then
assertTrue("Non-matching created node was found", isNoSuchNode(foundId));
}
Aggregations