// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.security.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.security.models.TimeWindowCustomAlertRule;
import java.time.Duration;
import org.junit.jupiter.api.Assertions;

public final class TimeWindowCustomAlertRuleTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        TimeWindowCustomAlertRule model =
            BinaryData
                .fromString(
                    "{\"ruleType\":\"TimeWindowCustomAlertRule\",\"timeWindowSize\":\"PT137H35S\",\"minThreshold\":80244831,\"maxThreshold\":925016585,\"displayName\":\"oo\",\"description\":\"xlzevgbmqjqabcy\",\"isEnabled\":true}")
                .toObject(TimeWindowCustomAlertRule.class);
        Assertions.assertEquals(true, model.isEnabled());
        Assertions.assertEquals(80244831, model.minThreshold());
        Assertions.assertEquals(925016585, model.maxThreshold());
        Assertions.assertEquals(Duration.parse("PT137H35S"), model.timeWindowSize());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        TimeWindowCustomAlertRule model =
            new TimeWindowCustomAlertRule()
                .withIsEnabled(true)
                .withMinThreshold(80244831)
                .withMaxThreshold(925016585)
                .withTimeWindowSize(Duration.parse("PT137H35S"));
        model = BinaryData.fromObject(model).toObject(TimeWindowCustomAlertRule.class);
        Assertions.assertEquals(true, model.isEnabled());
        Assertions.assertEquals(80244831, model.minThreshold());
        Assertions.assertEquals(925016585, model.maxThreshold());
        Assertions.assertEquals(Duration.parse("PT137H35S"), model.timeWindowSize());
    }
}
