### Question:
NameNormaliser { public static String normalise(String name) { name = name.trim().toLowerCase(); if (!pattern.matcher(name).matches()) { throw new IllegalArgumentException(String.format("Invalid name '%s' must be conform to pattern %s", name, pattern.pattern())); } return name; }  static String normalise(String name);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void invalidBeginsWithDigit() { normalise("1abc_def_1"); }
@Test(expected = IllegalArgumentException.class) public void invalidBeginsWithUnderscore() { normalise("_abc_def_1"); }
@Test(expected = IllegalArgumentException.class) public void invalidEndsWithUnderscore() { normalise("abc_def_"); }
@Test(expected = IllegalArgumentException.class) public void invalidConsecutiveUnderscores() { normalise("abc__def_1"); }
@Test public void validName() { assertThat(normalise("abc_def_1"), is("abc_def_1")); }
@Test public void validNameWithWhitespace() { assertThat(normalise(" abc_def_1 "), is("abc_def_1")); }
@Test public void validNameUppercase() { assertThat(normalise("ABC_DEF_1"), is("abc_def_1")); }
@Test public void validDelimitedDigit() { assertThat(normalise("abc_1_def"), is("abc_1_def")); }