From d500eef7d50d0d290c0db6e8f923f5857e32b63a Mon Sep 17 00:00:00 2001 From: Timon Borter Date: Sun, 10 Nov 2024 08:12:36 +0100 Subject: [PATCH] docs: uuid v4 validation matcher in addition to https://github.com/citrusframework/citrus/pull/1248. --- .../matcher/core/UuidV4ValidationMatcher.java | 3 +- .../DateRangeValidationMatcherIT.java | 1 + .../validation/UuidV4ValidationMatcherIT.java | 30 ++++++++ .../validation/UuidV4ValidationMatcherIT.xml | 70 +++++++++++++++++++ src/manual/validation-matchers.adoc | 32 ++++++++- 5 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 runtime/citrus-testng/src/test/java/org/citrusframework/integration/validation/UuidV4ValidationMatcherIT.java create mode 100644 runtime/citrus-testng/src/test/resources/org/citrusframework/integration/validation/UuidV4ValidationMatcherIT.xml diff --git a/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/UuidV4ValidationMatcher.java b/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/UuidV4ValidationMatcher.java index cbe0131cec..72e4cd9f08 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/UuidV4ValidationMatcher.java +++ b/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/UuidV4ValidationMatcher.java @@ -24,9 +24,10 @@ import java.util.UUID; /** - * UuidValidationMatcher checks if valid UUID version 4 is present + * This validation matcher checks if a valid UUID version 4 is present. */ public class UuidV4ValidationMatcher implements ValidationMatcher { + @Override public void validate(String fieldName, String value, List controlParameters, TestContext context) throws ValidationException { try { diff --git a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/validation/DateRangeValidationMatcherIT.java b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/validation/DateRangeValidationMatcherIT.java index 1be54f5126..71d01c9006 100644 --- a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/validation/DateRangeValidationMatcherIT.java +++ b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/validation/DateRangeValidationMatcherIT.java @@ -25,6 +25,7 @@ * @since 2.5 */ public class DateRangeValidationMatcherIT extends TestNGCitrusSpringSupport { + @Test @CitrusTestSource(type = TestLoader.SPRING) public void DateRangeValidationMatcherIT() {} diff --git a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/validation/UuidV4ValidationMatcherIT.java b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/validation/UuidV4ValidationMatcherIT.java new file mode 100644 index 0000000000..a4e8695300 --- /dev/null +++ b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/validation/UuidV4ValidationMatcherIT.java @@ -0,0 +1,30 @@ +/* + * Copyright the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citrusframework.integration.validation; + +import org.citrusframework.annotations.CitrusTestSource; +import org.citrusframework.common.TestLoader; +import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; +import org.testng.annotations.Test; + +public class UuidV4ValidationMatcherIT extends TestNGCitrusSpringSupport { + + @Test + @CitrusTestSource(type = TestLoader.SPRING) + public void UuidV4ValidationMatcherIT() { + } +} diff --git a/runtime/citrus-testng/src/test/resources/org/citrusframework/integration/validation/UuidV4ValidationMatcherIT.xml b/runtime/citrus-testng/src/test/resources/org/citrusframework/integration/validation/UuidV4ValidationMatcherIT.xml new file mode 100644 index 0000000000..cc69f6707d --- /dev/null +++ b/runtime/citrus-testng/src/test/resources/org/citrusframework/integration/validation/UuidV4ValidationMatcherIT.xml @@ -0,0 +1,70 @@ + + + + + bbortt + 2014-11-10 + FINAL + bbortt + 2014-11-10T00:00:00 + + + + Tests the @isUUIDv4()@ validator + + + + + + + + + + + Hello Citrus! + +
+ +
+
+ + + + Hello Citrus! + +
+ +
+
+ + + + Hello Citrus! + +
+ +
+
+ + + + + + Hello Citrus! + +
+ +
+
+
+
+
+
+
diff --git a/src/manual/validation-matchers.adoc b/src/manual/validation-matchers.adoc index cfd1faa5e4..e435b65ff4 100644 --- a/src/manual/validation-matchers.adoc +++ b/src/manual/validation-matchers.adoc @@ -1,5 +1,5 @@ [[validation-matcher]] -= Validation matcher += Validation Matchers Message validation in Citrus is essential. The framework offers several validation mechanisms for different message types and formats. With test variables we are able to check for simple value equality. We ensure that message entries are equal to predefined expected values. Validation matcher add powerful assertion functionality on top of that. You just can use the predefined validation matcher functionalities in order to perform more complex assertions like *contains* or *isNumber* in your validation statements. @@ -393,3 +393,33 @@ You can now skip all whitespaces in your control value. ---- @trimAllWhitespaces('somevalue')@ ---- + +[[matcher-is-uuid-v4]] +== isUUIDv4() + +This validation matcher checks if a valid UUID version 4 is present. +Given the ``, usage is as following. + +.Example `isUUIDv4()` validation +[source,xml] +---- + + + + Hello Citrus! + +
+ +
+
+ + + + Hello Citrus! + +
+ +
+
+
+----