Example usage for org.hibernate.boot.model.naming ImplicitNameSource getBuildingContext

List of usage examples for org.hibernate.boot.model.naming ImplicitNameSource getBuildingContext

Introduction

In this page you can find the example usage for org.hibernate.boot.model.naming ImplicitNameSource getBuildingContext.

Prototype

MetadataBuildingContext getBuildingContext();

Source Link

Document

Access to the current building context.

Usage

From source file:org.ligoj.bootstrap.core.dao.ImplicitNamingStrategyNiceJpaImplTest.java

License:MIT License

private void mockContext(final ImplicitNameSource source) {
    final var context = Mockito.mock(MetadataBuildingContext.class);
    final var collector = Mockito.mock(InFlightMetadataCollector.class);
    final var database = Mockito.mock(Database.class);
    final var jdbcEnvironment = Mockito.mock(JdbcEnvironment.class);
    final var identifierHelper = Mockito.mock(IdentifierHelper.class);
    Mockito.when(identifierHelper.toIdentifier(ArgumentMatchers.anyString()))
            .then((Answer<Identifier>) invocation -> DatabaseIdentifier
                    .toIdentifier((String) invocation.getArguments()[0]));
    Mockito.when(jdbcEnvironment.getIdentifierHelper()).thenReturn(identifierHelper);
    Mockito.when(database.getJdbcEnvironment()).thenReturn(jdbcEnvironment);
    Mockito.when(collector.getDatabase()).thenReturn(database);
    Mockito.when(context.getMetadataCollector()).thenReturn(collector);
    Mockito.when(source.getBuildingContext()).thenReturn(context);
}