RoadNameValidator implements ModelValidator<String> { @Override public String validate(String roadName) throws InvalidRoadNameException { if (roadName == null || !ROAD_NAME_PATTERN.matcher(roadName).matches()) { throw new InvalidRoadNameException(ERROR_MESSAGE); } return roadName; }  @Override String validate(String roadName); static String validateRoadName(String roadName);  }
@Test public void typical() { assertThat(underTest.validate("normal_road"), is("normal_road")); }
@Test public void typicalWithNumber() { assertThat(underTest.validate("normal2"), is("normal2")); }
@Test(expected = InvalidRoadNameException.class) public void nullRoadName() { underTest.validate(null); }
@Test(expected = InvalidRoadNameException.class) public void startsWithUnderscore() { underTest.validate("_road"); }
@Test(expected = InvalidRoadNameException.class) public void emptyString() { underTest.validate(""); }
@Test(expected = InvalidRoadNameException.class) public void whitespaceCharacters() { underTest.validate(" "); }
@Test(expected = InvalidRoadNameException.class) public void startsWithNumber() { underTest.validate("2a"); }
@Test(expected = InvalidRoadNameException.class) public void startsWithACaptialLetter() { underTest.validate("Road"); }
@Test(expected = InvalidRoadNameException.class) public void capittalLettersInTheMiddle() { underTest.validate("wideRoad"); }
@Test(expected = InvalidRoadNameException.class) public void otherCharacters() { underTest.validate("road$"); }