public static void validate(WindowConfig windowConfig) {
        if (windowConfig.getWindowLengthDurationMs() == null && windowConfig.getWindowLengthCount() == null) {
            throw new IllegalArgumentException("Window length is not specified");
        }

        if (windowConfig.getWindowLengthDurationMs() != null && windowConfig.getWindowLengthCount() != null) {
            throw new IllegalArgumentException(
                    "Window length for time and count are set! Please set one or the other.");
        }

        if (windowConfig.getWindowLengthCount() != null) {
            if (windowConfig.getWindowLengthCount() <= 0) {
                throw new IllegalArgumentException(
                        "Window length must be positive [" + windowConfig.getWindowLengthCount() + "]");
            }
        }

        if (windowConfig.getWindowLengthDurationMs() != null) {
            if (windowConfig.getWindowLengthDurationMs() <= 0) {
                throw new IllegalArgumentException(
                        "Window length must be positive [" + windowConfig.getWindowLengthDurationMs() + "]");
            }
        }

        if (windowConfig.getSlidingIntervalCount() != null) {
            if (windowConfig.getSlidingIntervalCount() <= 0) {
                throw new IllegalArgumentException(
                        "Sliding interval must be positive [" + windowConfig.getSlidingIntervalCount() + "]");
            }
        }

        if (windowConfig.getSlidingIntervalDurationMs() != null) {
            if (windowConfig.getSlidingIntervalDurationMs() <= 0) {
                throw new IllegalArgumentException(
                        "Sliding interval must be positive [" + windowConfig.getSlidingIntervalDurationMs() + "]");
            }
        }

        if (windowConfig.getTimestampExtractorClassName() != null) {
            if (windowConfig.getMaxLagMs() != null) {
                if (windowConfig.getMaxLagMs() < 0) {
                    throw new IllegalArgumentException(
                            "Lag duration must be positive [" + windowConfig.getMaxLagMs() + "]");
                }
            }
            if (windowConfig.getWatermarkEmitIntervalMs() != null) {
                if (windowConfig.getWatermarkEmitIntervalMs() <= 0) {
                    throw new IllegalArgumentException(
                            "Watermark interval must be positive [" + windowConfig.getWatermarkEmitIntervalMs() + "]");
                }
            }
        }
    }
@Test
    public void testSettingSlidingTimeWindow() throws Exception {
        final Object[][] args = new Object[][]{
                {-1L, 10L},
                {10L, -1L},
                {0L, 10L},
                {10L, 0L},
                {0L, 0L},
                {-1L, -1L},
                {5L, 10L},
                {1L, 1L},
                {10L, 5L},
                {100L, 10L},
                {100L, 100L},
                {200L, 100L},
                {500L, 100L},
                {null, null},
                {null, 1L},
                {1L, null},
                {null, -1L},
                {-1L, null}
        };

        for (Object[] arg : args) {
            Object arg0 = arg[0];
            Object arg1 = arg[1];
            try {
                Long windowLengthDuration = null;
                if (arg0 != null) {
                    windowLengthDuration = (Long) arg0;
                }
                Long slidingIntervalDuration = null;
                if (arg1 != null) {
                    slidingIntervalDuration = (Long) arg1;
                }

                WindowConfig windowConfig = new WindowConfig();
                windowConfig.setWindowLengthDurationMs(windowLengthDuration);
                windowConfig.setSlidingIntervalDurationMs(slidingIntervalDuration);
                WindowConfigUtils.validate(windowConfig);

                if (arg0 == null) {
                    fail(String.format("Window length cannot be null -- "
                            + "windowLengthCount: %s slidingIntervalCount: %s", arg0, arg1));
                }
                if ((Long) arg0 <= 0) {
                    fail(String.format("Window length cannot be zero or less -- "
                            + "windowLengthCount: %s slidingIntervalCount: %s", arg0, arg1));
                }
                if (arg1 != null && (Long) arg1 <= 0) {
                    fail(String.format("Sliding interval length cannot be zero or less -- "
                            + "windowLengthCount: %s slidingIntervalCount: %s", arg0, arg1));
                }
            } catch (IllegalArgumentException e) {
                if (arg0 != null && arg1 != null && (Long) arg0 > 0 && (Long) arg1 > 0) {
                    fail(String.format("Exception: %s thrown on valid input -- windowLengthDuration: %s "
                            + "slidingIntervalDuration: %s", e.getMessage(), arg0, arg1));
                }
            }
        }
    }