### Question:
PropertyValueUtils { @NonNull public static <E extends Enum> E getEnumValue(@NonNull final PropertyDescriptor propertyDescriptor, @NonNull final PropertyContext context, @NonNull final Class<E> enumType, @NonNull final E defaultValue) { Objects.requireNonNull(propertyDescriptor, "PropertyDescriptor is required"); Objects.requireNonNull(context, "PropertyContext is required"); Objects.requireNonNull(enumType, "Enum type is required"); Objects.requireNonNull(defaultValue, "Default value is required"); PropertyValue property = context.getProperty(propertyDescriptor); if (property == null) { return defaultValue; } String propertyValue = property.getValue(); Objects.requireNonNull(enumType, "Type of Enum is required"); Objects.requireNonNull(defaultValue, "Default value which will be used if propertyValue is not enum value"); return getEnumValue(enumType, defaultValue, propertyValue); } private  PropertyValueUtils(); @NonNull static E getEnumValue(@NonNull final PropertyDescriptor propertyDescriptor,
                                                  @NonNull final PropertyContext context,
                                                  @NonNull final Class<E> enumType,
                                                  @NonNull final E defaultValue); @Nullable static E getEnumValue(@NonNull final Class<E> enumType,
                                                   @Nullable final E defaultValue,
                                                   @Nullable final String propertyValue); @NonNull static List<String> getList(@NonNull final PropertyDescriptor propertyDescriptor,
                                       @NonNull final PropertyContext context,
                                       @Nullable final FlowFile flowFile); @NonNull static MapperOptions getMapperOptions(@NonNull final PropertyContext context,
                                                 @Nullable final FlowFile flowFile);  }### Answer:
@Test public void enumValue() { testRunner.setProperty(TEST_ENUM_PROPERTY, PropertyEnum.TWO.name()); PropertyEnum propertyValue = PropertyValueUtils .getEnumValue(TEST_ENUM_PROPERTY, processContext, PropertyEnum.class, PropertyEnum.ONE); Assert.assertEquals(PropertyEnum.TWO, propertyValue); }
@Test public void enumValueDefault() { PropertyEnum propertyValue = PropertyValueUtils .getEnumValue(TEST_ENUM_PROPERTY, processContext, PropertyEnum.class, PropertyEnum.ONE); Assert.assertEquals(PropertyEnum.ONE, propertyValue); }
@Test public void enumValueNotExistConstant() { testRunner.setProperty(TEST_ENUM_PROPERTY, "not-exist-value"); PropertyEnum propertyValue = PropertyValueUtils .getEnumValue(TEST_ENUM_PROPERTY, processContext, PropertyEnum.class, PropertyEnum.ONE); Assert.assertEquals(PropertyEnum.ONE, propertyValue); }
@Test public void enumValueNull() { PropertyEnum enumValue = PropertyValueUtils.getEnumValue(PropertyEnum.class, null, null); Assert.assertNull(enumValue); }