You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2022/11/11 08:56:52 UTC
[uima-uimafit] 01/01: Issue #211: Conveniently skip validation
This is an automated email from the ASF dual-hosted git repository.
rec pushed a commit to branch feature/211-Conveniently-skip-validation
in repository https://gitbox.apache.org/repos/asf/uima-uimafit.git
commit 62484e6d4dce5ded7b646b57391bc6c94e6e0a5c
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Fri Nov 11 09:56:44 2022 +0100
Issue #211: Conveniently skip validation
- Add convenience methods for skipping validation
- Add JavaDoc
---
.../apache/uima/fit/testing/junit/ManagedCas.java | 29 +++++++++++++++++++++-
.../apache/uima/fit/testing/junit/ManagedJCas.java | 29 +++++++++++++++++++++-
2 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/uimafit-junit/src/main/java/org/apache/uima/fit/testing/junit/ManagedCas.java b/uimafit-junit/src/main/java/org/apache/uima/fit/testing/junit/ManagedCas.java
index cfb50aa..b16d163 100644
--- a/uimafit-junit/src/main/java/org/apache/uima/fit/testing/junit/ManagedCas.java
+++ b/uimafit-junit/src/main/java/org/apache/uima/fit/testing/junit/ManagedCas.java
@@ -112,16 +112,43 @@ public final class ManagedCas implements TestWatcher, AfterTestExecutionCallback
}
}
+ /**
+ * Skip validation for the current test run only.
+ *
+ * @return the object for chaining.
+ */
public ManagedCas skipValidation() {
- validator = null;
+ validator = new Validator.Builder().withoutAutoDetectedChecks().build();
return this;
}
+ /**
+ * Skip validation by default. If validation is enabled for a particular run using
+ * {@link #withValidator(Validator)} it is reset to a no-op validator again after the test is
+ * complete.
+ *
+ * @return the object for chaining.
+ */
+ public ManagedCas withoutDefaultValidator() {
+ this.defaultValidator = new Validator.Builder().withoutAutoDetectedChecks().build();
+ return this;
+ }
+
+ /**
+ * Set a default validator for the all test runs.
+ *
+ * @return the object for chaining.
+ */
public ManagedCas withDefaultValidator(Validator aValidator) {
this.defaultValidator = aValidator;
return this;
}
+ /**
+ * Set a validator for the current test run only.
+ *
+ * @return the object for chaining.
+ */
public ManagedCas withValidator(Validator aValidator) {
this.validator = aValidator;
return this;
diff --git a/uimafit-junit/src/main/java/org/apache/uima/fit/testing/junit/ManagedJCas.java b/uimafit-junit/src/main/java/org/apache/uima/fit/testing/junit/ManagedJCas.java
index fb2c0d9..74e51b2 100644
--- a/uimafit-junit/src/main/java/org/apache/uima/fit/testing/junit/ManagedJCas.java
+++ b/uimafit-junit/src/main/java/org/apache/uima/fit/testing/junit/ManagedJCas.java
@@ -113,16 +113,43 @@ public final class ManagedJCas
}
}
+ /**
+ * Skip validation for the current test run only.
+ *
+ * @return the object for chaining.
+ */
public ManagedJCas skipValidation() {
- validator = null;
+ validator = new Validator.Builder().withoutAutoDetectedChecks().build();
return this;
}
+ /**
+ * Skip validation by default. If validation is enabled for a particular run using
+ * {@link #withValidator(Validator)} it is reset to a no-op validator again after the test is
+ * complete.
+ *
+ * @return the object for chaining.
+ */
+ public ManagedJCas withoutDefaultValidator() {
+ this.defaultValidator = new Validator.Builder().withoutAutoDetectedChecks().build();
+ return this;
+ }
+
+ /**
+ * Set a default validator for the all test runs.
+ *
+ * @return the object for chaining.
+ */
public ManagedJCas withDefaultValidator(Validator aValidator) {
this.defaultValidator = aValidator;
return this;
}
+ /**
+ * Set a validator for the current test run only.
+ *
+ * @return the object for chaining.
+ */
public ManagedJCas withValidator(Validator aValidator) {
this.validator = aValidator;
return this;