//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldAddServerVersionMetadataOnHelloMessage() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldAddServerVersionMetadataOnHelloMessage() { // Given // hello message IDictionary <string, object> meta = map("user_agent", "3.0", PRINCIPAL, "neo4j", CREDENTIALS, "password"); HelloMessage helloMessage = new HelloMessage(meta); // setup state machine ConnectedState state = new ConnectedState(); BoltStateMachineState readyState = mock(typeof(BoltStateMachineState)); StateMachineContext context = mock(typeof(StateMachineContext)); BoltStateMachineSPI boltSpi = mock(typeof(BoltStateMachineSPI), RETURNS_MOCKS); MutableConnectionState connectionState = new MutableConnectionState(); state.ReadyState = readyState; when(context.BoltSpi()).thenReturn(boltSpi); when(context.ConnectionState()).thenReturn(connectionState); when(boltSpi.Version()).thenReturn("42.42.42"); MutableConnectionState connectionStateMock = mock(typeof(MutableConnectionState)); when(context.ConnectionState()).thenReturn(connectionStateMock); when(context.ConnectionId()).thenReturn("connection-uuid"); when(boltSpi.Authenticate(meta)).thenReturn(AuthenticationResult.AUTH_DISABLED); // When BoltStateMachineState newState = state.Process(helloMessage, context); // Then assertEquals(readyState, newState); verify(connectionStateMock).onMetadata("server", stringValue("42.42.42")); verify(connectionStateMock).onMetadata(eq("connection_id"), any(typeof(StringValue))); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.bolt.runtime.BoltStateMachineState process(org.neo4j.bolt.messaging.RequestMessage message, org.neo4j.bolt.runtime.StateMachineContext context) throws org.neo4j.bolt.runtime.BoltConnectionFatality public override BoltStateMachineState Process(RequestMessage message, StateMachineContext context) { AssertInitialized(); if (message is HelloMessage) { HelloMessage helloMessage = ( HelloMessage )message; string userAgent = helloMessage.UserAgent(); IDictionary <string, object> authToken = helloMessage.AuthToken(); if (processAuthentication(userAgent, authToken, context)) { context.ConnectionState().onMetadata(CONNECTION_ID_KEY, Values.stringValue(context.ConnectionId())); return(_readyState); } else { return(null); } } return(null); }