Exemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.neo4j.kernel.api.KernelTransaction mockKernelTransaction() throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException
        private static KernelTransaction MockKernelTransaction()
        {
            SchemaRead schemaRead = mock(typeof(SchemaRead));

            when(schemaRead.IndexGetState(any(typeof(IndexReference)))).thenReturn(InternalIndexState.FAILED);
            when(schemaRead.IndexGetFailure(any(typeof(IndexReference)))).thenReturn(Exceptions.stringify(_cause));

            KernelTransaction kt = mock(typeof(KernelTransaction));

            when(kt.TokenRead()).thenReturn(mock(typeof(TokenRead)));
            when(kt.SchemaRead()).thenReturn(schemaRead);
            when(kt.Terminated).thenReturn(false);
            when(kt.AcquireStatement()).thenReturn(mock(typeof(Statement)));
            return(kt);
        }
Exemplo n.º 2
0
        public override string GetIndexFailure(IndexDefinition index)
        {
            KernelTransaction transaction = SafeAcquireTransaction(_transactionSupplier);

            try
            {
                using (Statement ignore = transaction.AcquireStatement())
                {
                    SchemaRead     schemaRead = transaction.SchemaRead();
                    IndexReference descriptor = GetIndexReference(schemaRead, transaction.TokenRead(), (IndexDefinitionImpl)index);
                    return(schemaRead.IndexGetFailure(descriptor));
                }
            }
            catch (Exception e) when(e is SchemaRuleNotFoundException || e is IndexNotFoundKernelException)
            {
                throw NewIndexNotFoundException(index, e);
            }
        }