HHH-17909 Improve test to cover schema generated by named ordinal enum
This commit is contained in:
parent
0e0ad7b6ed
commit
644a9aebbc
|
@ -43,7 +43,7 @@ public class OracleEnumTest {
|
||||||
assertEquals( ts.activity.activityType, ActivityType.Play );
|
assertEquals( ts.activity.activityType, ActivityType.Play );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testOrdinalEnum(SessionFactoryScope scope) {
|
@Test public void testNamedOrdinalEnum(SessionFactoryScope scope) {
|
||||||
Weather weather = new Weather();
|
Weather weather = new Weather();
|
||||||
Sky sky = new Sky();
|
Sky sky = new Sky();
|
||||||
sky.skyType = SkyType.Sunny;
|
sky.skyType = SkyType.Sunny;
|
||||||
|
@ -57,31 +57,62 @@ public class OracleEnumTest {
|
||||||
scope.inSession( s -> {
|
scope.inSession( s -> {
|
||||||
s.doWork(
|
s.doWork(
|
||||||
c -> {
|
c -> {
|
||||||
|
boolean namedEnumFound = false;
|
||||||
|
boolean namedOrdinalEnumFound = false;
|
||||||
|
|
||||||
try(Statement stmt = c.createStatement()) {
|
try(Statement stmt = c.createStatement()) {
|
||||||
try(ResultSet typeInfo = stmt.executeQuery("select name, decode(instr(data_display,'WHEN '''),0,'NUMBER','VARCHAR2') from user_domains where type='ENUMERATED'")) {
|
try(ResultSet typeInfo = stmt.executeQuery("select name, decode(instr(data_display,'WHEN '''),0,'NUMBER','VARCHAR2') from user_domains where type='ENUMERATED'")) {
|
||||||
while (typeInfo.next()) {
|
while (typeInfo.next()) {
|
||||||
String name = typeInfo.getString(1);
|
String name = typeInfo.getString(1);
|
||||||
String baseType = typeInfo.getString(2);
|
String baseType = typeInfo.getString(2);
|
||||||
if (name.equalsIgnoreCase("ActivityType") && baseType.equals("VARCHAR2")) {
|
if (name.equalsIgnoreCase("ActivityType") && baseType.equals("VARCHAR2")) {
|
||||||
return;
|
namedEnumFound = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (name.equalsIgnoreCase("SkyType") && baseType.equals("NUMBER")) {
|
||||||
|
namedOrdinalEnumFound = true;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fail("named enum type not exported");
|
|
||||||
|
if (!namedEnumFound) {
|
||||||
|
fail("named enum type not exported");
|
||||||
|
}
|
||||||
|
if (!namedOrdinalEnumFound) {
|
||||||
|
fail("named ordinal enum type not exported");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
scope.inSession( s -> {
|
scope.inSession( s -> {
|
||||||
s.doWork(
|
s.doWork(
|
||||||
c -> {
|
c -> {
|
||||||
|
boolean namedEnumFound = false;
|
||||||
|
boolean namedOrdinalEnumFound = false;
|
||||||
|
|
||||||
ResultSet tableInfo = c.getMetaData().getColumns(null, null, "ACTIVITY", "ACTIVITYTYPE" );
|
ResultSet tableInfo = c.getMetaData().getColumns(null, null, "ACTIVITY", "ACTIVITYTYPE" );
|
||||||
while ( tableInfo.next() ) {
|
while ( tableInfo.next() ) {
|
||||||
String type = tableInfo.getString(6);
|
String type = tableInfo.getString(6);
|
||||||
assertEquals( "VARCHAR2", type );
|
assertEquals( "VARCHAR2", type );
|
||||||
return;
|
namedEnumFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tableInfo = c.getMetaData().getColumns(null, null, "SKY", "SKYTYPE" );
|
||||||
|
while ( tableInfo.next() ) {
|
||||||
|
String type = tableInfo.getString(6);
|
||||||
|
assertEquals( "NUMBER", type );
|
||||||
|
namedOrdinalEnumFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!namedEnumFound) {
|
||||||
|
fail("named enum type not exported");
|
||||||
|
}
|
||||||
|
if (!namedOrdinalEnumFound) {
|
||||||
|
fail("named ordinal enum type not exported");
|
||||||
}
|
}
|
||||||
fail("named enum column not exported");
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue