@Test(expected = InvalidEntityException.class) public void shouldValidateDescriptionTooLong() throws AlreadyExistEntityException, InvalidEntityException { resourceValidator.validateDescription("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaajjjjjjjjjjjjjjjjjjjjjj" + "jjjjjjjjjjjjjjjjjjjjjjjdddddddddddddddddddddddddddddddddddddddjjjjjjjjaaaaaaaaaaaaaaaaaaaddddddddd" + "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" + "ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"); }
public void validateDescription(String name) throws InvalidEntityException { if (name == null) { throw new InvalidEntityException("The description is not valid. It is null"); } if (name.length() == 0) { throw new InvalidEntityException("The description is not valid. It is empty"); } if (name.length() > DESCRIPTION_LENGHT) { throw new InvalidEntityException("The description is not valid. The name has mor than 256 characteres"); } }
ResourceValidatorImpl implements ResourceValidator { public void validateDescription(String name) throws InvalidEntityException { if (name == null) { throw new InvalidEntityException("The description is not valid. It is null"); } if (name.length() == 0) { throw new InvalidEntityException("The description is not valid. It is empty"); } if (name.length() > DESCRIPTION_LENGHT) { throw new InvalidEntityException("The description is not valid. The name has mor than 256 characteres"); } } }
ResourceValidatorImpl implements ResourceValidator { public void validateDescription(String name) throws InvalidEntityException { if (name == null) { throw new InvalidEntityException("The description is not valid. It is null"); } if (name.length() == 0) { throw new InvalidEntityException("The description is not valid. It is empty"); } if (name.length() > DESCRIPTION_LENGHT) { throw new InvalidEntityException("The description is not valid. The name has mor than 256 characteres"); } }  }
ResourceValidatorImpl implements ResourceValidator { public void validateDescription(String name) throws InvalidEntityException { if (name == null) { throw new InvalidEntityException("The description is not valid. It is null"); } if (name.length() == 0) { throw new InvalidEntityException("The description is not valid. It is empty"); } if (name.length() > DESCRIPTION_LENGHT) { throw new InvalidEntityException("The description is not valid. The name has mor than 256 characteres"); } }  void validateName(String name); void validateDescription(String name); }
ResourceValidatorImpl implements ResourceValidator { public void validateDescription(String name) throws InvalidEntityException { if (name == null) { throw new InvalidEntityException("The description is not valid. It is null"); } if (name.length() == 0) { throw new InvalidEntityException("The description is not valid. It is empty"); } if (name.length() > DESCRIPTION_LENGHT) { throw new InvalidEntityException("The description is not valid. The name has mor than 256 characteres"); } }  void validateName(String name); void validateDescription(String name);  }