public static Duration convertFreshnessToDuration(IntervalFreshness intervalFreshness) {
        // validate the freshness value firstly
        validateIntervalFreshness(intervalFreshness);

        long interval = Long.parseLong(intervalFreshness.getInterval());
        switch (intervalFreshness.getTimeUnit()) {
            case DAY:
                return Duration.ofDays(interval);
            case HOUR:
                return Duration.ofHours(interval);
            case MINUTE:
                return Duration.ofMinutes(interval);
            case SECOND:
                return Duration.ofSeconds(interval);
            default:
                throw new ValidationException(
                        String.format(
                                "Unknown freshness time unit: %s.",
                                intervalFreshness.getTimeUnit()));
        }
    }
@Test
    void testConvertFreshnessToDuration() {
        // verify second
        Duration actualSecond = convertFreshnessToDuration(IntervalFreshness.ofSecond("20"));
        assertThat(actualSecond).isEqualTo(Duration.ofSeconds(20));

        // verify minute
        Duration actualMinute = convertFreshnessToDuration(IntervalFreshness.ofMinute("3"));
        assertThat(actualMinute).isEqualTo(Duration.ofMinutes(3));

        // verify hour
        Duration actualHour = convertFreshnessToDuration(IntervalFreshness.ofHour("3"));
        assertThat(actualHour).isEqualTo(Duration.ofHours(3));

        // verify day
        Duration actualDay = convertFreshnessToDuration(IntervalFreshness.ofDay("3"));
        assertThat(actualDay).isEqualTo(Duration.ofDays(3));
    }