Skip to content

Commit 644a9ae

Browse files
quaffbeikov
authored andcommitted
HHH-17909 Improve test to cover schema generated by named ordinal enum
1 parent 0e0ad7b commit 644a9ae

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/type/OracleEnumTest.java

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class OracleEnumTest {
4343
assertEquals( ts.activity.activityType, ActivityType.Play );
4444
}
4545

46-
@Test public void testOrdinalEnum(SessionFactoryScope scope) {
46+
@Test public void testNamedOrdinalEnum(SessionFactoryScope scope) {
4747
Weather weather = new Weather();
4848
Sky sky = new Sky();
4949
sky.skyType = SkyType.Sunny;
@@ -57,31 +57,62 @@ public class OracleEnumTest {
5757
scope.inSession( s -> {
5858
s.doWork(
5959
c -> {
60+
boolean namedEnumFound = false;
61+
boolean namedOrdinalEnumFound = false;
62+
6063
try(Statement stmt = c.createStatement()) {
6164
try(ResultSet typeInfo = stmt.executeQuery("select name, decode(instr(data_display,'WHEN '''),0,'NUMBER','VARCHAR2') from user_domains where type='ENUMERATED'")) {
6265
while (typeInfo.next()) {
6366
String name = typeInfo.getString(1);
6467
String baseType = typeInfo.getString(2);
6568
if (name.equalsIgnoreCase("ActivityType") && baseType.equals("VARCHAR2")) {
66-
return;
69+
namedEnumFound = true;
70+
continue;
71+
}
72+
if (name.equalsIgnoreCase("SkyType") && baseType.equals("NUMBER")) {
73+
namedOrdinalEnumFound = true;
74+
continue;
6775
}
6876
}
6977
}
7078
}
71-
fail("named enum type not exported");
79+
80+
if (!namedEnumFound) {
81+
fail("named enum type not exported");
82+
}
83+
if (!namedOrdinalEnumFound) {
84+
fail("named ordinal enum type not exported");
85+
}
7286
}
7387
);
7488
});
7589
scope.inSession( s -> {
7690
s.doWork(
7791
c -> {
92+
boolean namedEnumFound = false;
93+
boolean namedOrdinalEnumFound = false;
94+
7895
ResultSet tableInfo = c.getMetaData().getColumns(null, null, "ACTIVITY", "ACTIVITYTYPE" );
7996
while ( tableInfo.next() ) {
8097
String type = tableInfo.getString(6);
8198
assertEquals( "VARCHAR2", type );
82-
return;
99+
namedEnumFound = true;
100+
break;
101+
}
102+
tableInfo = c.getMetaData().getColumns(null, null, "SKY", "SKYTYPE" );
103+
while ( tableInfo.next() ) {
104+
String type = tableInfo.getString(6);
105+
assertEquals( "NUMBER", type );
106+
namedOrdinalEnumFound = true;
107+
break;
108+
}
109+
110+
if (!namedEnumFound) {
111+
fail("named enum type not exported");
112+
}
113+
if (!namedOrdinalEnumFound) {
114+
fail("named ordinal enum type not exported");
83115
}
84-
fail("named enum column not exported");
85116
}
86117
);
87118
});

0 commit comments

Comments
 (0)