package io.fluxcapacitor.javaclient.tracking.handling.validation;

import lombok.Getter;

import javax.validation.ConstraintViolation;
import java.util.Set;

import static java.util.stream.Collectors.toList;

@Getter
public class ValidationException extends RuntimeException {

    private final Set<? extends ConstraintViolation<?>> violations;

    public ValidationException(Set<? extends ConstraintViolation<?>> violations) {
        super(String.format("One or more constraints were violated:%s%s", System.lineSeparator(), convert(violations)));
        this.violations = violations;
    }

    protected static String convert(Set<? extends ConstraintViolation<?>> violations) {
        return String.join(System.lineSeparator(), violations.stream().map(v -> String
                .format("property %s in class %s %s", v.getPropertyPath(), v.getRootBeanClass().getSimpleName(),
                        v.getMessage())).sorted().collect(toList()));
    }
}

@@ -144,18 +144,169 @@
 ava.
-util.Set;%0A
+beans.ConstructorProperties;%0Aimport java.util.Set;%0Aimport java.util.SortedSet;%0Aimport java.util.TreeSet;%0A%0Aimport static java.util.stream.Collectors.toCollection;
 %0Aimp
@@ -445,43 +445,23 @@
 al S
-et%3C? extends ConstraintViolation%3C?%3E
+ortedSet%3CString
 %3E vi
@@ -652,22 +652,21 @@
 ator(), 
-conver
+forma
 t(violat
@@ -714,208 +714,390 @@
 ions
-;%0A    %7D%0A%0A    protected static String convert(Set%3C? extends ConstraintViolation%3C?%3E%3E violations) %7B%0A        return String.join(System.lineSeparator(), violations.stream().map(v -%3E String%0A                
+.stream().map(ValidationException::format).collect(toCollection(TreeSet::new));%0A    %7D%0A%0A    @ConstructorProperties(%7B%22message%22, %22violations%22%7D)%0A    public ValidationException(String message, Set%3CString%3E violations) %7B%0A        super(message);%0A        this.violations = new TreeSet%3C%3E(violations);%0A    %7D%0A%0A    protected static String format(ConstraintViolation%3C?%3E v) %7B%0A        return String
 .for
@@ -1213,16 +1213,21 @@
         
+   
+  
 v.getMes
@@ -1233,16 +1233,231 @@
 ssage())
+;%0A    %7D%0A%0A    protected static String format(Set%3C? extends ConstraintViolation%3C?%3E%3E violations) %7B%0A        return String.join(System.lineSeparator(), violations.stream().map(%0A                ValidationException::format
 ).sorted

Fix issue with deserialization of ValidationException