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