@Test public void testValidateFieldLength() { HashMap<String, String> map = new HashMap<>(); map.put("foo1", "foo_value1"); map.put("foo2", "foo_value2_longer"); map.put("foo3", "foo_"); map.put("foo4", "foo_value4_veryLong_value"); try { ValidateUtil.validateFieldLength(map, 30); } catch (VmidcBrokerInvalidEntryException e) { fail("Error in validateFieldLength"); } map.clear(); map.put("foo1", "foo_value1"); map.put("foo2", "foo_value2_longer"); map.put("foo3", "foo_"); map.put("foo4", "foo_value4_veryLong_value"); try { ValidateUtil.validateFieldLength(map, 11); fail("Error in validateFieldLength, We should not get here"); } catch (VmidcBrokerInvalidEntryException e) { } }
public static void validateFieldLength(Map<String, String> map, int maxLen) throws VmidcBrokerInvalidEntryException { for (Entry<String, String> entry : map.entrySet()) { String field = entry.getKey(); String value = entry.getValue(); if (value != null && value.length() > maxLen) { throw new VmidcBrokerInvalidEntryException(field + " length should not exceed " + maxLen + " characters. The provided field exceeds this limit by " + (value.length() - maxLen) + " characters."); } } }
ValidateUtil implements ValidationApi { public static void validateFieldLength(Map<String, String> map, int maxLen) throws VmidcBrokerInvalidEntryException { for (Entry<String, String> entry : map.entrySet()) { String field = entry.getKey(); String value = entry.getValue(); if (value != null && value.length() > maxLen) { throw new VmidcBrokerInvalidEntryException(field + " length should not exceed " + maxLen + " characters. The provided field exceeds this limit by " + (value.length() - maxLen) + " characters."); } } } }
ValidateUtil implements ValidationApi { public static void validateFieldLength(Map<String, String> map, int maxLen) throws VmidcBrokerInvalidEntryException { for (Entry<String, String> entry : map.entrySet()) { String field = entry.getKey(); String value = entry.getValue(); if (value != null && value.length() > maxLen) { throw new VmidcBrokerInvalidEntryException(field + " length should not exceed " + maxLen + " characters. The provided field exceeds this limit by " + (value.length() - maxLen) + " characters."); } } }  }
ValidateUtil implements ValidationApi { public static void validateFieldLength(Map<String, String> map, int maxLen) throws VmidcBrokerInvalidEntryException { for (Entry<String, String> entry : map.entrySet()) { String field = entry.getKey(); String value = entry.getValue(); if (value != null && value.length() > maxLen) { throw new VmidcBrokerInvalidEntryException(field + " length should not exceed " + maxLen + " characters. The provided field exceeds this limit by " + (value.length() - maxLen) + " characters."); } } }  static void checkForNullFields(Map<String, Object> map); static void validateFieldsAreNull(Map<String, Object> map); static void checkForValidIpAddressFormat(String ipAddress); static boolean validateDaName(String name); static void validateFieldLength(Map<String, String> map, int maxLen); static void checkForValidEmailAddress(String email); static void checkForValidUsername(String username); static void checkForValidPassword(String password); static void checkForValidFqdn(String smtpServer); static void checkForValidPortNumber(String port); static void checkMarkedForDeletion(IscEntity entity, String name); static boolean isEmpty(Collection<?> collection); @Override void checkValidIpAddress(String value); @Override void checkValidPassword(String value); @Override boolean isValidDaName(String string); }
ValidateUtil implements ValidationApi { public static void validateFieldLength(Map<String, String> map, int maxLen) throws VmidcBrokerInvalidEntryException { for (Entry<String, String> entry : map.entrySet()) { String field = entry.getKey(); String value = entry.getValue(); if (value != null && value.length() > maxLen) { throw new VmidcBrokerInvalidEntryException(field + " length should not exceed " + maxLen + " characters. The provided field exceeds this limit by " + (value.length() - maxLen) + " characters."); } } }  static void checkForNullFields(Map<String, Object> map); static void validateFieldsAreNull(Map<String, Object> map); static void checkForValidIpAddressFormat(String ipAddress); static boolean validateDaName(String name); static void validateFieldLength(Map<String, String> map, int maxLen); static void checkForValidEmailAddress(String email); static void checkForValidUsername(String username); static void checkForValidPassword(String password); static void checkForValidFqdn(String smtpServer); static void checkForValidPortNumber(String port); static void checkMarkedForDeletion(IscEntity entity, String name); static boolean isEmpty(Collection<?> collection); @Override void checkValidIpAddress(String value); @Override void checkValidPassword(String value); @Override boolean isValidDaName(String string); static final int DEFAULT_MAX_LEN; }