| Total Complexity | 8 |
| Total Lines | 21 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | package easytests.api.v1.validators; |
||
| 9 | public class AnswersValidator { |
||
| 10 | |||
| 11 | public void validateAnswer(AnswerModelInterface answerModel) throws Exception { |
||
|
|
|||
| 12 | |||
| 13 | if (answerModel.getTxt().length() > 255) { |
||
| 14 | throw new BadRequestException("Answer text too long"); |
||
| 15 | } |
||
| 16 | if (!(answerModel.getId() == null)) { |
||
| 17 | throw new BadRequestException("Answer Id must be absent"); |
||
| 18 | } |
||
| 19 | if (!answerModel.getTxt().getClass().getName().equals("String".getClass().getName())) { |
||
| 20 | throw new BadRequestException("Text in Answer must be String"); |
||
| 21 | } |
||
| 22 | if (answerModel.getTxt().equals("") || answerModel.getTxt() == null) { |
||
| 23 | throw new BadRequestException("Text in answer must be not absent"); |
||
| 24 | } |
||
| 25 | if (!answerModel.getRight().getClass().getName().equals(Boolean.class.getName())) { |
||
| 26 | throw new BadRequestException("Type of isRight must be boolean"); |
||
| 27 | } |
||
| 28 | if (!answerModel.getSerialNumber().getClass().getName().equals(Integer.class.getName())) { |
||
| 29 | throw new BadRequestException("Serial Number must be Integer"); |
||
| 30 | } |
||
| 34 |