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

package com.azure.resourcemanager.costmanagement.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.costmanagement.fluent.models.AlertProperties;
import com.azure.resourcemanager.costmanagement.models.AlertCategory;
import com.azure.resourcemanager.costmanagement.models.AlertCriteria;
import com.azure.resourcemanager.costmanagement.models.AlertOperator;
import com.azure.resourcemanager.costmanagement.models.AlertPropertiesDefinition;
import com.azure.resourcemanager.costmanagement.models.AlertPropertiesDetails;
import com.azure.resourcemanager.costmanagement.models.AlertSource;
import com.azure.resourcemanager.costmanagement.models.AlertStatus;
import com.azure.resourcemanager.costmanagement.models.AlertTimeGrainType;
import com.azure.resourcemanager.costmanagement.models.AlertType;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AlertPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AlertProperties model =
            BinaryData
                .fromString(
                    "{\"definition\":{\"type\":\"Quota\",\"category\":\"System\",\"criteria\":\"QuotaThresholdApproaching\"},\"description\":\"yzydagfuaxbezyi\",\"source\":\"User\",\"details\":{\"timeGrainType\":\"None\",\"periodStartDate\":\"rdxwzywqsm\",\"triggeredBy\":\"ureximoryocfs\",\"resourceGroupFilter\":[\"dataymddys\"],\"resourceFilter\":[\"dataiuxhqyudxorr\"],\"meterFilter\":[\"datapoczvyifqrvkdvjs\"],\"tagFilter\":\"datarm\",\"operator\":\"LessThanOrEqualTo\",\"unit\":\"t\",\"contactEmails\":[\"ulexxbczwtr\",\"wiqzbqjvsovmyo\",\"acspkwl\"],\"contactGroups\":[\"obpxjmflbvvn\",\"hrk\",\"ciwwzjuqkhr\",\"ajiwkuo\"],\"contactRoles\":[\"kg\",\"sauuimj\",\"vxieduugidyj\"],\"overridingAlert\":\"f\",\"departmentName\":\"aos\",\"companyName\":\"xc\",\"enrollmentNumber\":\"npc\",\"enrollmentStartDate\":\"ocohslkevleg\",\"enrollmentEndDate\":\"fbuhfmvfaxkffe\"},\"costEntityId\":\"hl\",\"status\":\"None\",\"creationTime\":\"yvshxmz\",\"closeTime\":\"bzoggigrx\",\"modificationTime\":\"ur\",\"statusModificationUserName\":\"xxjnspydptk\",\"statusModificationTime\":\"nkoukn\"}")
                .toObject(AlertProperties.class);
        Assertions.assertEquals(AlertType.QUOTA, model.definition().type());
        Assertions.assertEquals(AlertCategory.SYSTEM, model.definition().category());
        Assertions.assertEquals(AlertCriteria.QUOTA_THRESHOLD_APPROACHING, model.definition().criteria());
        Assertions.assertEquals("yzydagfuaxbezyi", model.description());
        Assertions.assertEquals(AlertSource.USER, model.source());
        Assertions.assertEquals(AlertTimeGrainType.NONE, model.details().timeGrainType());
        Assertions.assertEquals("rdxwzywqsm", model.details().periodStartDate());
        Assertions.assertEquals("ureximoryocfs", model.details().triggeredBy());
        Assertions.assertEquals(AlertOperator.LESS_THAN_OR_EQUAL_TO, model.details().operator());
        Assertions.assertEquals("t", model.details().unit());
        Assertions.assertEquals("ulexxbczwtr", model.details().contactEmails().get(0));
        Assertions.assertEquals("obpxjmflbvvn", model.details().contactGroups().get(0));
        Assertions.assertEquals("kg", model.details().contactRoles().get(0));
        Assertions.assertEquals("f", model.details().overridingAlert());
        Assertions.assertEquals("aos", model.details().departmentName());
        Assertions.assertEquals("xc", model.details().companyName());
        Assertions.assertEquals("npc", model.details().enrollmentNumber());
        Assertions.assertEquals("ocohslkevleg", model.details().enrollmentStartDate());
        Assertions.assertEquals("fbuhfmvfaxkffe", model.details().enrollmentEndDate());
        Assertions.assertEquals("hl", model.costEntityId());
        Assertions.assertEquals(AlertStatus.NONE, model.status());
        Assertions.assertEquals("yvshxmz", model.creationTime());
        Assertions.assertEquals("bzoggigrx", model.closeTime());
        Assertions.assertEquals("ur", model.modificationTime());
        Assertions.assertEquals("xxjnspydptk", model.statusModificationUsername());
        Assertions.assertEquals("nkoukn", model.statusModificationTime());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AlertProperties model =
            new AlertProperties()
                .withDefinition(
                    new AlertPropertiesDefinition()
                        .withType(AlertType.QUOTA)
                        .withCategory(AlertCategory.SYSTEM)
                        .withCriteria(AlertCriteria.QUOTA_THRESHOLD_APPROACHING))
                .withDescription("yzydagfuaxbezyi")
                .withSource(AlertSource.USER)
                .withDetails(
                    new AlertPropertiesDetails()
                        .withTimeGrainType(AlertTimeGrainType.NONE)
                        .withPeriodStartDate("rdxwzywqsm")
                        .withTriggeredBy("ureximoryocfs")
                        .withResourceGroupFilter(Arrays.asList("dataymddys"))
                        .withResourceFilter(Arrays.asList("dataiuxhqyudxorr"))
                        .withMeterFilter(Arrays.asList("datapoczvyifqrvkdvjs"))
                        .withTagFilter("datarm")
                        .withOperator(AlertOperator.LESS_THAN_OR_EQUAL_TO)
                        .withUnit("t")
                        .withContactEmails(Arrays.asList("ulexxbczwtr", "wiqzbqjvsovmyo", "acspkwl"))
                        .withContactGroups(Arrays.asList("obpxjmflbvvn", "hrk", "ciwwzjuqkhr", "ajiwkuo"))
                        .withContactRoles(Arrays.asList("kg", "sauuimj", "vxieduugidyj"))
                        .withOverridingAlert("f")
                        .withDepartmentName("aos")
                        .withCompanyName("xc")
                        .withEnrollmentNumber("npc")
                        .withEnrollmentStartDate("ocohslkevleg")
                        .withEnrollmentEndDate("fbuhfmvfaxkffe"))
                .withCostEntityId("hl")
                .withStatus(AlertStatus.NONE)
                .withCreationTime("yvshxmz")
                .withCloseTime("bzoggigrx")
                .withModificationTime("ur")
                .withStatusModificationUsername("xxjnspydptk")
                .withStatusModificationTime("nkoukn");
        model = BinaryData.fromObject(model).toObject(AlertProperties.class);
        Assertions.assertEquals(AlertType.QUOTA, model.definition().type());
        Assertions.assertEquals(AlertCategory.SYSTEM, model.definition().category());
        Assertions.assertEquals(AlertCriteria.QUOTA_THRESHOLD_APPROACHING, model.definition().criteria());
        Assertions.assertEquals("yzydagfuaxbezyi", model.description());
        Assertions.assertEquals(AlertSource.USER, model.source());
        Assertions.assertEquals(AlertTimeGrainType.NONE, model.details().timeGrainType());
        Assertions.assertEquals("rdxwzywqsm", model.details().periodStartDate());
        Assertions.assertEquals("ureximoryocfs", model.details().triggeredBy());
        Assertions.assertEquals(AlertOperator.LESS_THAN_OR_EQUAL_TO, model.details().operator());
        Assertions.assertEquals("t", model.details().unit());
        Assertions.assertEquals("ulexxbczwtr", model.details().contactEmails().get(0));
        Assertions.assertEquals("obpxjmflbvvn", model.details().contactGroups().get(0));
        Assertions.assertEquals("kg", model.details().contactRoles().get(0));
        Assertions.assertEquals("f", model.details().overridingAlert());
        Assertions.assertEquals("aos", model.details().departmentName());
        Assertions.assertEquals("xc", model.details().companyName());
        Assertions.assertEquals("npc", model.details().enrollmentNumber());
        Assertions.assertEquals("ocohslkevleg", model.details().enrollmentStartDate());
        Assertions.assertEquals("fbuhfmvfaxkffe", model.details().enrollmentEndDate());
        Assertions.assertEquals("hl", model.costEntityId());
        Assertions.assertEquals(AlertStatus.NONE, model.status());
        Assertions.assertEquals("yvshxmz", model.creationTime());
        Assertions.assertEquals("bzoggigrx", model.closeTime());
        Assertions.assertEquals("ur", model.modificationTime());
        Assertions.assertEquals("xxjnspydptk", model.statusModificationUsername());
        Assertions.assertEquals("nkoukn", model.statusModificationTime());
    }
}
