Java 类org.hibernate.boot.spi.MetadataBuildingContext 实例源码

项目:bootstrap    文件:ImplicitNamingStrategyNiceJpaImplTest.java   
private void mockContext(final ImplicitNameSource source) {
    final MetadataBuildingContext context = Mockito.mock(MetadataBuildingContext.class);
    final InFlightMetadataCollector collector = Mockito.mock(InFlightMetadataCollector.class);
    final Database database = Mockito.mock(Database.class);
    final JdbcEnvironment jdbcEnvironment = Mockito.mock(JdbcEnvironment.class);
    final IdentifierHelper identifierHelper = Mockito.mock(IdentifierHelper.class);
    Mockito.when(identifierHelper.toIdentifier(ArgumentMatchers.anyString())).then(new Answer<Identifier>() {

        @Override
        public Identifier answer(final InvocationOnMock invocation) {
            return 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);
}
项目:bootstrap    文件:SequenceIdentifierGeneratorStrategyProviderTest.java   
/**
 * Check strategy configuration.
 */
@Test
public void testConfiguration() {
    final Properties params = new Properties();
    params.put("identity_tables", "summy.seg");
    params.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, new ObjectNameNormalizer() {

        @Override
        protected MetadataBuildingContext getBuildingContext() {
            return null;
        }
    });

    OptimizedSequenceStyleGenerator optimizedSequenceStyleGenerator = newStyleGenerator();
    optimizedSequenceStyleGenerator.configure(StringType.INSTANCE, params, newServiceRegistry());
}
项目:web-framework-for-java    文件:DatabaseImplicitNamingStrategy.java   
@Override
public Identifier determineBasicColumnName(ImplicitBasicColumnNameSource source) {

    String columnName = StringHelper.toLowerCase(
        StringHelper.insertUnderscoreBetweenWords(source.getAttributePath().getProperty())
    );

    ImplicitBasicColumnNameSource newSource = new ImplicitBasicColumnNameSource() {
        @Override
        public AttributePath getAttributePath()
        {
            return AttributePath.parse(columnName);
        }

        @Override
        public boolean isCollectionElement() {
            return source.isCollectionElement();
        }

        @Override
        public MetadataBuildingContext getBuildingContext()
        {
            return source.getBuildingContext();
        }
    };

    return super.determineBasicColumnName(newSource);
}
项目:midpoint    文件:MidPointImplicitNamingStrategy.java   
@Override
protected Identifier toIdentifier(String stringForm, MetadataBuildingContext buildingContext) {
    Identifier i = super.toIdentifier(stringForm, buildingContext);

    LOGGER.trace("toIdentifier {} -> {}", stringForm, i);

    return i;
}
项目:midpoint    文件:MidPointImplicitNamingStrategy.java   
@Override
protected Identifier toIdentifier(String stringForm, MetadataBuildingContext buildingContext) {
    Identifier i = super.toIdentifier(stringForm, buildingContext);

    LOGGER.trace("toIdentifier {} -> {}", stringForm, i);

    return i;
}