Browse Source
Reference issues in tests comments. Removed `DisabledOnDatabase` IdGeneration default methods related to sequence generation are now internally consistent. Formatting and naming. IdGeneration offers simple support by default. Fix exception in oracle integration test setup Use SqlIdentifier for sequence names Remove SEQUENCE id source Added documentation See #1923 Original pull request #1955pull/2001/head
26 changed files with 250 additions and 290 deletions
@ -1,27 +0,0 @@
@@ -1,27 +0,0 @@
|
||||
package org.springframework.data.jdbc.testing; |
||||
|
||||
import java.lang.annotation.Documented; |
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
import org.junit.jupiter.api.extension.ExtendWith; |
||||
import org.springframework.test.context.junit.jupiter.EnabledIf; |
||||
|
||||
/** |
||||
* Annotation that allows to disable a particular test to be executed on a particular database |
||||
* |
||||
* @author Mikhail Polivakha |
||||
*/ |
||||
@Target({ElementType.TYPE, ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
@ExtendWith(DisabledOnDatabaseExecutionCondition.class) |
||||
public @interface DisabledOnDatabase { |
||||
|
||||
/** |
||||
* The database on which the test is not supposed to run on |
||||
*/ |
||||
DatabaseType database(); |
||||
} |
||||
@ -1,36 +0,0 @@
@@ -1,36 +0,0 @@
|
||||
package org.springframework.data.jdbc.testing; |
||||
|
||||
import org.apache.commons.lang3.ArrayUtils; |
||||
import org.junit.jupiter.api.extension.ConditionEvaluationResult; |
||||
import org.junit.jupiter.api.extension.ExecutionCondition; |
||||
import org.junit.jupiter.api.extension.ExtensionContext; |
||||
import org.springframework.context.ApplicationContext; |
||||
import org.springframework.core.annotation.MergedAnnotation; |
||||
import org.springframework.core.annotation.MergedAnnotations; |
||||
import org.springframework.test.context.junit.jupiter.SpringExtension; |
||||
|
||||
/** |
||||
* {@link ExecutionCondition} for the {@link DisabledOnDatabase} annotation |
||||
* |
||||
* @author Mikhail Polivakha |
||||
*/ |
||||
public class DisabledOnDatabaseExecutionCondition implements ExecutionCondition { |
||||
|
||||
@Override |
||||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { |
||||
ApplicationContext applicationContext = SpringExtension.getApplicationContext(context); |
||||
|
||||
MergedAnnotation<DisabledOnDatabase> disabledOnDatabaseMergedAnnotation = MergedAnnotations |
||||
.from(context.getRequiredTestMethod(), MergedAnnotations.SearchStrategy.DIRECT) |
||||
.get(DisabledOnDatabase.class); |
||||
|
||||
DatabaseType database = disabledOnDatabaseMergedAnnotation.getEnum("database", DatabaseType.class); |
||||
|
||||
if (ArrayUtils.contains(applicationContext.getEnvironment().getActiveProfiles(), database.getProfile())) { |
||||
return ConditionEvaluationResult.disabled( |
||||
"The test method '%s' is disabled for '%s' because of the @DisabledOnDatabase annotation".formatted(context.getRequiredTestMethod().getName(), database) |
||||
); |
||||
} |
||||
return ConditionEvaluationResult.enabled("The test method '%s' is enabled".formatted(context.getRequiredTestMethod())); |
||||
} |
||||
} |
||||
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
package org.springframework.data.relational.core.mapping; |
||||
|
||||
import java.lang.annotation.Documented; |
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
import org.springframework.core.annotation.AliasFor; |
||||
|
||||
/** |
||||
* Specify the sequence from which the value for the {@link org.springframework.data.annotation.Id} should be fetched |
||||
* |
||||
* @author Mikhail Polivakha |
||||
*/ |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Target(ElementType.FIELD) |
||||
@Documented |
||||
public @interface Sequence { |
||||
|
||||
/** |
||||
* The name of the sequence from which the id should be fetched |
||||
*/ |
||||
@AliasFor("sequence") |
||||
String value() default ""; |
||||
|
||||
/** |
||||
* Alias for {@link #value()} |
||||
*/ |
||||
@AliasFor("value") |
||||
String sequence() default ""; |
||||
|
||||
/** |
||||
* Schema where the sequence reside. Technically, this attribute is not necessarily the schema. It just represents the |
||||
* location/namespace, where the sequence resides. For instance, in Oracle databases the schema and user are often |
||||
* used interchangeably, so {@link #schema() schema} attribute may represent an Oracle user as well. |
||||
* <p> |
||||
* The final name of the sequence to be queried for the next value will be constructed by the concatenation of schema |
||||
* and sequence : |
||||
* |
||||
* <pre> |
||||
* schema().sequence() |
||||
* </pre> |
||||
*/ |
||||
String schema() default ""; |
||||
} |
||||
@ -1,43 +0,0 @@
@@ -1,43 +0,0 @@
|
||||
package org.springframework.data.relational.core.mapping; |
||||
|
||||
import java.lang.annotation.Documented; |
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
import org.springframework.core.annotation.AliasFor; |
||||
|
||||
/** |
||||
* Specify the sequence from which the value for the {@link org.springframework.data.annotation.Id} |
||||
* should be fetched |
||||
* |
||||
* @author Mikhail Polivakha |
||||
*/ |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Target(ElementType.FIELD) |
||||
@Documented |
||||
public @interface TargetSequence { |
||||
|
||||
/** |
||||
* The name of the sequence from which the id should be fetched |
||||
*/ |
||||
String value() default ""; |
||||
|
||||
/** |
||||
* Alias for {@link #value()} |
||||
*/ |
||||
@AliasFor("value") |
||||
String sequence() default ""; |
||||
|
||||
/** |
||||
* Schema where the sequence reside. |
||||
* Technically, this attribute is not necessarily the schema. It just represents the location/namespace, |
||||
* where the sequence resides. For instance, in Oracle databases the schema and user are often used |
||||
* interchangeably, so {@link #schema() schema} attribute may represent an Oracle user as well. |
||||
* <p> |
||||
* The final name of the sequence to be queried for the next value will be constructed by the concatenation |
||||
* of schema and sequence : <pre>schema().sequence()</pre> |
||||
*/ |
||||
String schema() default ""; |
||||
} |
||||
Loading…
Reference in new issue