use of org.neo4j.graphdb.schema.IndexCreator in project neo4j by neo4j.
the class SchemaAcceptanceTest method indexSettingValuesMustHaveCorrectType.
@Test
void indexSettingValuesMustHaveCorrectType() {
try (Transaction tx = db.beginTx()) {
IndexCreator creator = tx.schema().indexFor(label).withName("my_index").on(propertyKey);
assertThrows(IllegalArgumentException.class, () -> creator.withIndexType(IndexType.FULLTEXT).withIndexConfiguration(Map.of(IndexSettingImpl.FULLTEXT_ANALYZER, 1)).create());
assertThrows(IllegalArgumentException.class, () -> creator.withIndexType(IndexType.FULLTEXT).withIndexConfiguration(Map.of(IndexSettingImpl.FULLTEXT_ANALYZER, true)).create());
assertThrows(IllegalArgumentException.class, () -> creator.withIndexType(IndexType.FULLTEXT).withIndexConfiguration(Map.of(IndexSettingImpl.FULLTEXT_EVENTUALLY_CONSISTENT, "true")).create());
assertThrows(IllegalArgumentException.class, () -> creator.withIndexType(IndexType.FULLTEXT).withIndexConfiguration(Map.of(IndexSettingImpl.FULLTEXT_EVENTUALLY_CONSISTENT, 1)).create());
assertThrows(IllegalArgumentException.class, () -> creator.withIndexConfiguration(Map.of(IndexSettingImpl.SPATIAL_CARTESIAN_MAX, "1")).create());
assertThrows(IllegalArgumentException.class, () -> creator.withIndexConfiguration(Map.of(IndexSettingImpl.SPATIAL_CARTESIAN_MAX, 1)).create());
assertThrows(IllegalArgumentException.class, () -> creator.withIndexConfiguration(Map.of(IndexSettingImpl.SPATIAL_CARTESIAN_MAX, 1.0)).create());
tx.commit();
}
}
use of org.neo4j.graphdb.schema.IndexCreator in project neo4j by neo4j.
the class SchemaAcceptanceTest method createIndexNoWait.
static IndexDefinition createIndexNoWait(GraphDatabaseService db, String name, RelationshipType relType, String... properties) {
IndexDefinition indexDef;
try (Transaction tx = db.beginTx()) {
IndexCreator indexCreator = tx.schema().indexFor(relType);
for (String property : properties) {
indexCreator = indexCreator.on(property);
}
if (name != null) {
indexCreator = indexCreator.withName(name);
}
indexDef = indexCreator.create();
tx.commit();
}
return indexDef;
}
use of org.neo4j.graphdb.schema.IndexCreator in project neo4j by neo4j.
the class SchemaAcceptanceTest method indexNamesInTransactionStateMustBeUniqueEvenWhenGenerated.
@Test
void indexNamesInTransactionStateMustBeUniqueEvenWhenGenerated() {
try (Transaction tx = db.beginTx()) {
IndexDefinition index = tx.schema().indexFor(label).on(propertyKey).create();
IndexCreator creator = tx.schema().indexFor(otherLabel).on(secondPropertyKey).withName(index.getName());
ConstraintViolationException exception = assertThrows(ConstraintViolationException.class, creator::create);
assertThat(exception).hasMessageContaining(alreadyExistsIndexMessage(index.getName()));
tx.commit();
}
}
use of org.neo4j.graphdb.schema.IndexCreator in project neo4j by neo4j.
the class SchemaAcceptanceTest method indexNamesInTransactionStateMustBeUniqueEvenWhenGenerated2.
@Test
void indexNamesInTransactionStateMustBeUniqueEvenWhenGenerated2() {
try (Transaction tx = db.beginTx()) {
IndexDefinition index = tx.schema().indexFor(otherLabel).on(secondPropertyKey).withName("index_a0d2924").create();
IndexCreator creator = tx.schema().indexFor(label).on(propertyKey);
ConstraintViolationException exception = assertThrows(ConstraintViolationException.class, creator::create);
assertThat(exception).hasMessageContaining(alreadyExistsIndexMessage(index.getName()));
tx.commit();
}
}
Aggregations