@Test public void ensureValidLabelFailsTest() { String[] invalidLabels = new String[]{ "", "1", "_", "-", "'", "^", "/", "\\", "*", "a:b", "valid?no", "yüce", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1" }; for (String label : invalidLabels) { try { Validator.ensureValidLabel(label); } catch (ValidationException ex) { continue; } fail("Label validation should have failed for: " + label); } }
public static void ensureValidLabel(String label) { if (!validLabel(label)) { throw new ValidationException(String.format("Invalid label: %s", label)); } }
Validator { public static void ensureValidLabel(String label) { if (!validLabel(label)) { throw new ValidationException(String.format("Invalid label: %s", label)); } } }
Validator { public static void ensureValidLabel(String label) { if (!validLabel(label)) { throw new ValidationException(String.format("Invalid label: %s", label)); } } Validator(); }
Validator { public static void ensureValidLabel(String label) { if (!validLabel(label)) { throw new ValidationException(String.format("Invalid label: %s", label)); } } 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 ensureValidLabel(String label) { if (!validLabel(label)) { throw new ValidationException(String.format("Invalid label: %s", label)); } } 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);  }