// 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.fluent.models.AlertsSuppressionRuleInner;
import com.azure.resourcemanager.security.models.AlertsSuppressionRulesList;
import com.azure.resourcemanager.security.models.RuleState;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AlertsSuppressionRulesListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AlertsSuppressionRulesList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"alertType\":\"hvbbxuripltfnh\",\"lastModifiedUtc\":\"2021-05-19T04:32:03Z\",\"expirationDateUtc\":\"2021-08-21T19:13:45Z\",\"reason\":\"gx\",\"state\":\"Expired\",\"comment\":\"ckpyklyhplu\"},\"id\":\"pvruudlg\",\"name\":\"ibthostgktstvd\",\"type\":\"eclze\"},{\"properties\":{\"alertType\":\"bcvhzlhpl\",\"lastModifiedUtc\":\"2021-07-07T17:09:43Z\",\"expirationDateUtc\":\"2021-05-30T19:04:16Z\",\"reason\":\"lwwqfbumlkxtrqj\",\"state\":\"Disabled\",\"comment\":\"lmbtxhwgfwsrt\"},\"id\":\"coezbrhubskh\",\"name\":\"dyg\",\"type\":\"ookk\"},{\"properties\":{\"alertType\":\"qjbvleorfmlu\",\"lastModifiedUtc\":\"2021-07-18T04:19:58Z\",\"expirationDateUtc\":\"2021-10-19T17:51:06Z\",\"reason\":\"fa\",\"state\":\"Disabled\",\"comment\":\"nqqyba\"},\"id\":\"euayjkqabqgzsles\",\"name\":\"cbhernntiewdj\",\"type\":\"vbquwr\"}],\"nextLink\":\"hwagohbuffkmrqe\"}")
                .toObject(AlertsSuppressionRulesList.class);
        Assertions.assertEquals("hvbbxuripltfnh", model.value().get(0).alertType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-21T19:13:45Z"), model.value().get(0).expirationDateUtc());
        Assertions.assertEquals("gx", model.value().get(0).reason());
        Assertions.assertEquals(RuleState.EXPIRED, model.value().get(0).state());
        Assertions.assertEquals("ckpyklyhplu", model.value().get(0).comment());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AlertsSuppressionRulesList model =
            new AlertsSuppressionRulesList()
                .withValue(
                    Arrays
                        .asList(
                            new AlertsSuppressionRuleInner()
                                .withAlertType("hvbbxuripltfnh")
                                .withExpirationDateUtc(OffsetDateTime.parse("2021-08-21T19:13:45Z"))
                                .withReason("gx")
                                .withState(RuleState.EXPIRED)
                                .withComment("ckpyklyhplu"),
                            new AlertsSuppressionRuleInner()
                                .withAlertType("bcvhzlhpl")
                                .withExpirationDateUtc(OffsetDateTime.parse("2021-05-30T19:04:16Z"))
                                .withReason("lwwqfbumlkxtrqj")
                                .withState(RuleState.DISABLED)
                                .withComment("lmbtxhwgfwsrt"),
                            new AlertsSuppressionRuleInner()
                                .withAlertType("qjbvleorfmlu")
                                .withExpirationDateUtc(OffsetDateTime.parse("2021-10-19T17:51:06Z"))
                                .withReason("fa")
                                .withState(RuleState.DISABLED)
                                .withComment("nqqyba")));
        model = BinaryData.fromObject(model).toObject(AlertsSuppressionRulesList.class);
        Assertions.assertEquals("hvbbxuripltfnh", model.value().get(0).alertType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-21T19:13:45Z"), model.value().get(0).expirationDateUtc());
        Assertions.assertEquals("gx", model.value().get(0).reason());
        Assertions.assertEquals(RuleState.EXPIRED, model.value().get(0).state());
        Assertions.assertEquals("ckpyklyhplu", model.value().get(0).comment());
    }
}
