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'.");
}
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);
}
Aggregations