### Question:
InstanceOfValidator implements ConstraintValidator<InstanceOf, ClientExpression>, ValidationErrorDescriptorBuilder { @Override public ErrorDescriptor build(ConstraintViolation violation) { InstanceOf annotation = (InstanceOf) violation.getConstraintDescriptor().getAnnotation(); final ErrorDescriptor errorDescriptor = new ErrorDescriptor() .setErrorCode(annotation.errorCode()) .setMessage(annotation.message()); errorDescriptor.addProperties(new ClientProperty("invalidType", ClientTypeUtility.extractClientType(violation.getInvalidValue().getClass())) ); return errorDescriptor; }  @Override void initialize(InstanceOf constraintAnnotation); @Override boolean isValid(ClientExpression value, ConstraintValidatorContext context); @Override ErrorDescriptor build(ConstraintViolation violation);  }### Answer:
@Test public void buildErrorDescriptor() { String invalidType = ClientTypeUtility.extractClientType(invalidValueMock.getClass()); doReturn(invalidValueMock).when(constraintViolationMock).getInvalidValue(); doReturn(constraintDescriptorMock).when(constraintViolationMock).getConstraintDescriptor(); doReturn(instanceOfMock).when(constraintDescriptorMock).getAnnotation(); doReturn("message").when(instanceOfMock).message(); doReturn("errorCode").when(instanceOfMock).errorCode(); assertNotNull(validator.build(constraintViolationMock)); assertEquals(validator.build(constraintViolationMock).getMessage(), "message"); assertEquals(validator.build(constraintViolationMock).getErrorCode(), "errorCode"); assertNotNull(validator.build(constraintViolationMock).getProperties()); ClientProperty clientProperty = validator.build(constraintViolationMock).getProperties().get(0); assertEquals(clientProperty.getKey(), "invalidType"); assertEquals(clientProperty.getValue(), invalidType); }