### Question:
ValidEnumValueOrProfileAttributeValidator implements
        ConstraintValidator<ValidEnumValueOrProfileAttribute, String>, ValidationErrorDescriptorBuilder { @Override public void initialize(ValidEnumValueOrProfileAttribute constraintAnnotation) { Object[] constants = constraintAnnotation.enumClass().getEnumConstants(); errorCode = constraintAnnotation.message(); if(constants == null){ throw new IllegalStateException("enumClass [" + constraintAnnotation.enumClass() + "]is not enum"); } for (Object constant : constants) { enumNames.add(constant.toString()); } }  @Override void initialize(ValidEnumValueOrProfileAttribute constraintAnnotation); @Override boolean isValid(String value, ConstraintValidatorContext context); @Override ErrorDescriptor build(ConstraintViolation violation);  }### Answer:
@Test public void initialize_notEnumClass_illegalStateException() { doReturn(Object.class).when(validEnumValueOrProfileAttribute).enumClass(); assertThrows(IllegalStateException.class, new Executable() { @Override public void execute() { validEnumValueOrProfileAttributeValidator.initialize(validEnumValueOrProfileAttribute); } }); }