### Question:
SizeConstraintValidationErrorDescriptorBuilder implements ValidationErrorDescriptorBuilder<Size> { @Override public ErrorDescriptor build(ConstraintViolation<Size> violation) { final Size annotation = (Size) violation.getConstraintDescriptor().getAnnotation(); final String propertyPath = violation.getPropertyPath().toString(); final String invalidValue = violation.getInvalidValue().toString(); final String proprtyName = propertyPath.substring(propertyPath.lastIndexOf(".") + 1); final ErrorDescriptor errorDescriptor = new ErrorDescriptor(). setErrorCode(annotation.message()). setMessage("Length of field \"" + proprtyName + "\" breaks length limit."); errorDescriptor.addProperties(new ClientProperty("invalidValue", invalidValue), new ClientProperty("actualLength", String.valueOf(invalidValue.length())), new ClientProperty("maxLimit", String.valueOf(annotation.max())), new ClientProperty("minLimit", String.valueOf(annotation.min())), new ClientProperty("propertyPath", propertyPath)); return errorDescriptor; }  @Override ErrorDescriptor build(ConstraintViolation<Size> violation);  }### Answer:
@Test public void build_someViolation_returnDescriptor() { ErrorDescriptor expectedErrorDescriptor = new ErrorDescriptor().setErrorCode(errorCode). addProperties( new ClientProperty("invalidValue", String.valueOf(invalidValue)), new ClientProperty("actualLength", String.valueOf(invalidValue.length())), new ClientProperty("maxLimit", String.valueOf(maxValue)), new ClientProperty("minLimit", String.valueOf(minValue)), new ClientProperty("propertyPath", String.valueOf(propertyPath)) ) .setMessage("Length of field \"specPropertyName\" breaks length limit."); assertEquals(expectedErrorDescriptor, builder.build(violation)); }