@Test
  public void shouldAcquireSchemaReadLockBeforeRetrievingAllConstraintsl() throws Exception {
    // given
    SchemaReadOperations delegate = mock(SchemaReadOperations.class);
    @SuppressWarnings("unchecked")
    Iterator<UniquenessConstraint> constraints = mock(Iterator.class);
    when(delegate.constraintsGetAll(state)).thenReturn(constraints);

    LockingStatementOperations context = new LockingStatementOperations(null, delegate, null, null);

    // when
    Iterator<UniquenessConstraint> result = context.constraintsGetAll(state);

    // then
    assertEquals(constraints, result);
    InOrder order = inOrder(lockHolder, delegate);
    order.verify(lockHolder).acquireSchemaReadLock();
    order.verify(delegate).constraintsGetAll(state);
    verifyNoMoreInteractions(lockHolder, delegate);
  }
  @Test
  public void shouldAcquireSchemaReadLockBeforeRetrievingIndexRule() throws Exception {
    // given
    SchemaReadOperations delegate = mock(SchemaReadOperations.class);
    @SuppressWarnings("unchecked")
    Iterator<IndexDescriptor> rules = mock(Iterator.class);
    when(delegate.indexesGetAll(state)).thenReturn(rules);

    LockingStatementOperations context = new LockingStatementOperations(null, delegate, null, null);

    // when
    Iterator<IndexDescriptor> result = context.indexesGetAll(state);

    // then
    assertSame(rules, result);
    InOrder order = inOrder(lockHolder, delegate);
    order.verify(lockHolder).acquireSchemaReadLock();
    order.verify(delegate).indexesGetAll(state);
    verifyNoMoreInteractions(lockHolder, delegate);
  }