Search in sources :

Example 1 with SchemaWrite

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();
    }
}
Also used : SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) KernelTransactionImplementation(org.neo4j.kernel.impl.api.KernelTransactionImplementation) IndexPrototype(org.neo4j.internal.schema.IndexPrototype) Test(org.junit.jupiter.api.Test)

Example 2 with SchemaWrite

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));
}
Also used : SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 3 with SchemaWrite

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));
}
Also used : SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 4 with SchemaWrite

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));
}
Also used : SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 5 with SchemaWrite

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"));
}
Also used : SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite)

Aggregations

SchemaWrite (org.neo4j.internal.kernel.api.SchemaWrite)27 Test (org.junit.jupiter.api.Test)21 KernelIntegrationTest (org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)15 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)11 TokenWrite (org.neo4j.internal.kernel.api.TokenWrite)9 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)9 LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)5 ProcedureException (org.neo4j.internal.kernel.api.exceptions.ProcedureException)4 SchemaKernelException (org.neo4j.internal.kernel.api.exceptions.schema.SchemaKernelException)4 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)4 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)4 SchemaRead (org.neo4j.internal.kernel.api.SchemaRead)3 FulltextSchemaDescriptor (org.neo4j.internal.schema.FulltextSchemaDescriptor)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 FutureTask (java.util.concurrent.FutureTask)2 Timeout (org.junit.jupiter.api.Timeout)2 KernelException (org.neo4j.exceptions.KernelException)2 Resource (org.neo4j.graphdb.Resource)2 SchemaDescriptor (org.neo4j.internal.schema.SchemaDescriptor)2 IndexBackedConstraintDescriptor (org.neo4j.internal.schema.constraints.IndexBackedConstraintDescriptor)2