Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReuseExistingOrphanedConstraintIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReuseExistingOrphanedConstraintIndex()
        {
            // given
            IndexingService indexingService = mock(typeof(IndexingService));
            StubKernel      kernel          = new StubKernel(this);

            long orphanedConstraintIndexId = 111;

            when(_schemaRead.indexGetCommittedId(_indexReference)).thenReturn(orphanedConstraintIndexId);
            IndexProxy indexProxy = mock(typeof(IndexProxy));

            when(indexingService.GetIndexProxy(orphanedConstraintIndexId)).thenReturn(indexProxy);
            NodePropertyAccessor nodePropertyAccessor = mock(typeof(NodePropertyAccessor));

            when(_schemaRead.index(_descriptor)).thenReturn(_indexReference);
            when(_schemaRead.indexGetOwningUniquenessConstraintId(_indexReference)).thenReturn(null);                     // which means it has no owner
            ConstraintIndexCreator creator = new ConstraintIndexCreator(() => kernel, indexingService, nodePropertyAccessor, _logProvider);

            // when
            KernelTransactionImplementation transaction = CreateTransaction();
            long indexId = creator.CreateUniquenessConstraintIndex(transaction, _descriptor, DefaultProvider);

            // then
            assertEquals(orphanedConstraintIndexId, indexId);
            assertEquals("There should have been no need to acquire a statement to create the constraint index", 0, kernel.Transactions.Count);
            verify(_schemaRead).indexGetCommittedId(_indexReference);
            verify(_schemaRead).index(_descriptor);
            verify(_schemaRead).indexGetOwningUniquenessConstraintId(_indexReference);
            verifyNoMoreInteractions(_schemaRead);
            verify(indexProxy).awaitStoreScanCompleted(anyLong(), any());
        }