|
8 | 8 | import java.util.LinkedHashMap; |
9 | 9 | import java.util.Locale; |
10 | 10 |
|
| 11 | +import org.hibernate.dialect.DatabaseVersion; |
11 | 12 | import org.hibernate.dialect.Dialect; |
12 | 13 |
|
| 14 | +import org.hibernate.dialect.SimpleDatabaseVersion; |
13 | 15 | import org.junit.jupiter.api.extension.ConditionEvaluationResult; |
14 | 16 | import org.junit.jupiter.api.extension.ExecutionCondition; |
15 | 17 | import org.junit.jupiter.api.extension.ExtensionContext; |
@@ -181,27 +183,46 @@ public enum VersionMatchMode { |
181 | 183 | SAME_OR_OLDER |
182 | 184 | } |
183 | 185 |
|
| 186 | + record DialectVersionKey(Class<? extends Dialect> dialect, DatabaseVersion version) { |
| 187 | + public static DialectVersionKey of(SkipForDialect annotation) { |
| 188 | + final Class<? extends Dialect> dialectClass = annotation.dialectClass(); |
| 189 | + int majorVersion = DatabaseVersion.NO_VERSION; |
| 190 | + int minorVersion = DatabaseVersion.NO_VERSION; |
| 191 | + int microVersion = DatabaseVersion.NO_VERSION; |
| 192 | + if ( annotation.majorVersion() != -1 ) { |
| 193 | + majorVersion = annotation.majorVersion(); |
| 194 | + if ( annotation.minorVersion() != -1 ) { |
| 195 | + minorVersion += annotation.minorVersion(); |
| 196 | + if ( annotation.microVersion() != -1 ) { |
| 197 | + microVersion += annotation.microVersion(); |
| 198 | + } |
| 199 | + } |
| 200 | + } |
| 201 | + return new DialectVersionKey( dialectClass, new SimpleDatabaseVersion( majorVersion, minorVersion, microVersion ) ); |
| 202 | + } |
| 203 | + } |
| 204 | + |
184 | 205 | private ConditionEvaluationResult evaluateSkipConditions(ExtensionContext context, Dialect dialect, String enabledResult) { |
185 | 206 | final Collection<SkipForDialect> effectiveSkips = TestingUtil.collectAnnotations( |
186 | 207 | context, |
187 | 208 | SkipForDialect.class, |
188 | 209 | SkipForDialectGroup.class, |
189 | 210 | (methodAnnotation, methodAnnotations, classAnnotation, classAnnotations) -> { |
190 | | - final LinkedHashMap<Class<?>, SkipForDialect> map = new LinkedHashMap<>(); |
| 211 | + final LinkedHashMap<DialectVersionKey, SkipForDialect> map = new LinkedHashMap<>(); |
191 | 212 | if ( classAnnotation != null ) { |
192 | | - map.put( classAnnotation.dialectClass(), classAnnotation ); |
| 213 | + map.put( DialectVersionKey.of( classAnnotation ), classAnnotation ); |
193 | 214 | } |
194 | 215 | if ( classAnnotations != null ) { |
195 | 216 | for ( SkipForDialect annotation : classAnnotations ) { |
196 | | - map.put( annotation.dialectClass(), annotation ); |
| 217 | + map.put( DialectVersionKey.of( annotation ), annotation ); |
197 | 218 | } |
198 | 219 | } |
199 | 220 | if ( methodAnnotation != null ) { |
200 | | - map.put( methodAnnotation.dialectClass(), methodAnnotation ); |
| 221 | + map.put( DialectVersionKey.of( methodAnnotation ), methodAnnotation ); |
201 | 222 | } |
202 | 223 | if ( methodAnnotations != null ) { |
203 | 224 | for ( SkipForDialect annotation : methodAnnotations ) { |
204 | | - map.put( annotation.dialectClass(), annotation ); |
| 225 | + map.put( DialectVersionKey.of( annotation ), annotation ); |
205 | 226 | } |
206 | 227 | } |
207 | 228 | return map.values(); |
|
0 commit comments