FactoryBaseValidator { protected void validateProjectName(Factory factory) throws ApiException { String projectName = null; switch (factory.getV()) { case "2.0": case "2.1": if (null != factory.getProject()) { projectName = factory.getProject().getName(); } break; default: } if (null != projectName && !PROJECT_NAME_VALIDATOR.matcher(projectName).matches()) { throw new ConflictException( "Project name must contain only Latin letters, digits or these following special characters -._."); } } FactoryBaseValidator(AccountDao accountDao,
                                UserDao userDao,
                                PreferenceDao preferenceDao);   }
@Test(dataProvider = "invalidProjectNamesProvider", expectedExceptions = ApiException.class, expectedExceptionsMessageRegExp = "Project name must contain only Latin letters, digits or these following special characters" + " -._.") public void shouldThrowFactoryUrlExceptionIfProjectNameInvalid(String projectName) throws Exception { factory.withProject(dto.createDto(NewProject.class) .withType("type") .withName(projectName)); validator.validateProjectName(factory); }
@Test(dataProvider = "validProjectNamesProvider") public void shouldBeAbleToValidateValidProjectName(String projectName) throws Exception { factory.withProject(dto.createDto(NewProject.class) .withType("type") .withName(projectName)); validator.validateProjectName(factory); }