Lior Vernia has posted comments on this change.

Change subject: common: adding maskValidator util
......................................................................


Patch Set 11:

(5 comments)

http://gerrit.ovirt.org/#/c/35144/11/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/ValidationUtils.java
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/ValidationUtils.java:

Line 23:     public static final String NO_SPECIAL_CHARACTERS_WITH_DOT = 
"[0-9a-zA-Z-_\\.]+";
Line 24:     public static final String NO_TRIMMING_WHITE_SPACES_PATTERN = 
"^$|\\S.*\\S";
Line 25:     public static final String IP_PATTERN_NON_EMPTY =
Line 26:             
"\\b((25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)\\.){3}(25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)";
Line 27:     public static final String IP_PATTERN = 
"^"+IP_PATTERN_NON_EMPTY+"$|^$";
Yet again, this doesn't look formatted.
Line 28:     public static final String SUBNET_PREFIX_PATTERN = 
"(?:3[0-2]|[12]?[0-9])";
Line 29:     public static final String CIDR_FORMAT_PATTERN = "^" + 
IP_PATTERN_NON_EMPTY + "/" + SUBNET_PREFIX_PATTERN + "$";
Line 30:     public static final String ISO_SUFFIX = ".iso";
Line 31:     public static final String ISO_SUFFIX_PATTERN = "^$|^.+\\.iso$";


http://gerrit.ovirt.org/#/c/35144/11/backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/utils/IpAddressConverterTest.java
File 
backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/utils/IpAddressConverterTest.java:

Line 35:                 { "1.1.1.1", 0x01010101 },
Line 36:                 { "1.255.4.255", 0x01ff04ff },
Line 37:                 { "0.128.0.7", 0x00800007 },
Line 38:                 { "1.2.3.4", 0x01020304 },
Line 39:                 { "127.63.31.7", 0x7f3f1f07 },
In my opinion, this test case is useless - there's no way to verify this is 
valid with a human eye...
Line 40:                 { "0.0.0.1", 0x00000001 },
Line 41:                 { "1.1.1.1", 0x01010101 }, });
Line 42:     }
Line 43: 


http://gerrit.ovirt.org/#/c/35144/11/backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/validation/MaskValidatorTest.java
File 
backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/validation/MaskValidatorTest.java:

Line 20:     public MaskValidatorTest(String mask, boolean isMaskValidFormat, 
boolean isMaskValid, boolean isPrefixAllowed) {
Line 21:         this.mask = mask;
Line 22:         this.isMaskValidFormat = isMaskValidFormat;
Line 23:         this.isMaskValid = isMaskValid;
Line 24:         this.isPrefixAllowed = isPrefixAllowed;
See below comment - this should then become isPrefixValid instead of allowed 
(allowed is obsolete, it was only relevant when the validator had one method to 
test validity in all cases).
Line 25:     }
Line 26: 
Line 27:     @Test
Line 28:     public void checkMaskFormatValidator() {


Line 24:         this.isPrefixAllowed = isPrefixAllowed;
Line 25:     }
Line 26: 
Line 27:     @Test
Line 28:     public void checkMaskFormatValidator() {
I would split this test to two independent tests - one that tests whether the 
input is in valid netmask format, and the other whether it's in valid prefix 
format.
Line 29:         assertEquals("Failed to validate mask's Format: " + mask,
Line 30:                 isMaskValidFormat, 
MaskValidator.getInstance().isValidNetmaskFormat(mask)
Line 31:                         || (isPrefixAllowed && 
MaskValidator.getInstance().isPrefixValid(mask)));
Line 32:     }


Line 39: 
Line 40:         assertEquals("Failed to validate mask value" + mask,
Line 41:                 isMaskValid,
Line 42:                 MaskValidator.getInstance().isNetmaskValid(mask)
Line 43:                         || (isPrefixAllowed && 
MaskValidator.getInstance().isPrefixValid(mask)));
This line is redundant - as you've made sure above, this test shouldn't run 
when it's not in netmask format.
Line 44:     }
Line 45: 
Line 46:     @Parameterized.Parameters
Line 47:     public static Collection<Object[]> namesParams() {


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I04fb0aa2193801688f1bfc5dc7684cabdfa2827d
Gerrit-PatchSet: 11
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Eliraz Levi <[email protected]>
Gerrit-Reviewer: Alona Kaplan <[email protected]>
Gerrit-Reviewer: Eliraz Levi <[email protected]>
Gerrit-Reviewer: Lior Vernia <[email protected]>
Gerrit-Reviewer: Martin Mucha <[email protected]>
Gerrit-Reviewer: Yevgeny Zaspitsky <[email protected]>
Gerrit-Reviewer: [email protected]
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to