use of org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor in project neo4j by neo4j.
the class NodeGetUniqueFromIndexSeekIT method createUniquenessConstraint.
private NewIndexDescriptor createUniquenessConstraint(int labelId, int... propertyIds) throws Exception {
Statement statement = statementInNewTransaction(SecurityContext.AUTH_DISABLED);
LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(labelId, propertyIds);
statement.schemaWriteOperations().uniquePropertyConstraintCreate(descriptor);
NewIndexDescriptor result = statement.readOperations().uniqueIndexGetForLabelAndPropertyKey(SchemaBoundary.map(descriptor));
commit();
return result;
}
use of org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor in project neo4j by neo4j.
the class StateHandlingStatementOperationsTest method shouldNeverDelegateWrites.
@Test
public void shouldNeverDelegateWrites() throws Exception {
KernelStatement state = mockedState();
when(state.txState()).thenReturn(new TxState());
StoreStatement storeStatement = mock(StoreStatement.class);
when(state.getStoreStatement()).thenReturn(storeStatement);
when(inner.indexesGetForLabel(0)).thenReturn(iterator(NewIndexDescriptorFactory.forLabel(0, 0)));
when(storeStatement.acquireSingleNodeCursor(anyLong())).thenReturn(asNodeCursor(0));
when(inner.nodeGetProperties(eq(storeStatement), any(NodeItem.class))).thenReturn(asPropertyCursor());
StateHandlingStatementOperations ctx = newTxStateOps(inner);
// When
LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(0, 0);
ctx.indexCreate(state, descriptor);
ctx.nodeAddLabel(state, 0, 0);
ctx.indexDrop(state, NewIndexDescriptorFactory.forSchema(descriptor));
ctx.nodeRemoveLabel(state, 0, 0);
// one for add and one for remove
verify(storeStatement, times(2)).acquireSingleNodeCursor(0);
verifyNoMoreInteractions(storeStatement);
}
use of org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor in project neo4j by neo4j.
the class SchemaCacheTest method shouldResolveIndexDescriptor.
@Test
public void shouldResolveIndexDescriptor() throws Exception {
// Given
SchemaCache cache = newSchemaCache();
cache.addSchemaRule(newIndexRule(1L, 1, 2));
cache.addSchemaRule(newIndexRule(2L, 1, 3));
cache.addSchemaRule(newIndexRule(3L, 2, 2));
// When
LabelSchemaDescriptor schema = SchemaDescriptorFactory.forLabel(1, 3);
NewIndexDescriptor descriptor = cache.indexDescriptor(schema);
// Then
assertThat(descriptor.schema(), equalTo(schema));
}
Aggregations