//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCloseAutoCommitTransactionAndRespondToNextStatementWhenStreamingFails() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCloseAutoCommitTransactionAndRespondToNextStatementWhenStreamingFails() { // Given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.bolt.runtime.BoltStateMachine machine = env.newMachine(BOLT_CHANNEL); BoltStateMachine machine = Env.newMachine(_boltChannel); machine.Process(new InitMessage(USER_AGENT, emptyMap()), nullResponseHandler()); BoltResponseRecorder recorder = new BoltResponseRecorder(); // When machine.Process(new RunMessage("UNWIND [1, 0] AS x RETURN 1 / x", EMPTY_MAP), recorder); machine.Process(PullAllMessage.INSTANCE, recorder); machine.Process(AckFailureMessage.INSTANCE, recorder); machine.Process(new RunMessage("RETURN 2", EMPTY_MAP), recorder); machine.Process(PullAllMessage.INSTANCE, recorder); // Then assertThat(recorder.NextResponse(), succeeded()); assertThat(recorder.NextResponse(), allOf(containsRecord(1L), failedWithStatus(Org.Neo4j.Kernel.Api.Exceptions.Status_Statement.ArithmeticError))); assertThat(recorder.NextResponse(), succeeded()); assertThat(recorder.NextResponse(), succeeded()); assertThat(recorder.NextResponse(), succeededWithRecord(2L)); assertEquals(0, recorder.ResponseCount()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReceiveBookmarkOnCommitAndPullAll() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReceiveBookmarkOnCommitAndPullAll() { // Given BoltResponseRecorder recorder = new BoltResponseRecorder(); BoltStateMachine machine = Env.newMachine(_boltChannel); machine.Process(new InitMessage(USER_AGENT, emptyMap()), nullResponseHandler()); // When machine.Process(new RunMessage("BEGIN", EMPTY_MAP), recorder); machine.Process(DiscardAllMessage.INSTANCE, recorder); machine.Process(new RunMessage("CREATE (a:Person)", EMPTY_MAP), recorder); machine.Process(DiscardAllMessage.INSTANCE, recorder); machine.Process(new RunMessage("COMMIT", EMPTY_MAP), recorder); machine.Process(PullAllMessage.INSTANCE, recorder); // Then assertThat(recorder.NextResponse(), succeeded()); assertThat(recorder.NextResponse(), succeeded()); assertThat(recorder.NextResponse(), succeeded()); assertThat(recorder.NextResponse(), succeeded()); assertThat(recorder.NextResponse(), succeeded()); assertThat(recorder.NextResponse(), succeededWithMetadata("bookmark", _bookmarkPattern)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReadYourOwnWrites() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReadYourOwnWrites() { using (Transaction tx = Env.graph().beginTx()) { Node node = Env.graph().createNode(Label.label("A")); node.SetProperty("prop", "one"); tx.Success(); } BinaryLatch latch = new BinaryLatch(); long dbVersion = Env.lastClosedTxId(); Thread thread = new Thread(() => { try { using (BoltStateMachine machine = Env.newMachine(_boltChannel)) { machine.process(new InitMessage(USER_AGENT, emptyMap()), nullResponseHandler()); latch.Await(); machine.process(new RunMessage("MATCH (n:A) SET n.prop = 'two'", EMPTY_MAP), nullResponseHandler()); machine.process(PullAllMessage.INSTANCE, nullResponseHandler()); } } catch (BoltConnectionFatality connectionFatality) { throw new Exception(connectionFatality); } }); thread.Start(); long dbVersionAfterWrite = dbVersion + 1; using (BoltStateMachine machine = Env.newMachine(_boltChannel)) { BoltResponseRecorder recorder = new BoltResponseRecorder(); machine.process(new InitMessage(USER_AGENT, emptyMap()), nullResponseHandler()); latch.Release(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String bookmark = "neo4j:bookmark:v1:tx" + dbVersionAfterWrite; string bookmark = "neo4j:bookmark:v1:tx" + dbVersionAfterWrite; machine.process(new RunMessage("BEGIN", ValueUtils.asMapValue(singletonMap("bookmark", bookmark))), nullResponseHandler()); machine.process(PullAllMessage.INSTANCE, recorder); machine.process(new RunMessage("MATCH (n:A) RETURN n.prop", EMPTY_MAP), nullResponseHandler()); machine.process(PullAllMessage.INSTANCE, recorder); machine.process(new RunMessage("COMMIT", EMPTY_MAP), nullResponseHandler()); machine.process(PullAllMessage.INSTANCE, recorder); assertThat(recorder.NextResponse(), succeeded()); assertThat(recorder.NextResponse(), succeededWithRecord("two")); assertThat(recorder.NextResponse(), succeededWithMetadata("bookmark", _bookmarkPattern)); } thread.Join(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldMoveToInterruptedOnInterrupt() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldMoveToInterruptedOnInterrupt() { // Given BoltStateMachineV3 machine = BoltStateMachineInTxReadyState; // When BoltResponseRecorder recorder = new BoltResponseRecorder(); machine.Process(InterruptSignal.INSTANCE, recorder); // Then assertThat(machine.State(), instanceOf(typeof(InterruptedState))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldMoveToReadyOnRollback_succ() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldMoveToReadyOnRollbackSucc() { BoltStateMachineV3 machine = BoltStateMachineInTxReadyState; // When BoltResponseRecorder recorder = new BoltResponseRecorder(); machine.Process(ROLLBACK_MESSAGE, recorder); // Then assertThat(recorder.NextResponse(), succeeded()); assertThat(machine.State(), instanceOf(typeof(ReadyState))); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void shouldCloseConnectionOnIllegalMessages(org.neo4j.bolt.messaging.RequestMessage message) throws Throwable private void ShouldCloseConnectionOnIllegalMessages(RequestMessage message) { // Given BoltStateMachineV3 machine = BoltStateMachineInTxReadyState; // when BoltResponseRecorder recorder = new BoltResponseRecorder(); verifyKillsConnection(() => machine.process(message, recorder)); // then assertThat(recorder.NextResponse(), failedWithStatus(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.Invalid)); assertNull(machine.State()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest @MethodSource("ignoredMessages") void shouldIgnoreMessages(org.neo4j.bolt.messaging.RequestMessage message) throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldIgnoreMessages(RequestMessage message) { // Given BoltStateMachineV3 machine = BoltStateMachineInFailedState; // When BoltResponseRecorder recorder = new BoltResponseRecorder(); machine.Process(message, recorder); // Then assertThat(recorder.NextResponse(), wasIgnored()); assertThat(machine.State(), instanceOf(typeof(FailedState))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldMoveToInterruptedOnInterrupt() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldMoveToInterruptedOnInterrupt() { // Given BoltStateMachineV3 machine = NewStateMachine(); machine.Process(NewHelloMessage(), nullResponseHandler()); // When BoltResponseRecorder recorder = new BoltResponseRecorder(); machine.Process(InterruptSignal.INSTANCE, recorder); // Then assertThat(machine.State(), instanceOf(typeof(InterruptedState))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldMoveToReadyOnCommit_succ() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldMoveToReadyOnCommitSucc() { BoltStateMachineV3 machine = BoltStateMachineInTxReadyState; // When BoltResponseRecorder recorder = new BoltResponseRecorder(); machine.Process(COMMIT_MESSAGE, recorder); // Then RecordedBoltResponse response = recorder.NextResponse(); assertThat(response, succeeded()); assertTrue(response.HasMetadata("bookmark")); assertThat(machine.State(), instanceOf(typeof(ReadyState))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldMoveToStreamingOnRun_succ() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldMoveToStreamingOnRunSucc() { // Given BoltStateMachineV3 machine = BoltStateMachineInTxReadyState; // When BoltResponseRecorder recorder = new BoltResponseRecorder(); machine.Process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k", EmptyParams), recorder); // Then RecordedBoltResponse response = recorder.NextResponse(); assertTrue(response.HasMetadata("fields")); assertTrue(response.HasMetadata("t_first")); assertThat(machine.State(), instanceOf(typeof(TransactionStreamingState))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldMoveFromTxStreamingToTxReadyOnDiscardAll_succ() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldMoveFromTxStreamingToTxReadyOnDiscardAllSucc() { // Given BoltStateMachineV3 machine = BoltStateMachineInTxStreamingState; // When BoltResponseRecorder recorder = new BoltResponseRecorder(); machine.Process(DiscardAllMessage.INSTANCE, recorder); // Then RecordedBoltResponse response = recorder.NextResponse(); assertThat(response, succeeded()); assertFalse(response.HasMetadata("bookmark")); assertThat(machine.State(), instanceOf(typeof(TransactionReadyState))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotFailWhenOutOfOrderRollbackInAutoCommitMode() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotFailWhenOutOfOrderRollbackInAutoCommitMode() { // Given BoltResponseRecorder runRecorder = new BoltResponseRecorder(); BoltResponseRecorder pullAllRecorder = new BoltResponseRecorder(); BoltStateMachine machine = Env.newMachine(_boltChannel); machine.Process(new InitMessage(USER_AGENT, emptyMap()), nullResponseHandler()); // When machine.Process(new RunMessage("ROLLBACK", EMPTY_MAP), runRecorder); machine.Process(PullAllMessage.INSTANCE, pullAllRecorder); // Then assertThat(runRecorder.NextResponse(), succeeded()); assertThat(pullAllRecorder.NextResponse(), succeeded()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldMoveToFailedStateOnBegin_fail() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldMoveToFailedStateOnBeginFail() { // Given BoltStateMachineV3 machine = NewStateMachine(); machine.Process(NewHelloMessage(), nullResponseHandler()); // When BoltResponseRecorder recorder = new BoltResponseRecorder(); BeginMessage beginMessage = mock(typeof(BeginMessage)); when(beginMessage.Bookmark()).thenThrow(new Exception("Fail")); machine.Process(beginMessage, recorder); // Then assertThat(recorder.NextResponse(), failedWithStatus(Org.Neo4j.Kernel.Api.Exceptions.Status_General.UnknownError)); assertThat(machine.State(), instanceOf(typeof(FailedState))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldMoveToStreamingOnBegin_succ() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldMoveToStreamingOnBeginSucc() { // Given BoltStateMachineV3 machine = NewStateMachine(); machine.Process(NewHelloMessage(), nullResponseHandler()); // When BoltResponseRecorder recorder = new BoltResponseRecorder(); machine.Process(new BeginMessage(), recorder); // Then RecordedBoltResponse response = recorder.NextResponse(); assertThat(response, succeeded()); assertThat(machine.State(), instanceOf(typeof(TransactionReadyState))); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: public boolean matches(final Object item) public override bool matches(object item) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.bolt.runtime.BoltStateMachine machine = (org.neo4j.bolt.runtime.BoltStateMachine) item; BoltStateMachine machine = ( BoltStateMachine )item; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final BoltResponseRecorder recorder = new BoltResponseRecorder(); BoltResponseRecorder recorder = new BoltResponseRecorder(); try { machine.Process(ResetMessage.INSTANCE, recorder); return(recorder.ResponseCount() == 1 && InState(typeof(ReadyState)).matches(item)); } catch (BoltConnectionFatality) { return(false); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void shouldThrowExceptionOnIllegalMessagesInStreamingState(org.neo4j.bolt.messaging.RequestMessage message) throws Throwable private void ShouldThrowExceptionOnIllegalMessagesInStreamingState(RequestMessage message) { // Given BoltStateMachineV3 machine = NewStateMachine(); machine.Process(NewHelloMessage(), nullResponseHandler()); machine.Process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k", EmptyParams), nullResponseHandler()); assertThat(machine.State(), instanceOf(typeof(StreamingState))); // when BoltResponseRecorder recorder = new BoltResponseRecorder(); verifyKillsConnection(() => machine.process(message, recorder)); // then assertThat(recorder.NextResponse(), failedWithStatus(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.Invalid)); assertNull(machine.State()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldMoveFromStreamingToReadyOnPullAll_succ() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldMoveFromStreamingToReadyOnPullAllSucc() { // Given BoltStateMachineV3 machine = BoltStateMachineInStreamingState; // When BoltResponseRecorder recorder = new BoltResponseRecorder(); machine.Process(PullAllMessage.INSTANCE, recorder); // Then RecordedBoltResponse response = recorder.NextResponse(); assertThat(response, succeeded()); assertTrue(response.HasMetadata("type")); assertTrue(response.HasMetadata("t_last")); assertTrue(response.HasMetadata("bookmark")); assertThat(machine.State(), instanceOf(typeof(ReadyState))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldInterpretEmptyStatementAsReuseLastStatementInAutocommitTransaction() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldInterpretEmptyStatementAsReuseLastStatementInAutocommitTransaction() { // Given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.bolt.runtime.BoltStateMachine machine = env.newMachine(BOLT_CHANNEL); BoltStateMachine machine = Env.newMachine(_boltChannel); machine.Process(new InitMessage(USER_AGENT, emptyMap()), nullResponseHandler()); BoltResponseRecorder recorder = new BoltResponseRecorder(); // When machine.Process(new RunMessage("RETURN 1", EMPTY_MAP), nullResponseHandler()); machine.Process(PullAllMessage.INSTANCE, recorder); machine.Process(new RunMessage("", EMPTY_MAP), nullResponseHandler()); machine.Process(PullAllMessage.INSTANCE, recorder); // Then assertThat(recorder.NextResponse(), succeededWithRecord(1L)); assertThat(recorder.NextResponse(), succeededWithRecord(1L)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertSchedulerWorks(org.neo4j.bolt.runtime.BoltConnection connection) throws InterruptedException private void AssertSchedulerWorks(BoltConnection connection) { BoltResponseRecorder recorder = new BoltResponseRecorder(); connection.Enqueue(_machine => _machine.process(ResetMessage.INSTANCE, recorder)); try { RecordedBoltResponse response = recorder.NextResponse(); assertThat(response.Message(), equalTo(SUCCESS)); assertThat((( BoltStateMachineV1 )_machine).state(), instanceOf(typeof(ReadyState))); assertThat(_liveTransactions.get(), equalTo(0L)); } catch (AssertionError e) { //JAVA TO C# CONVERTER TODO TASK: The following line has a Java format specifier which cannot be directly translated to .NET: //ORIGINAL LINE: throw new AssertionError(String.format("Expected session to return to good state after RESET, but " + "assertion failed: %s.%n" + "Seed: %s%n" + "Messages sent:%n" + "%s", e.getMessage(), seed, org.neo4j.helpers.collection.Iterables.toString(sent, "\n")), e); throw new AssertionError(string.Format("Expected session to return to good state after RESET, but " + "assertion failed: %s.%n" + "Seed: %s%n" + "Messages sent:%n" + "%s", e.Message, _seed, Iterables.ToString(_sent, "\n")), e); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleBeginCommit() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleBeginCommit() { // Given BoltResponseRecorder recorder = new BoltResponseRecorder(); BoltStateMachine machine = Env.newMachine(_boltChannel); machine.Process(new InitMessage(USER_AGENT, emptyMap()), nullResponseHandler()); // When machine.Process(new RunMessage("BEGIN", EMPTY_MAP), recorder); machine.Process(DiscardAllMessage.INSTANCE, nullResponseHandler()); machine.Process(new RunMessage("CREATE (n:InTx)", EMPTY_MAP), recorder); machine.Process(DiscardAllMessage.INSTANCE, nullResponseHandler()); machine.Process(new RunMessage("COMMIT", EMPTY_MAP), recorder); machine.Process(DiscardAllMessage.INSTANCE, nullResponseHandler()); // Then assertThat(recorder.NextResponse(), succeeded()); assertThat(recorder.NextResponse(), succeeded()); assertThat(recorder.NextResponse(), succeeded()); }