ValidationResult { private <T> void add(Set<ConstraintViolation<T>> violations) { if(CollectionUtils.isEmpty(violations)) { return; } for(ConstraintViolation<T> c : violations) { ValidationError.Model e = new ValidationError.Model(); e.setCode(c.getPropertyPath().toString()); e.setModelAlias(null); e.setMsg(c.getMessage()); this.template.add(e); } } ValidationResult(); <T> ValidationResult(Set<ConstraintViolation<T>> violations); void addValidationErrors(Set<ConstraintViolation<T>> violations); @JsonIgnore
	final CollectionsTemplate<List<ValidationError>, ValidationError> template; }
@SuppressWarnings("unchecked") @Test public void testInit() { ConstraintViolation<String> v1 = Mockito.mock(ConstraintViolation.class); Path v1Path = Mockito.mock(Path.class); Set<ConstraintViolation<String>> violations = new HashSet<>(); violations.add(v1); Mockito.when(v1.getPropertyPath()).thenReturn(v1Path); Mockito.when(v1Path.toString()).thenReturn("a.b.c.field1"); Mockito.when(v1.getMessage()).thenReturn("Bad!"); this.testee = new ValidationResult(violations); Assert.assertEquals(1, this.testee.getTemplate().size()); ValidationError.Model e = (ValidationError.Model) this.testee.getTemplate().get().get(0); Assert.assertEquals("a.b.c.field1", e.getCode()); Assert.assertNull(e.getModelAlias()); Assert.assertEquals("Bad!", e.getMsg()); }