public BoltStateMachineV1Context(BoltStateMachine machine, BoltChannel boltChannel, BoltStateMachineSPI spi, MutableConnectionState connectionState, Clock clock)
 {
     this._machine         = machine;
     this._boltChannel     = boltChannel;
     this._spi             = spi;
     this._connectionState = connectionState;
     this._clock           = clock;
 }
Beispiel #2
0
        public BoltStateMachineV1(BoltStateMachineSPI spi, BoltChannel boltChannel, Clock clock)
        {
            this._id                     = boltChannel.Id();
            this._boltChannel            = boltChannel;
            this._spi                    = spi;
            this.ConnectionStateConflict = new MutableConnectionState();
            this._context                = new BoltStateMachineV1Context(this, boltChannel, spi, ConnectionStateConflict, clock);

            States states = BuildStates();

            this._state       = states.Initial;
            this._failedState = states.Failed;
        }
Beispiel #3
0
//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)));
        }