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 testSettingTumblingCountWindow() throws Exception {
        final Object[] args = new Object[]{-1, 0, 1, 2, 5, 10, null};

        for (Object arg : args) {
            Object arg0 = arg;
            try {

                Integer windowLengthCount = null;
                if (arg0 != null) {
                    windowLengthCount = (Integer) arg0;
                }

                WindowConfig windowConfig = new WindowConfig();
                windowConfig.setWindowLengthCount(windowLengthCount);
                WindowConfigUtils.validate(windowConfig);

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