public void ResponseMessageConsistencyTest1() { var original = new Response() { Id = Guid.NewGuid(), IsSuccess = false, Data = new byte[] { 0xAA, 0xBB, 0xCC, 0xDD } }; // Serializing var serializer = new MessageSerializingVisitor(); original.Accept(serializer); var serializedData = serializer.Result; Assert.NotNull(serializedData); Assert.True(serializedData.Length > 0); // Deserializing var deserializer = new MessageDeserializingVisitor() { DataBuffer = serializedData, DataLength = serializedData.Length, BufferOffset = 0 }; var reconstructedMessage = new Response(); reconstructedMessage.Accept(deserializer); Assert.AreEqual(original.Id, reconstructedMessage.Id); Assert.AreEqual(original.IsSuccess, reconstructedMessage.IsSuccess); Assert.AreEqual(original.Data, reconstructedMessage.Data); }
public static Response Cast(this Response response) { var builder = new ResponseBuilder(); var visitor = new ResponseToBuilderVisitor(builder); response.Accept(visitor); return(builder.Type(null).Query(false).Build()); }
public static QueryResponse <T> CastQuery <T>(this Response response) { var builder = new ResponseBuilder(); var visitor = new ResponseToBuilderVisitor(builder); response.Accept(visitor); return(builder.Type(typeof(T)).Query(true).BuildQuery <T>()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void unpackResponse(org.neo4j.com.Response<?> response, ResponseUnpacker_TxHandler txHandler) throws Exception public override void UnpackResponse <T1>(Response <T1> response, ResponseUnpacker_TxHandler txHandler) { if (_stopped) { throw new System.InvalidOperationException("Component is currently stopped"); } BatchingResponseHandler responseHandler = new BatchingResponseHandler(_maxBatchSize, _batchCommitter, _obligationFulfiller, txHandler, _versionContextSupplier, _log); try { response.Accept(responseHandler); } finally { responseHandler.ApplyQueuedTransactions(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHaveFixedTargetTransactionIdEvenIfLastTransactionIdIsMoving() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHaveFixedTargetTransactionIdEvenIfLastTransactionIdIsMoving() { // GIVEN LogicalTransactionStore transactionStore = mock(typeof(LogicalTransactionStore)); long lastAppliedTransactionId = 5L; TransactionCursor endlessCursor = new EndlessCursor(this, lastAppliedTransactionId + 1); when(transactionStore.getTransactions(anyLong())).thenReturn(endlessCursor); const long targetTransactionId = 8L; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.TransactionIdStore transactionIdStore = new org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore(targetTransactionId, 0, BASE_TX_COMMIT_TIMESTAMP, 0, 0); TransactionIdStore transactionIdStore = new SimpleTransactionIdStore(targetTransactionId, 0, BASE_TX_COMMIT_TIMESTAMP, 0, 0); ResponsePacker packer = new ResponsePacker(transactionStore, transactionIdStore, Suppliers.singleton(StoreIdTestFactory.newStoreIdForCurrentVersion())); // WHEN Response <object> response = packer.PackTransactionStreamResponse(RequestContextStartingAt(5L), null); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicLong nextExpectedVisit = new java.util.concurrent.atomic.AtomicLong(lastAppliedTransactionId); AtomicLong nextExpectedVisit = new AtomicLong(lastAppliedTransactionId); response.Accept(new HandlerAnonymousInnerClass(this, targetTransactionId, transactionIdStore, nextExpectedVisit)); }