use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class IndexValuesValidationTest method validateLegacyIndexedRelationshipProperties.
@Test
public void validateLegacyIndexedRelationshipProperties() {
Label label = Label.label("legacyIndexedRelationshipPropertiesTestLabel");
String propertyName = "legacyIndexedRelationshipProperties";
String legacyIndexedRelationshipIndex = "legacyIndexedRelationshipIndex";
RelationshipType indexType = RelationshipType.withName("legacyIndexType");
try (Transaction transaction = database.beginTx()) {
Node source = database.createNode(label);
Node destination = database.createNode(label);
Relationship relationship = source.createRelationshipTo(destination, indexType);
database.index().forRelationships(legacyIndexedRelationshipIndex).add(relationship, propertyName, "shortString");
transaction.success();
}
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Property value bytes length: 32767 is longer then 32766, " + "which is maximum supported length of indexed property value.");
try (Transaction transaction = database.beginTx()) {
Node source = database.createNode(label);
Node destination = database.createNode(label);
Relationship relationship = source.createRelationshipTo(destination, indexType);
String longValue = StringUtils.repeat("a", IndexWriter.MAX_TERM_LENGTH + 1);
database.index().forRelationships(legacyIndexedRelationshipIndex).add(relationship, propertyName, longValue);
transaction.success();
}
}
use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class IndexValuesValidationTest method validateIndexedNodeProperties.
@Test
public void validateIndexedNodeProperties() throws Exception {
Label label = Label.label("indexedNodePropertiesTestLabel");
String propertyName = "indexedNodePropertyName";
createIndex(label, propertyName);
try (Transaction ignored = database.beginTx()) {
database.schema().awaitIndexesOnline(5, TimeUnit.MINUTES);
}
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Property value bytes length: 32767 is longer then 32766, " + "which is maximum supported length of indexed property value.");
try (Transaction transaction = database.beginTx()) {
Node node = database.createNode(label);
node.setProperty(propertyName, StringUtils.repeat("a", IndexWriter.MAX_TERM_LENGTH + 1));
transaction.success();
}
}
use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class IndexValuesValidationTest method validateNodePropertiesOnPopulation.
@Test
public void validateNodePropertiesOnPopulation() {
Label label = Label.label("populationTestNodeLabel");
String propertyName = "populationTestPropertyName";
try (Transaction transaction = database.beginTx()) {
Node node = database.createNode(label);
node.setProperty(propertyName, StringUtils.repeat("a", IndexWriter.MAX_TERM_LENGTH + 1));
transaction.success();
}
IndexDefinition indexDefinition = createIndex(label, propertyName);
try {
try (Transaction ignored = database.beginTx()) {
database.schema().awaitIndexesOnline(5, TimeUnit.MINUTES);
}
} catch (IllegalStateException e) {
try (Transaction ignored = database.beginTx()) {
String indexFailure = database.schema().getIndexFailure(indexDefinition);
assertThat("", indexFailure, Matchers.startsWith("java.lang.IllegalArgumentException: " + "Property value bytes length: 32767 is longer then 32766, " + "which is maximum supported length of indexed property value."));
}
}
}
use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method prepareDb.
private void prepareDb() {
Label countryLabel = Label.label(COUNTRY_LABEL);
Label color = Label.label(COLOR_LABEL);
Label car = Label.label(CAR_LABEL);
try (Transaction transaction = embeddedDatabase.beginTx()) {
createNamedLabeledNode(countryLabel, "Sweden");
createNamedLabeledNode(countryLabel, "USA");
createNamedLabeledNode(color, "red");
createNamedLabeledNode(color, "green");
createNamedLabeledNode(car, "Volvo");
createNamedLabeledNode(car, "Ford");
for (int i = 0; i < 250; i++) {
embeddedDatabase.createNode();
}
transaction.success();
}
}
use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class DatabaseContentVerifier method verifyJohnnyLabels.
public void verifyJohnnyLabels() {
// Johnny labels has got a bunch of alter egos
try (Transaction tx = database.beginTx()) {
Node johhnyLabels = database.getNodeById(1);
Set<String> expectedLabels = new HashSet<>();
for (int i = 0; i < 30; i++) {
expectedLabels.add("AlterEgo" + i);
}
for (Label label : johhnyLabels.getLabels()) {
assertTrue(expectedLabels.remove(label.name()));
}
assertTrue(expectedLabels.isEmpty());
tx.success();
}
}
Aggregations