예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void listAllIndexesWithFailedIndex() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ListAllIndexesWithFailedIndex()
        {
            // Given
            Transaction transaction    = NewTransaction(AUTH_DISABLED);
            int         failedLabel    = transaction.TokenWrite().labelGetOrCreateForName("Fail");
            int         propertyKeyId1 = transaction.TokenWrite().propertyKeyGetOrCreateForName("foo");

            _failNextIndexPopulation.set(true);
            LabelSchemaDescriptor descriptor = forLabel(failedLabel, propertyKeyId1);

            transaction.SchemaWrite().indexCreate(descriptor);
            Commit();

            //let indexes come online
            try
            {
                using (Org.Neo4j.Graphdb.Transaction ignored = Db.beginTx())
                {
                    Db.schema().awaitIndexesOnline(2, MINUTES);
                    fail("Expected to fail when awaiting for index to come online");
                }
            }
            catch (System.InvalidOperationException)
            {
                // expected
            }

            // When
            RawIterator <object[], ProcedureException> stream = Procs().procedureCallRead(Procs().procedureGet(procedureName("db", "indexes")).id(), new object[0], ProcedureCallContext.EMPTY);

            assertTrue(stream.HasNext());
            object[] result = stream.Next();
            assertFalse(stream.HasNext());

            // Then
            assertEquals("INDEX ON :Fail(foo)", result[0]);
            assertEquals("Unnamed index", result[1]);
            assertEquals(Collections.singletonList("Fail"), result[2]);
            assertEquals(Collections.singletonList("foo"), result[3]);
            assertEquals("FAILED", result[4]);
            assertEquals("node_label_property", result[5]);
            assertEquals(0.0, result[6]);
            IDictionary <string, string> providerDescriptionMap = MapUtil.stringMap("key", GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10.providerKey(), "version", GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10.providerVersion());

            assertEquals(providerDescriptionMap, result[7]);
            assertEquals(IndexingService.getIndexId(descriptor), result[8]);
            assertThat(( string )result[9], containsString("java.lang.RuntimeException: Fail on update during population"));

            Commit();
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Setup()
        {
            _procs.registerComponent(typeof(KernelTransaction), ctx => ctx.get(KERNEL_TRANSACTION), false);
            _procs.registerComponent(typeof(DependencyResolver), ctx => ctx.get(_dependencyResolver), false);
            _procs.registerComponent(typeof(GraphDatabaseAPI), ctx => ctx.get(_graphdatabaseapi), false);
            _procs.registerComponent(typeof(SecurityContext), ctx => ctx.get(SECURITY_CONTEXT), true);

            _procs.registerComponent(typeof(Log), ctx => ctx.get(_log), false);
            _procs.registerType(typeof(Node), NTNode);
            _procs.registerType(typeof(Relationship), NTRelationship);
            _procs.registerType(typeof(Path), NTPath);

            (new SpecialBuiltInProcedures("1.3.37", Edition.enterprise.ToString())).accept(_procs);
            _procs.registerProcedure(typeof(BuiltInProcedures));
            _procs.registerProcedure(typeof(BuiltInDbmsProcedures));

            when(_tx.acquireStatement()).thenReturn(_statement);
            when(_tx.tokenRead()).thenReturn(_tokens);
            when(_tx.dataRead()).thenReturn(_read);
            when(_tx.schemaRead()).thenReturn(_schemaRead);
            when(_schemaRead.snapshot()).thenReturn(_schemaReadCore);

            when(_tokens.propertyKeyGetAllTokens()).thenAnswer(AsTokens(_propKeys));
            when(_tokens.labelsGetAllTokens()).thenAnswer(AsTokens(_labels));
            when(_tokens.relationshipTypesGetAllTokens()).thenAnswer(AsTokens(_relTypes));
            when(_schemaReadCore.indexesGetAll()).thenAnswer(i => Iterators.concat(_indexes.GetEnumerator(), _uniqueIndexes.GetEnumerator()));
            when(_schemaReadCore.index(any(typeof(SchemaDescriptor)))).thenAnswer((Answer <IndexReference>)invocationOnMock =>
            {
                SchemaDescriptor schema = invocationOnMock.getArgument(0);
                int label = Schema.keyId();
                int prop  = Schema.PropertyId;
                return(GetIndexReference(label, prop));
            });
            when(_schemaReadCore.constraintsGetAll()).thenAnswer(i => _constraints.GetEnumerator());

            when(_tokens.propertyKeyName(anyInt())).thenAnswer(invocation => _propKeys[invocation.getArgument(0)]);
            when(_tokens.nodeLabelName(anyInt())).thenAnswer(invocation => _labels[invocation.getArgument(0)]);
            when(_tokens.relationshipTypeName(anyInt())).thenAnswer(invocation => _relTypes[invocation.getArgument(0)]);

            when(_indexingService.getIndexId(any(typeof(SchemaDescriptor)))).thenReturn(42L);

            when(_schemaReadCore.constraintsGetForRelationshipType(anyInt())).thenReturn(emptyIterator());
            when(_schemaReadCore.indexesGetForLabel(anyInt())).thenReturn(emptyIterator());
            when(_schemaReadCore.indexesGetForRelationshipType(anyInt())).thenReturn(emptyIterator());
            when(_schemaReadCore.constraintsGetForLabel(anyInt())).thenReturn(emptyIterator());
            when(_read.countsForNode(anyInt())).thenReturn(1L);
            when(_read.countsForRelationship(anyInt(), anyInt(), anyInt())).thenReturn(1L);
            when(_schemaReadCore.indexGetState(any(typeof(IndexReference)))).thenReturn(InternalIndexState.ONLINE);
        }
예제 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private long tryGetIndexId(org.neo4j.internal.kernel.api.schema.SchemaDescriptor descriptor) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException
        private long TryGetIndexId(SchemaDescriptor descriptor)
        {
            return(_indexService.getIndexId(descriptor));
        }