use of org.neo4j.graphdb.RelationshipType in project neo4j by neo4j.
the class PECListingIT method canListRelationshipPropertyExistenceConstraints.
@Test
public void canListRelationshipPropertyExistenceConstraints() throws Exception {
// GIVEN
RelationshipType relType = RelationshipType.withName("KNOWS");
SchemaHelper.createRelPropertyExistenceConstraint(db, relType, "since");
// WHEN / THEN
executeCommand("schema ls", "ON \\(\\)-\\[knows:KNOWS\\]-\\(\\) ASSERT exists\\(knows.since\\)");
}
use of org.neo4j.graphdb.RelationshipType in project neo4j by neo4j.
the class PECListingIT method canListBothNodeAndRelationshipPropertyExistenceConstraintsByLabelAndType.
@Test
public void canListBothNodeAndRelationshipPropertyExistenceConstraintsByLabelAndType() throws Exception {
// GIVEN
Label label = label("Person");
RelationshipType relType = RelationshipType.withName("KNOWS");
// WHEN
SchemaHelper.createNodePropertyExistenceConstraint(db, label, "name");
SchemaHelper.createRelPropertyExistenceConstraint(db, relType, "since");
// THEN
executeCommand("schema ls -l :Person -r :KNOWS", "ON \\(person:Person\\) ASSERT exists\\(person.name\\)", "ON \\(\\)-\\[knows:KNOWS\\]-\\(\\) ASSERT exists\\(knows.since\\)");
}
use of org.neo4j.graphdb.RelationshipType in project neo4j by neo4j.
the class PECListingIT method canListBothNodeAndRelationshipPropertyExistenceConstraints.
@Test
public void canListBothNodeAndRelationshipPropertyExistenceConstraints() throws Exception {
// GIVEN
Label label = label("Person");
RelationshipType relType = RelationshipType.withName("KNOWS");
// WHEN
SchemaHelper.createNodePropertyExistenceConstraint(db, label, "name");
SchemaHelper.createRelPropertyExistenceConstraint(db, relType, "since");
// THEN
executeCommand("schema ls", "ON \\(person:Person\\) ASSERT exists\\(person.name\\)", "ON \\(\\)-\\[knows:KNOWS\\]-\\(\\) ASSERT exists\\(knows.since\\)");
}
use of org.neo4j.graphdb.RelationshipType in project neo4j by neo4j.
the class PECListingIT method shouldHaveCorrectIndentationsInSchemaListing.
@Test
public void shouldHaveCorrectIndentationsInSchemaListing() throws Exception {
// GIVEN
Label label = label("Person");
RelationshipType relType = RelationshipType.withName("KNOWS");
// WHEN
SchemaHelper.createUniquenessConstraint(db, label, "name");
SchemaHelper.createNodePropertyExistenceConstraint(db, label, "name");
SchemaHelper.createRelPropertyExistenceConstraint(db, relType, "since");
SchemaHelper.awaitIndexes(db);
// THEN
executeCommand("schema", "Indexes", " ON :Person\\(name\\) ONLINE \\(for uniqueness constraint\\)", "Constraints", " ON \\(person:Person\\) ASSERT person.name IS UNIQUE", " ON \\(person:Person\\) ASSERT exists\\(person.name\\)", " ON \\(\\)-\\[knows:KNOWS\\]-\\(\\) ASSERT exists\\(knows.since\\)");
}
use of org.neo4j.graphdb.RelationshipType in project neo4j by neo4j.
the class CircularGraphTest method testCircularBug.
@Test
public void testCircularBug() {
final long timestamp = 3;
try (Transaction tx = beginTx()) {
getNodeWithName("2").setProperty("timestamp", 1L);
getNodeWithName("3").setProperty("timestamp", 2L);
tx.success();
}
try (Transaction tx2 = beginTx()) {
final RelationshipType type = RelationshipType.withName("TO");
Iterator<Node> nodes = getGraphDb().traversalDescription().depthFirst().relationships(type, Direction.OUTGOING).evaluator(path -> {
Relationship rel = path.lastRelationship();
boolean relIsOfType = rel != null && rel.isType(type);
boolean prune = relIsOfType && (Long) path.endNode().getProperty("timestamp") >= timestamp;
return Evaluation.of(relIsOfType, !prune);
}).traverse(node("1")).nodes().iterator();
assertEquals("2", nodes.next().getProperty("name"));
assertEquals("3", nodes.next().getProperty("name"));
assertFalse(nodes.hasNext());
}
}
Aggregations