@Test(expected = InvalidEntityException.class) public void shouldValidateEmptyName() throws AlreadyExistEntityException, InvalidEntityException { resourceValidator.validateName(""); }
public void validateName(String name) throws InvalidEntityException { if (name == null) { throw new InvalidEntityException("The environment name is not valid. It is null"); } if (name.indexOf('.') != -1 || name.indexOf('_') != -1 || name.indexOf(' ') != -1) { throw new InvalidEntityException("The name is not valid. There is a strange name"); } if (name.length() == 0) { throw new InvalidEntityException("The name is not valid. It is empty"); } if (name.length() > NAME_LENGHT) { throw new InvalidEntityException("The name is not valid. The name has mor than 30 characteres"); } }
ResourceValidatorImpl implements ResourceValidator { public void validateName(String name) throws InvalidEntityException { if (name == null) { throw new InvalidEntityException("The environment name is not valid. It is null"); } if (name.indexOf('.') != -1 || name.indexOf('_') != -1 || name.indexOf(' ') != -1) { throw new InvalidEntityException("The name is not valid. There is a strange name"); } if (name.length() == 0) { throw new InvalidEntityException("The name is not valid. It is empty"); } if (name.length() > NAME_LENGHT) { throw new InvalidEntityException("The name is not valid. The name has mor than 30 characteres"); } } }
ResourceValidatorImpl implements ResourceValidator { public void validateName(String name) throws InvalidEntityException { if (name == null) { throw new InvalidEntityException("The environment name is not valid. It is null"); } if (name.indexOf('.') != -1 || name.indexOf('_') != -1 || name.indexOf(' ') != -1) { throw new InvalidEntityException("The name is not valid. There is a strange name"); } if (name.length() == 0) { throw new InvalidEntityException("The name is not valid. It is empty"); } if (name.length() > NAME_LENGHT) { throw new InvalidEntityException("The name is not valid. The name has mor than 30 characteres"); } }  }
ResourceValidatorImpl implements ResourceValidator { public void validateName(String name) throws InvalidEntityException { if (name == null) { throw new InvalidEntityException("The environment name is not valid. It is null"); } if (name.indexOf('.') != -1 || name.indexOf('_') != -1 || name.indexOf(' ') != -1) { throw new InvalidEntityException("The name is not valid. There is a strange name"); } if (name.length() == 0) { throw new InvalidEntityException("The name is not valid. It is empty"); } if (name.length() > NAME_LENGHT) { throw new InvalidEntityException("The name is not valid. The name has mor than 30 characteres"); } }  void validateName(String name); void validateDescription(String name); }
ResourceValidatorImpl implements ResourceValidator { public void validateName(String name) throws InvalidEntityException { if (name == null) { throw new InvalidEntityException("The environment name is not valid. It is null"); } if (name.indexOf('.') != -1 || name.indexOf('_') != -1 || name.indexOf(' ') != -1) { throw new InvalidEntityException("The name is not valid. There is a strange name"); } if (name.length() == 0) { throw new InvalidEntityException("The name is not valid. It is empty"); } if (name.length() > NAME_LENGHT) { throw new InvalidEntityException("The name is not valid. The name has mor than 30 characteres"); } }  void validateName(String name); void validateDescription(String name);  }