@Test
  public void shouldAcquireSchemaWriteLockBeforeAddingIndexRule() throws Exception {
    // given
    SchemaWriteOperations delegate = mock(SchemaWriteOperations.class);
    IndexDescriptor rule = mock(IndexDescriptor.class);
    when(delegate.indexCreate(state, 123, 456)).thenReturn(rule);

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

    // when
    IndexDescriptor result = context.indexCreate(state, 123, 456);

    // then
    assertSame(rule, result);
    InOrder order = inOrder(lockHolder, delegate);
    order.verify(lockHolder).acquireSchemaWriteLock();
    order.verify(delegate).indexCreate(state, 123, 456);
    verifyNoMoreInteractions(lockHolder, delegate);
  }
  @Test
  public void shouldAcquireSchemaWriteLockBeforeAddingUniquenessConstraint() throws Exception {
    // given
    SchemaWriteOperations delegate = mock(SchemaWriteOperations.class);
    UniquenessConstraint constraint = mock(UniquenessConstraint.class);
    when(delegate.uniquenessConstraintCreate(state, 123, 456)).thenReturn(constraint);

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

    // when
    UniquenessConstraint result = context.uniquenessConstraintCreate(state, 123, 456);

    // then
    assertEquals(constraint, result);
    InOrder order = inOrder(lockHolder, delegate);
    order.verify(lockHolder).acquireSchemaWriteLock();
    order.verify(delegate).uniquenessConstraintCreate(state, 123, 456);
    verifyNoMoreInteractions(lockHolder, delegate);
  }