Search in sources :

Example 91 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class SchemaTransactionStateTest method addedRulesShouldBeVisibleInTx.

@Test
public void addedRulesShouldBeVisibleInTx() throws Exception {
    // GIVEN
    commitNoLabels();
    // WHEN
    NewIndexDescriptor rule1 = indexCreate(txContext, state, labelId1, key1);
    NewIndexDescriptor rule2 = indexCreate(txContext, state, labelId2, key2);
    // THEN
    assertEquals(asSet(rule1), Iterators.asSet(txContext.indexesGetForLabel(state, labelId1)));
    verify(store).indexesGetForLabel(labelId1);
    assertEquals(asSet(rule2), Iterators.asSet(txContext.indexesGetForLabel(state, labelId2)));
    verify(store).indexesGetForLabel(labelId2);
    assertEquals(asSet(rule1, rule2), Iterators.asSet(txContext.indexesGetAll(state)));
    verify(store).indexesGetAll();
    verifyNoMoreInteractions(store);
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test)

Example 92 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class SchemaTransactionStateTest method shouldReturnNonExistentRuleAddedInTransactionFromLookup.

@Test
public void shouldReturnNonExistentRuleAddedInTransactionFromLookup() throws Exception {
    // GIVEN
    // -- the store already have an index on the label and a different property
    NewIndexDescriptor existingRule1 = NewIndexDescriptorFactory.forLabel(labelId1, key1);
    when(indexGetForLabelAndPropertyKey(store, labelId1, key1)).thenReturn(existingRule1);
    // -- the store already have an index on a different label with the same property
    NewIndexDescriptor existingRule2 = NewIndexDescriptorFactory.forLabel(labelId2, key2);
    when(indexGetForLabelAndPropertyKey(store, labelId2, key2)).thenReturn(existingRule2);
    // -- a non-existent index has been added in the transaction
    indexCreate(txContext, state, labelId1, key2);
    // WHEN
    NewIndexDescriptor index = indexGetForLabelAndPropertyKey(txContext, state, labelId1, key2);
    // THEN
    assertEquals(NewIndexDescriptorFactory.forLabel(labelId1, key2), index);
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test)

Example 93 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class SchemaTransactionStateTest method addedAdditionalRuleShouldBeVisibleInTx.

@Test
public void addedAdditionalRuleShouldBeVisibleInTx() throws Exception {
    // GIVEN
    commitNoLabels();
    // WHEN
    NewIndexDescriptor rule1 = indexCreate(txContext, state, labelId1, key1);
    NewIndexDescriptor rule2 = indexCreate(txContext, state, labelId1, key2);
    // THEN
    assertEquals(asSet(rule1, rule2), Iterators.asSet(txContext.indexesGetForLabel(state, labelId1)));
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test)

Example 94 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class SchemaTransactionStateTest method addedRuleShouldBeVisibleInTx.

@Test
public void addedRuleShouldBeVisibleInTx() throws Exception {
    // GIVEN
    commitNoLabels();
    // WHEN
    NewIndexDescriptor index = indexCreate(txContext, state, labelId1, key1);
    // THEN
    assertEquals(asSet(index), Iterators.asSet(txContext.indexesGetForLabel(state, labelId1)));
    verify(store).indexesGetForLabel(labelId1);
    assertEquals(asSet(index), Iterators.asSet(txContext.indexesGetAll(state)));
    verify(store).indexesGetAll();
    verifyNoMoreInteractions(store);
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test)

Example 95 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class SchemaCacheTest method shouldReturnNullWhenNoIndexExists.

@Test
public void shouldReturnNullWhenNoIndexExists() {
    // Given
    SchemaCache schemaCache = newSchemaCache();
    // When
    NewIndexDescriptor indexDescriptor = schemaCache.indexDescriptor(SchemaDescriptorFactory.forLabel(1, 1));
    // Then
    assertNull(indexDescriptor);
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test)

Aggregations

NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)99 Test (org.junit.Test)55 Statement (org.neo4j.kernel.api.Statement)24 ReadOperations (org.neo4j.kernel.api.ReadOperations)17 IndexNotFoundKernelException (org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException)10 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)9 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)9 InternalIndexState (org.neo4j.kernel.api.index.InternalIndexState)7 Transaction (org.neo4j.graphdb.Transaction)6 IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)5 IndexEntryConflictException (org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)5 SchemaRuleNotFoundException (org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException)5 LabelSchemaDescriptor (org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 PrimitiveLongSet (org.neo4j.collection.primitive.PrimitiveLongSet)4 Label (org.neo4j.graphdb.Label)4 NotFoundException (org.neo4j.graphdb.NotFoundException)4 KernelException (org.neo4j.kernel.api.exceptions.KernelException)4 NodePropertyDescriptor (org.neo4j.kernel.api.schema.NodePropertyDescriptor)4