//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void closeStatementOnClose() public virtual void CloseStatementOnClose() { KernelTransaction kernelTransaction = mock(typeof(KernelTransaction)); Statement statement = mock(typeof(Statement)); when(kernelTransaction.AcquireStatement()).thenReturn(statement); //noinspection EmptyTryBlock using (IndexProcedures ignored = new IndexProcedures(kernelTransaction, null)) { } verify(statement).close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void before() public virtual void Before() { ThreadToStatementContextBridge bridge = mock(typeof(ThreadToStatementContextBridge)); Statement statement = mock(typeof(Statement)); when(bridge.Get()).thenReturn(statement); _kernelTransaction = spy(typeof(KernelTransaction)); _locks = mock(typeof(Locks)); when(_kernelTransaction.locks()).thenReturn(_locks); _placeboTx = new PlaceboTransaction(_kernelTransaction); _resource = mock(typeof(Node)); when(_resource.Id).thenReturn(1L); }
/// <param name="start"> the label of the start node of relationships to get the number of, or {@code null} for "any". </param> /// <param name="type"> the type of the relationships to get the number of, or {@code null} for "any". </param> /// <param name="end"> the label of the end node of relationships to get the number of, or {@code null} for "any". </param> private long CountsForRelationship(Label start, RelationshipType type, Label end) { KernelTransaction ktx = _ktxSupplier.get(); using (Statement ignore = ktx.AcquireStatement()) { TokenRead tokenRead = ktx.TokenRead(); int startId; int typeId; int endId; // start if (start == null) { startId = [email protected]_Fields.ANY_LABEL; } else { if ([email protected]_Fields.NO_TOKEN == (startId = tokenRead.NodeLabel(start.Name()))) { return(0); } } // type if (type == null) { typeId = [email protected]_Fields.ANY_RELATIONSHIP_TYPE; } else { if ([email protected]_Fields.NO_TOKEN == (typeId = tokenRead.RelationshipType(type.Name()))) { return(0); } } // end if (end == null) { endId = [email protected]_Fields.ANY_LABEL; } else { if ([email protected]_Fields.NO_TOKEN == (endId = tokenRead.NodeLabel(end.Name()))) { return(0); } } return(ktx.DataRead().countsForRelationship(startId, typeId, endId)); } }
public override IndexHits <Relationship> Query(object queryOrQueryObjectOrNull, Node startNodeOrNull, Node endNodeOrNull) { KernelTransaction ktx = TxBridge.get(); try { using (Statement ignore = ktx.AcquireStatement()) { RelationshipExplicitIndexCursor cursor = ktx.Cursors().allocateRelationshipExplicitIndexCursor(); long source = startNodeOrNull == null ? NO_SUCH_NODE : startNodeOrNull.Id; long target = endNodeOrNull == null ? NO_SUCH_NODE : endNodeOrNull.Id; ktx.IndexRead().relationshipExplicitIndexQuery(cursor, NameConflict, queryOrQueryObjectOrNull, source, target); return(new CursorWrappingRelationshipIndexHits(cursor, GraphDatabase, ktx, NameConflict)); } } catch (ExplicitIndexNotFoundKernelException) { throw new NotFoundException(Type + " index '" + NameConflict + "' doesn't exist"); } }
private void SetUpMocks() { _database = mock(typeof(Database)); _databaseFacade = mock(typeof(GraphDatabaseFacade)); _resolver = mock(typeof(DependencyResolver)); _executionEngine = mock(typeof(ExecutionEngine)); _statementBridge = mock(typeof(ThreadToStatementContextBridge)); _databaseQueryService = mock(typeof(GraphDatabaseQueryService)); _kernelTransaction = mock(typeof(KernelTransaction)); _statement = mock(typeof(Statement)); _request = mock(typeof(HttpServletRequest)); InternalTransaction transaction = new TopLevelTransaction(_kernelTransaction); LoginContext loginContext = AUTH_DISABLED; KernelTransaction.Type type = KernelTransaction.Type.@implicit; QueryRegistryOperations registryOperations = mock(typeof(QueryRegistryOperations)); when(_statement.queryRegistration()).thenReturn(registryOperations); when(_statementBridge.get()).thenReturn(_statement); when(_kernelTransaction.securityContext()).thenReturn(loginContext.Authorize(s => - 1, GraphDatabaseSettings.DEFAULT_DATABASE_NAME)); when(_kernelTransaction.transactionType()).thenReturn(type); when(_database.Graph).thenReturn(_databaseFacade); when(_databaseFacade.DependencyResolver).thenReturn(_resolver); when(_resolver.resolveDependency(typeof(QueryExecutionEngine))).thenReturn(_executionEngine); when(_resolver.resolveDependency(typeof(ThreadToStatementContextBridge))).thenReturn(_statementBridge); when(_resolver.resolveDependency(typeof(GraphDatabaseQueryService))).thenReturn(_databaseQueryService); when(_databaseQueryService.beginTransaction(type, loginContext)).thenReturn(transaction); when(_databaseQueryService.beginTransaction(type, loginContext, CUSTOM_TRANSACTION_TIMEOUT, TimeUnit.MILLISECONDS)).thenReturn(transaction); when(_databaseQueryService.DependencyResolver).thenReturn(_resolver); when(_request.Scheme).thenReturn("http"); when(_request.RemoteAddr).thenReturn("127.0.0.1"); when(_request.RemotePort).thenReturn(5678); when(_request.ServerName).thenReturn("127.0.0.1"); when(_request.ServerPort).thenReturn(7474); when(_request.RequestURI).thenReturn("/"); }
internal TransactionStateChecker(Statement statement, IsNodeDeletedInCurrentTx nodeCheck, IsRelationshipDeletedInCurrentTx relCheck) { this._statement = statement; this._nodeCheck = nodeCheck; this._relCheck = relCheck; }