use of org.neo4j.internal.kernel.api.SchemaWrite in project neo4j by neo4j.
the class FulltextIndexProviderTest method validateMustThrowIfSchemaIsNotFulltext.
@Test
void validateMustThrowIfSchemaIsNotFulltext() throws Exception {
try (KernelTransactionImplementation transaction = getKernelTransaction()) {
int[] propertyIds = { propIdHa };
SchemaDescriptor schema = SchemaDescriptor.forLabel(labelIdHa, propertyIds);
IndexPrototype prototype = IndexPrototype.forSchema(schema).withIndexType(FULLTEXT).withName(NAME);
SchemaWrite schemaWrite = transaction.schemaWrite();
var e = assertThrows(IllegalArgumentException.class, () -> schemaWrite.indexCreate(prototype));
assertThat(e.getMessage()).contains("schema is not a full-text index schema");
transaction.success();
}
}
use of org.neo4j.internal.kernel.api.SchemaWrite in project neo4j by neo4j.
the class IndexCreateIT method shouldFailCreateIndexWithDuplicateProperties.
@Test
void shouldFailCreateIndexWithDuplicateProperties() throws KernelException {
// given
TokenWrite tokenWrite = tokenWriteInNewTransaction();
int labelId = tokenWrite.labelGetOrCreateForName("Label");
int propId = tokenWrite.propertyKeyGetOrCreateForName("property");
commit();
SchemaWrite schemaWrite = schemaWriteInNewTransaction();
// when
final FulltextSchemaDescriptor descriptor = SchemaDescriptor.fulltext(EntityType.NODE, new int[] { labelId }, new int[] { propId, propId });
// then
assertThrows(RepeatedPropertyInSchemaException.class, () -> schemaWrite.indexCreate(descriptor, null));
}
use of org.neo4j.internal.kernel.api.SchemaWrite in project neo4j by neo4j.
the class IndexCreateIT method shouldFailCreateIndexWithDuplicateRelationshipTypes.
@Test
void shouldFailCreateIndexWithDuplicateRelationshipTypes() throws KernelException {
// given
TokenWrite tokenWrite = tokenWriteInNewTransaction();
int relTypeId = tokenWrite.relationshipTypeGetOrCreateForName("RELATIONSHIP");
int propId = tokenWrite.propertyKeyGetOrCreateForName("property");
commit();
SchemaWrite schemaWrite = schemaWriteInNewTransaction();
// when
final FulltextSchemaDescriptor descriptor = SchemaDescriptor.fulltext(EntityType.RELATIONSHIP, new int[] { relTypeId, relTypeId }, new int[] { propId });
// then
assertThrows(RepeatedRelationshipTypeInSchemaException.class, () -> schemaWrite.indexCreate(descriptor, null));
}
use of org.neo4j.internal.kernel.api.SchemaWrite in project neo4j by neo4j.
the class IndexCreateIT method shouldFailCreateIndexWithDuplicateLabels.
@Test
void shouldFailCreateIndexWithDuplicateLabels() throws KernelException {
// given
TokenWrite tokenWrite = tokenWriteInNewTransaction();
int labelId = tokenWrite.labelGetOrCreateForName("Label");
int propId = tokenWrite.propertyKeyGetOrCreateForName("property");
commit();
SchemaWrite schemaWrite = schemaWriteInNewTransaction();
// when
final FulltextSchemaDescriptor descriptor = SchemaDescriptor.fulltext(EntityType.NODE, new int[] { labelId, labelId }, new int[] { propId });
// then
assertThrows(RepeatedLabelInSchemaException.class, () -> schemaWrite.indexCreate(descriptor, null));
}
use of org.neo4j.internal.kernel.api.SchemaWrite in project neo4j by neo4j.
the class IndexCreateIT method shouldFailWithNonExistentProviderName.
protected void shouldFailWithNonExistentProviderName(IndexCreator creator) throws KernelException {
// given
TokenWrite tokenWrite = tokenWriteInNewTransaction();
int labelId = tokenWrite.labelGetOrCreateForName("Label");
int propId = tokenWrite.propertyKeyGetOrCreateForName("property");
commit();
SchemaWrite schemaWrite = schemaWriteInNewTransaction();
// when
assertThrows(IndexProviderNotFoundException.class, () -> creator.create(schemaWrite, forLabel(labelId, propId), "something-completely-different", "index name"));
}
Aggregations