NamespaceNameValidator { @VisibleForTesting static ValidationResult validateInternal(String namespaceName) { if (isNullOrEmpty(namespaceName)) { return ValidationResult.NULL_OR_EMPTY; } if (namespaceName.length() > METADATA_NAME_MAX_LENGTH) { return ValidationResult.TOO_LONG; } if (!METADATA_NAME_PATTERN.matcher(namespaceName).matches()) { return ValidationResult.INVALID; } return ValidationResult.OK; } private  NamespaceNameValidator(); static void validate(String namespaceName); static boolean isValid(String name);  }
@Test public void testFailsOnNull() { assertEquals(validateInternal(null), NULL_OR_EMPTY); }
@Test public void testFailsOnEmpty() { assertEquals(validateInternal(""), NULL_OR_EMPTY); }
@Test public void testFailsOnTooLong() { assertEquals( validateInternal("0123456789012345678901234567890123456789012345678901234567890123"), TOO_LONG); }
@Test(dataProvider = "invalidDnsNames") public void testFailsOnInvalidChars(String invalidName) { assertEquals(validateInternal(invalidName), INVALID); }