NameValidationUtils { public static void validateNodeName(String name) { String message = "Nodetemplate name <" + name + "> contains forbidden characters. Only alphanumeric and _ characters are allowed here."; validate("nodetemplateName", name, NODE_NAME_REGEX, message); }  static boolean isValid(String name); static void validate(String ownerKey, String name); static void validateApplicationName(String name); static void validateApplicationId(String id); static void validateNodeName(String name); static final String DEFAULT_NAME_REGEX; static final Pattern DEFAULT_NAME_REPLACE_PATTERN; static final String APPLICATION_NAME_REGEX; static final String NODE_NAME_REGEX; }
@Test public void validateNodeNameTest() { NameValidationUtils.validateNodeName("Compute"); NameValidationUtils.validateNodeName("Compute_2"); List<String> invalids = Lists.newArrayList("Computé", "Compute-2", "Compute.unix", "Compute 2"); invalids.forEach(invalid -> { expectException(new Callable() { @Override public Object call() throws Exception { NameValidationUtils.validateNodeName(invalid); return null; } }, InvalidNameException.class); }); }