@Test public void ensureValidFieldNameFailsTest() { String[] invalidFieldNames = new String[]{ "", "'", "^", "/", "\\", "A", "*", "a:b", "valid?no", "yüce", "_", "-", ".data", "d.e", "1", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1" }; for (String name : invalidFieldNames) { try { Validator.ensureValidFieldName(name); } catch (ValidationException ex) { continue; } fail("Field name validation should have failed for: " + name); } }
public static void ensureValidFieldName(String fieldName) { if (!validFieldName(fieldName)) { throw new ValidationException(String.format("Invalid field name: %s", fieldName)); } }
Validator { public static void ensureValidFieldName(String fieldName) { if (!validFieldName(fieldName)) { throw new ValidationException(String.format("Invalid field name: %s", fieldName)); } } }
Validator { public static void ensureValidFieldName(String fieldName) { if (!validFieldName(fieldName)) { throw new ValidationException(String.format("Invalid field name: %s", fieldName)); } } Validator(); }
Validator { public static void ensureValidFieldName(String fieldName) { if (!validFieldName(fieldName)) { throw new ValidationException(String.format("Invalid field name: %s", fieldName)); } } Validator(); @SuppressWarnings("WeakerAccess") static boolean validIndexName(String indexName); static void ensureValidIndexName(String indexName); @SuppressWarnings("WeakerAccess") static boolean validFieldName(String fieldName); static void ensureValidFieldName(String fieldName); @SuppressWarnings("WeakerAccess") static boolean validLabel(String label); static void ensureValidLabel(String label); @SuppressWarnings("WeakerAccess") static boolean validKey(String key); static void ensureValidKey(String key); }
Validator { public static void ensureValidFieldName(String fieldName) { if (!validFieldName(fieldName)) { throw new ValidationException(String.format("Invalid field name: %s", fieldName)); } } Validator(); @SuppressWarnings("WeakerAccess") static boolean validIndexName(String indexName); static void ensureValidIndexName(String indexName); @SuppressWarnings("WeakerAccess") static boolean validFieldName(String fieldName); static void ensureValidFieldName(String fieldName); @SuppressWarnings("WeakerAccess") static boolean validLabel(String label); static void ensureValidLabel(String label); @SuppressWarnings("WeakerAccess") static boolean validKey(String key); static void ensureValidKey(String key);  }