Search in sources :

Example 6 with TransactionStateMachineSPIProvider

use of org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider in project neo4j by neo4j.

the class TransactionStateMachineSPIProviderV4Test method shouldErrorIfDatabaseNotFound.

@Test
void shouldErrorIfDatabaseNotFound() {
    DatabaseManagementService managementService = mock(DatabaseManagementService.class);
    var databaseName = "database";
    when(managementService.database(databaseName)).thenThrow(new DatabaseNotFoundException(databaseName));
    TransactionStateMachineSPIProvider spiProvider = newSpiProvider(managementService);
    BoltIOException error = assertThrows(BoltIOException.class, () -> spiProvider.getTransactionStateMachineSPI(databaseName, mock(StatementProcessorReleaseManager.class)));
    assertThat(error.status()).isEqualTo(Status.Database.DatabaseNotFound);
    assertThat(error.getMessage()).contains("Database does not exist. Database name: 'database'.");
}
Also used : BoltIOException(org.neo4j.bolt.messaging.BoltIOException) DatabaseNotFoundException(org.neo4j.dbms.api.DatabaseNotFoundException) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) TransactionStateMachineSPIProvider(org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider) Test(org.junit.jupiter.api.Test)

Example 7 with TransactionStateMachineSPIProvider

use of org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider in project neo4j by neo4j.

the class TransactionStateMachineSPIProviderV4Test method shouldReturnDefaultTransactionStateMachineSPIWithEmptyDatabasename.

@Test
void shouldReturnDefaultTransactionStateMachineSPIWithEmptyDatabasename() throws Throwable {
    String databaseName = "neo4j";
    DatabaseManagementService managementService = managementService(databaseName);
    TransactionStateMachineSPIProvider spiProvider = newSpiProvider(managementService);
    when(mockBoltChannel.defaultDatabase()).thenReturn("neo4j");
    TransactionStateMachineSPI spi = spiProvider.getTransactionStateMachineSPI("", mock(StatementProcessorReleaseManager.class, RETURNS_MOCKS));
    assertThat(spi).isInstanceOf(TransactionStateMachineV4SPI.class);
}
Also used : StatementProcessorReleaseManager(org.neo4j.bolt.runtime.statemachine.StatementProcessorReleaseManager) TransactionStateMachineSPI(org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPI) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) TransactionStateMachineSPIProvider(org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider) Test(org.junit.jupiter.api.Test)

Aggregations

TransactionStateMachineSPIProvider (org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider)7 Test (org.junit.jupiter.api.Test)5 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)5 StatementProcessorReleaseManager (org.neo4j.bolt.runtime.statemachine.StatementProcessorReleaseManager)4 TransactionStateMachineSPI (org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPI)3 BoltChannel (org.neo4j.bolt.BoltChannel)1 BoltIOException (org.neo4j.bolt.messaging.BoltIOException)1 BoltProtocolBreachFatality (org.neo4j.bolt.runtime.BoltProtocolBreachFatality)1 BoltStateMachine (org.neo4j.bolt.runtime.statemachine.BoltStateMachine)1 BoltStateMachineSPI (org.neo4j.bolt.runtime.statemachine.BoltStateMachineSPI)1 BoltStateMachineV4 (org.neo4j.bolt.v4.BoltStateMachineV4)1 DatabaseNotFoundException (org.neo4j.dbms.api.DatabaseNotFoundException)1 DefaultDatabaseResolver (org.neo4j.kernel.database.DefaultDatabaseResolver)1