Martin Betak has uploaded a new change for review.

Change subject: core: Minor cleanup of ValidationUtilsTest
......................................................................

core: Minor cleanup of ValidationUtilsTest

Remove duplication in tests code when testing for pattern match of
multiple strings.

Change-Id: I3416939844516e3d39538221970c9caa5ca73fd7
Signed-off-by: Martin Betak <[email protected]>
---
M 
backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/utils/ValidationUtilsTest.java
1 file changed, 4 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/30807/1

diff --git 
a/backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/utils/ValidationUtilsTest.java
 
b/backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/utils/ValidationUtilsTest.java
index 331f7fd..6edf249 100644
--- 
a/backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/utils/ValidationUtilsTest.java
+++ 
b/backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/utils/ValidationUtilsTest.java
@@ -10,15 +10,8 @@
 public class ValidationUtilsTest {
     @Test
     public void testcontainsIlegalCharacters() {
-        String[] straValid = new String[] { "www_redhat_com", "127001", 
"www_REDHAT_1" };
-        String[] straInvalid = new String[] { "www.redhatcom", "me@localhost", 
"no/worries" };
-        for (String s : straValid) {
-            assertTrue("Valid strings: " + s, 
Pattern.matches(ValidationUtils.NO_SPECIAL_CHARACTERS, s));
-        }
-
-        for (String s : straInvalid) {
-            assertTrue("Invalid strings: " + s, 
!Pattern.matches(ValidationUtils.NO_SPECIAL_CHARACTERS, s));
-        }
+        assertPatternMatches("Valid strings: ", 
ValidationUtils.NO_SPECIAL_CHARACTERS, "www_redhat_com", "127001", 
"www_REDHAT_1");
+        assertPatternDoesNotMatch("Invalid strings: ", 
ValidationUtils.NO_SPECIAL_CHARACTERS, "www.redhatcom", "me@localhost", 
"no/worries");
     }
 
     @Test
@@ -39,18 +32,8 @@
 
     @Test
     public void testTrimmingWhitespaces() {
-        String[] validStrings = {"", "aoeu", "a o e u ř", "%2123 o ^ ooe#"};
-        String[] inValidStrings = {" ", " aoeu", "a o e u ř ", " %2123 o ^ 
ooe##", " aoeu "};
-
-        for (String s : validStrings) {
-            assertTrue("Valid strings (no trimming whitespaces)",
-                    
Pattern.matches(ValidationUtils.NO_TRIMMING_WHITE_SPACES_PATTERN, s));
-        }
-
-        for (String s : inValidStrings) {
-            assertTrue("Invalid strings (trimming whitespaces)",
-                    
!Pattern.matches(ValidationUtils.NO_TRIMMING_WHITE_SPACES_PATTERN, s));
-        }
+        assertPatternMatches("Valid string (no trimming whitespaces): ", 
ValidationUtils.NO_TRIMMING_WHITE_SPACES_PATTERN, "", "aoeu", "a o e u ř", 
"%2123 o ^ ooe#");
+        assertPatternDoesNotMatch("Invalid string (trimming whitespaces): ", 
ValidationUtils.NO_TRIMMING_WHITE_SPACES_PATTERN, " ", " aoeu", "a o e u ř ", " 
%2123 o ^ ooe##", " aoeu ");
     }
 
     @Test


-- 
To view, visit http://gerrit.ovirt.org/30807
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3416939844516e3d39538221970c9caa5ca73fd7
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Betak <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to