@Test
public void test() throws ParseException {

    CommandLineParser parser = new DefaultParser();
    Options options = new Options();
    options.addOption(Option.builder().longOpt("value")
        .hasArg()
        .build());
    // Check for user value
    String[] args = {"--value", "VALUE2"};
    CommandLine line = parser.parse(options, args);
    assertEquals(TestEnum.VALUE2, CommandLineUtil.getOptionValue(line, "value", TestEnum.class, TestEnum.VALUE1));
    // Check for default value
    args = new String[0];
    line = parser.parse(options, args);
    assertEquals(TestEnum.VALUE1, CommandLineUtil.getOptionValue(line, "value", TestEnum.class, TestEnum.VALUE1));
}