use of org.neo4j.kernel.impl.api.state.ConstraintIndexCreator in project neo4j by neo4j.
the class ConstraintIndexCreatorTest method shouldReleaseSchemaLockWhileAwaitingIndexPopulation.
@Test
public void shouldReleaseSchemaLockWhileAwaitingIndexPopulation() throws Exception {
// given
StubKernel kernel = new StubKernel();
IndexingService indexingService = mock(IndexingService.class);
StatementOperationParts constraintCreationContext = mockedParts();
PropertyAccessor propertyAccessor = mock(PropertyAccessor.class);
KernelStatement state = mockedState();
when(constraintCreationContext.schemaReadOperations().indexGetCommittedId(state, index)).thenReturn(2468L);
IndexProxy indexProxy = mock(IndexProxy.class);
when(indexingService.getIndexProxy(anyLong())).thenReturn(indexProxy);
ConstraintIndexCreator creator = new ConstraintIndexCreator(() -> kernel, indexingService, propertyAccessor, true);
// when
creator.createUniquenessConstraintIndex(state, constraintCreationContext.schemaReadOperations(), index.schema());
// then
verify(state.locks().pessimistic()).releaseExclusive(ResourceTypes.SCHEMA, ResourceTypes.schemaResource());
verify(state.locks().pessimistic()).acquireExclusive(state.lockTracer(), ResourceTypes.SCHEMA, ResourceTypes.schemaResource());
}
Aggregations