Search in sources :

Example 6 with SchemaWriteOperations

use of org.neo4j.kernel.api.SchemaWriteOperations in project neo4j by neo4j.

the class IndexIT method shouldNotListIndexesAmongConstraintIndexes.

@Test
public void shouldNotListIndexesAmongConstraintIndexes() throws Exception {
    // given
    SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
    schemaWriteOperations.indexCreate(SchemaBoundary.map(descriptor));
    commit();
    // then/when
    ReadOperations readOperations = readOperationsInNewTransaction();
    assertFalse(readOperations.uniqueIndexesGetAll().hasNext());
    assertFalse(readOperations.uniqueIndexesGetForLabel(labelId).hasNext());
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) SchemaWriteOperations(org.neo4j.kernel.api.SchemaWriteOperations) Test(org.junit.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 7 with SchemaWriteOperations

use of org.neo4j.kernel.api.SchemaWriteOperations in project neo4j by neo4j.

the class IndexIT method shouldDisallowDroppingIndexThatDoesNotExist.

@Test
public void shouldDisallowDroppingIndexThatDoesNotExist() throws Exception {
    // given
    NewIndexDescriptor index;
    {
        SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
        index = statement.indexCreate(SchemaBoundary.map(descriptor));
        commit();
    }
    {
        SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
        statement.indexDrop(index);
        commit();
    }
    // when
    try {
        SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
        statement.indexDrop(index);
        commit();
    }// then
     catch (SchemaKernelException e) {
        assertEquals("Unable to drop index on :label[" + labelId + "](property[" + propertyKeyId + "]): " + "No such INDEX ON :label[" + labelId + "](property[" + propertyKeyId + "]).", e.getMessage());
    }
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) SchemaWriteOperations(org.neo4j.kernel.api.SchemaWriteOperations) SchemaKernelException(org.neo4j.kernel.api.exceptions.schema.SchemaKernelException) Test(org.junit.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 8 with SchemaWriteOperations

use of org.neo4j.kernel.api.SchemaWriteOperations in project neo4j by neo4j.

the class IndexIT method rollBackIndexRuleShouldNotBeCommitted.

@Test
public void rollBackIndexRuleShouldNotBeCommitted() throws Exception {
    // GIVEN
    SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
    // WHEN
    schemaWriteOperations.indexCreate(SchemaBoundary.map(descriptor));
    // don't mark as success
    rollback();
    // THEN
    ReadOperations readOperations = readOperationsInNewTransaction();
    assertEquals(emptySetOf(NewIndexDescriptor.class), asSet(readOperations.indexesGetForLabel(labelId)));
    commit();
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) SchemaWriteOperations(org.neo4j.kernel.api.SchemaWriteOperations) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 9 with SchemaWriteOperations

use of org.neo4j.kernel.api.SchemaWriteOperations in project neo4j by neo4j.

the class IndexIT method committedAndTransactionalIndexRulesShouldBeMerged.

@Test
public void committedAndTransactionalIndexRulesShouldBeMerged() throws Exception {
    // GIVEN
    SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
    NewIndexDescriptor existingRule = schemaWriteOperations.indexCreate(SchemaBoundary.map(descriptor));
    commit();
    // WHEN
    Statement statement = statementInNewTransaction(AnonymousContext.AUTH_DISABLED);
    NewIndexDescriptor addedRule = statement.schemaWriteOperations().indexCreate(SchemaDescriptorFactory.forLabel(labelId, 10));
    Set<NewIndexDescriptor> indexRulesInTx = asSet(statement.readOperations().indexesGetForLabel(labelId));
    commit();
    // THEN
    assertEquals(asSet(existingRule, addedRule), indexRulesInTx);
}
Also used : SchemaWriteOperations(org.neo4j.kernel.api.SchemaWriteOperations) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Statement(org.neo4j.kernel.api.Statement) Test(org.junit.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 10 with SchemaWriteOperations

use of org.neo4j.kernel.api.SchemaWriteOperations in project neo4j by neo4j.

the class AbstractConstraintCreationIT method shouldClearSchemaStateWhenConstraintIsCreated.

@Test
public void shouldClearSchemaStateWhenConstraintIsCreated() throws Exception {
    // given
    SchemaStateCheck schemaState = new SchemaStateCheck().setUp();
    SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
    // when
    createConstraint(statement, descriptor);
    commit();
    // then
    schemaState.assertCleared(readOperationsInNewTransaction());
    rollback();
}
Also used : SchemaWriteOperations(org.neo4j.kernel.api.SchemaWriteOperations) Test(org.junit.Test)

Aggregations

SchemaWriteOperations (org.neo4j.kernel.api.SchemaWriteOperations)20 Test (org.junit.Test)19 ReadOperations (org.neo4j.kernel.api.ReadOperations)9 KernelIntegrationTest (org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)8 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)5 Statement (org.neo4j.kernel.api.Statement)4 Iterator (java.util.Iterator)2 ResourceIterator (org.neo4j.graphdb.ResourceIterator)2 DropConstraintFailureException (org.neo4j.kernel.api.exceptions.schema.DropConstraintFailureException)2 SchemaKernelException (org.neo4j.kernel.api.exceptions.schema.SchemaKernelException)2 UniquenessConstraintDescriptor (org.neo4j.kernel.api.schema_new.constaints.UniquenessConstraintDescriptor)2 ArrayList (java.util.ArrayList)1 Node (org.neo4j.graphdb.Node)1 QueryExecutionException (org.neo4j.graphdb.QueryExecutionException)1 Transaction (org.neo4j.graphdb.Transaction)1 TokenWriteOperations (org.neo4j.kernel.api.TokenWriteOperations)1 ProcedureException (org.neo4j.kernel.api.exceptions.ProcedureException)1 AlreadyConstrainedException (org.neo4j.kernel.api.exceptions.schema.AlreadyConstrainedException)1 ConstraintValidationException (org.neo4j.kernel.api.exceptions.schema.ConstraintValidationException)1 CreateConstraintFailureException (org.neo4j.kernel.api.exceptions.schema.CreateConstraintFailureException)1