Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.internal.kernel.api.IndexReference getIndex(IndexSpecifier specifier) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        private IndexReference GetIndex(IndexSpecifier specifier)
        {
            if (!string.ReferenceEquals(specifier.Name(), null))
            {
                // Find index by name.
                IndexReference indexReference = _ktx.schemaRead().indexGetForName(specifier.Name());

                if (indexReference == IndexReference.NO_INDEX)
                {
                    throw new ProcedureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Schema.IndexNotFound, "No such index '%s'", specifier);
                }
                return(indexReference);
            }
            else
            {
                // Find index by label and properties.
                int            labelId        = GetLabelId(specifier.Label());
                int[]          propertyKeyIds = GetPropertyIds(specifier.Properties());
                IndexReference indexReference = _ktx.schemaRead().index(labelId, propertyKeyIds);

                if (indexReference == IndexReference.NO_INDEX)
                {
                    throw new ProcedureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Schema.IndexNotFound, "No such index %s", specifier);
                }
                return(indexReference);
            }
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            _transaction   = mock(typeof(KernelTransaction));
            _tokenRead     = mock(typeof(TokenRead));
            _schemaRead    = mock(typeof(SchemaRead));
            _procedure     = new IndexProcedures(_transaction, null);
            _descriptor    = SchemaDescriptorFactory.forLabel(123, 456);
            _anyDescriptor = SchemaDescriptorFactory.forLabel(0, 0);
            _anyIndex      = forSchema(_anyDescriptor);
            when(_transaction.tokenRead()).thenReturn(_tokenRead);
            when(_transaction.schemaRead()).thenReturn(_schemaRead);
        }
Пример #3
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);
        }
Пример #4
0
 public override SchemaRead SchemaRead()
 {
     return(Internal.schemaRead());
 }