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 testSettingLagTime() throws Exception {
        final Object[] args = new Object[]{-1L, 0L, 1L, 2L, 5L, 10L, null};
        for (Object arg : args) {
            Object arg0 = arg;
            try {

                Long maxLagMs = null;
                if (arg0 != null) {
                    maxLagMs = (Long) arg0;
                }

                WindowConfig windowConfig = new WindowConfig();
                windowConfig.setWindowLengthCount(1);
                windowConfig.setSlidingIntervalCount(1);
                windowConfig.setMaxLagMs(maxLagMs);
                windowConfig.setTimestampExtractorClassName("SomeClass");
                WindowConfigUtils.validate(windowConfig);

                if(arg0 != null && (Long) arg0 < 0) {
                    fail(String.format("Window lag cannot be less than zero -- lagTime: %s", arg0));
                }
            } catch (IllegalArgumentException e) {
                if (arg0 != null && (Long) arg0 > 0) {
                    fail(String.format("Exception: %s thrown on valid input -- lagTime: %s",
                            e.getMessage(), arg0));
                }
            }
        }
    }