|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: Apache-2.0 |
| 3 | + * Copyright Red Hat Inc. and Hibernate Authors |
| 4 | + */ |
| 5 | +package org.hibernate.tool.schema.extract.spi; |
| 6 | + |
| 7 | +import org.hibernate.boot.model.relational.QualifiedTableName; |
| 8 | +import org.hibernate.boot.registry.StandardServiceRegistry; |
| 9 | +import org.hibernate.mapping.Table; |
| 10 | +import org.hibernate.testing.orm.junit.JiraKey; |
| 11 | +import org.hibernate.testing.util.ServiceRegistryUtil; |
| 12 | +import org.junit.Assert; |
| 13 | +import org.junit.jupiter.api.Test; |
| 14 | +import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; |
| 15 | +import org.hibernate.engine.jdbc.env.spi.IdentifierHelper; |
| 16 | +import org.hibernate.tool.schema.extract.internal.TableInformationImpl; |
| 17 | +import org.hibernate.boot.model.relational.Namespace.Name; |
| 18 | +import org.hibernate.boot.model.naming.Identifier; |
| 19 | +import org.mockito.Mockito; |
| 20 | + |
| 21 | + |
| 22 | +public class NameSpaceTablesInformationTest { |
| 23 | + |
| 24 | + @Test |
| 25 | + @JiraKey(value = "HHH-14270") |
| 26 | + public void testNameSpaceTablesInformation() { |
| 27 | + StandardServiceRegistry ssr = ServiceRegistryUtil.serviceRegistry(); |
| 28 | + JdbcEnvironment jdbcEnvironment = ssr.getService( JdbcEnvironment.class ); |
| 29 | + IdentifierHelper identifierHelper = jdbcEnvironment.getIdentifierHelper(); |
| 30 | + |
| 31 | + NameSpaceTablesInformation nameSpaceTablesInformation = new NameSpaceTablesInformation(identifierHelper); |
| 32 | + Name schemaName = new Name( new Identifier( "-", false ), new Identifier( "-", false ) ); |
| 33 | + InformationExtractor informationExtractor = Mockito.mock( InformationExtractor.class ); |
| 34 | + QualifiedTableName tableName = new QualifiedTableName( schemaName, new Identifier( "-", false ) ); |
| 35 | + |
| 36 | + TableInformation tableInformation = new TableInformationImpl( informationExtractor, identifierHelper, tableName, false, null ); |
| 37 | + nameSpaceTablesInformation.addTableInformation( tableInformation ); |
| 38 | + final Table table = new Table( "orm", tableName.getTableName().getText() ); |
| 39 | + nameSpaceTablesInformation.getTableInformation( table ); |
| 40 | + boolean tableMatched = tableInformation.getName().getTableName().getText().equals( tableName.getTableName().getText() ); |
| 41 | + Assert.assertTrue("Table matched: ", tableMatched); |
| 42 | + } |
| 43 | +} |
0 commit comments