1 package net.avcompris.guixer.core; 2 3 import static com.google.common.base.Preconditions.checkNotNull; 4 5 abstract class Validations { 6 7 public static void assertValidTestClassSimpleName(final String classSimpleName) { 8 9 checkNotNull(classSimpleName, "classSimpleName"); 10 11 final String regex = "[A-Z][\\w]+Test"; 12 13 if (!classSimpleName.matches(regex)) { 14 15 throw new AssertionError( 16 "classSimpleName should match \"" + regex + "\", but was: \"" + classSimpleName + "\""); 17 } 18 } 19 20 public static void assertValidTestMethodName(final String methodName) { 21 22 checkNotNull(methodName, "methodName"); 23 24 final String regex = "[a-z][\\w]+"; 25 26 if (!methodName.matches(regex)) { 27 28 throw new AssertionError("methodName should match \"" + regex + "\", but was: \"" + methodName + "\""); 29 } 30 } 31 32 public static void assertValidLabel(final String label) { 33 34 checkNotNull(label, "label"); 35 36 final String regex = "[\\w]+([\\.-][\\w]+)*"; 37 38 if (!label.matches(regex)) { 39 40 throw new AssertionError("label should match \"" + regex + "\", but was: \"" + label + "\""); 41 } 42 } 43 }