// 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.AlertInner;
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 AlertInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AlertInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"definition\":{\"type\":\"Invoice\",\"category\":\"Billing\",\"criteria\":\"CrossCloudNewDataAvailable\"},\"description\":\"ubisnjampmng\",\"source\":\"Preset\",\"details\":{\"timeGrainType\":\"Monthly\",\"periodStartDate\":\"wooc\",\"triggeredBy\":\"bonqvpkvlrxnjeas\",\"resourceGroupFilter\":[\"dataheoflokeyyienjbd\",\"datawtgrhpdjpj\",\"datamasxazjpqyegu\"],\"resourceFilter\":[\"datab\"],\"meterFilter\":[\"datae\",\"datajzzvdud\"],\"tagFilter\":\"datadslfhotwmcy\",\"operator\":\"None\",\"unit\":\"npgacftade\",\"contactEmails\":[\"tyfsoppusuesn\",\"wd\"],\"contactGroups\":[\"avo\"],\"contactRoles\":[\"dmoh\",\"tbqvudw\",\"dndnvow\"],\"overridingAlert\":\"jjugwdkcglhslaz\",\"departmentName\":\"yggdtjixh\",\"companyName\":\"uofqwe\",\"enrollmentNumber\":\"hmenevfyexfwhybc\",\"enrollmentStartDate\":\"vyvdcs\",\"enrollmentEndDate\":\"ynnaam\"},\"costEntityId\":\"tehfiqscjeypvh\",\"status\":\"Resolved\",\"creationTime\":\"gqhcjrefovg\",\"closeTime\":\"qsl\",\"modificationTime\":\"yvxyqjp\",\"statusModificationUserName\":\"attpngjcrcczsq\",\"statusModificationTime\":\"hvmdajvnysounq\"},\"eTag\":\"a\",\"id\":\"oaeupfhyhltrpmo\",\"name\":\"jmcmatuokthfu\",\"type\":\"uaodsfcpk\"}")
                .toObject(AlertInner.class);
        Assertions.assertEquals("a", model.etag());
        Assertions.assertEquals(AlertType.INVOICE, model.definition().type());
        Assertions.assertEquals(AlertCategory.BILLING, model.definition().category());
        Assertions.assertEquals(AlertCriteria.CROSS_CLOUD_NEW_DATA_AVAILABLE, model.definition().criteria());
        Assertions.assertEquals("ubisnjampmng", model.description());
        Assertions.assertEquals(AlertSource.PRESET, model.source());
        Assertions.assertEquals(AlertTimeGrainType.MONTHLY, model.details().timeGrainType());
        Assertions.assertEquals("wooc", model.details().periodStartDate());
        Assertions.assertEquals("bonqvpkvlrxnjeas", model.details().triggeredBy());
        Assertions.assertEquals(AlertOperator.NONE, model.details().operator());
        Assertions.assertEquals("npgacftade", model.details().unit());
        Assertions.assertEquals("tyfsoppusuesn", model.details().contactEmails().get(0));
        Assertions.assertEquals("avo", model.details().contactGroups().get(0));
        Assertions.assertEquals("dmoh", model.details().contactRoles().get(0));
        Assertions.assertEquals("jjugwdkcglhslaz", model.details().overridingAlert());
        Assertions.assertEquals("yggdtjixh", model.details().departmentName());
        Assertions.assertEquals("uofqwe", model.details().companyName());
        Assertions.assertEquals("hmenevfyexfwhybc", model.details().enrollmentNumber());
        Assertions.assertEquals("vyvdcs", model.details().enrollmentStartDate());
        Assertions.assertEquals("ynnaam", model.details().enrollmentEndDate());
        Assertions.assertEquals("tehfiqscjeypvh", model.costEntityId());
        Assertions.assertEquals(AlertStatus.RESOLVED, model.status());
        Assertions.assertEquals("gqhcjrefovg", model.creationTime());
        Assertions.assertEquals("qsl", model.closeTime());
        Assertions.assertEquals("yvxyqjp", model.modificationTime());
        Assertions.assertEquals("attpngjcrcczsq", model.statusModificationUsername());
        Assertions.assertEquals("hvmdajvnysounq", model.statusModificationTime());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AlertInner model =
            new AlertInner()
                .withEtag("a")
                .withDefinition(
                    new AlertPropertiesDefinition()
                        .withType(AlertType.INVOICE)
                        .withCategory(AlertCategory.BILLING)
                        .withCriteria(AlertCriteria.CROSS_CLOUD_NEW_DATA_AVAILABLE))
                .withDescription("ubisnjampmng")
                .withSource(AlertSource.PRESET)
                .withDetails(
                    new AlertPropertiesDetails()
                        .withTimeGrainType(AlertTimeGrainType.MONTHLY)
                        .withPeriodStartDate("wooc")
                        .withTriggeredBy("bonqvpkvlrxnjeas")
                        .withResourceGroupFilter(
                            Arrays.asList("dataheoflokeyyienjbd", "datawtgrhpdjpj", "datamasxazjpqyegu"))
                        .withResourceFilter(Arrays.asList("datab"))
                        .withMeterFilter(Arrays.asList("datae", "datajzzvdud"))
                        .withTagFilter("datadslfhotwmcy")
                        .withOperator(AlertOperator.NONE)
                        .withUnit("npgacftade")
                        .withContactEmails(Arrays.asList("tyfsoppusuesn", "wd"))
                        .withContactGroups(Arrays.asList("avo"))
                        .withContactRoles(Arrays.asList("dmoh", "tbqvudw", "dndnvow"))
                        .withOverridingAlert("jjugwdkcglhslaz")
                        .withDepartmentName("yggdtjixh")
                        .withCompanyName("uofqwe")
                        .withEnrollmentNumber("hmenevfyexfwhybc")
                        .withEnrollmentStartDate("vyvdcs")
                        .withEnrollmentEndDate("ynnaam"))
                .withCostEntityId("tehfiqscjeypvh")
                .withStatus(AlertStatus.RESOLVED)
                .withCreationTime("gqhcjrefovg")
                .withCloseTime("qsl")
                .withModificationTime("yvxyqjp")
                .withStatusModificationUsername("attpngjcrcczsq")
                .withStatusModificationTime("hvmdajvnysounq");
        model = BinaryData.fromObject(model).toObject(AlertInner.class);
        Assertions.assertEquals("a", model.etag());
        Assertions.assertEquals(AlertType.INVOICE, model.definition().type());
        Assertions.assertEquals(AlertCategory.BILLING, model.definition().category());
        Assertions.assertEquals(AlertCriteria.CROSS_CLOUD_NEW_DATA_AVAILABLE, model.definition().criteria());
        Assertions.assertEquals("ubisnjampmng", model.description());
        Assertions.assertEquals(AlertSource.PRESET, model.source());
        Assertions.assertEquals(AlertTimeGrainType.MONTHLY, model.details().timeGrainType());
        Assertions.assertEquals("wooc", model.details().periodStartDate());
        Assertions.assertEquals("bonqvpkvlrxnjeas", model.details().triggeredBy());
        Assertions.assertEquals(AlertOperator.NONE, model.details().operator());
        Assertions.assertEquals("npgacftade", model.details().unit());
        Assertions.assertEquals("tyfsoppusuesn", model.details().contactEmails().get(0));
        Assertions.assertEquals("avo", model.details().contactGroups().get(0));
        Assertions.assertEquals("dmoh", model.details().contactRoles().get(0));
        Assertions.assertEquals("jjugwdkcglhslaz", model.details().overridingAlert());
        Assertions.assertEquals("yggdtjixh", model.details().departmentName());
        Assertions.assertEquals("uofqwe", model.details().companyName());
        Assertions.assertEquals("hmenevfyexfwhybc", model.details().enrollmentNumber());
        Assertions.assertEquals("vyvdcs", model.details().enrollmentStartDate());
        Assertions.assertEquals("ynnaam", model.details().enrollmentEndDate());
        Assertions.assertEquals("tehfiqscjeypvh", model.costEntityId());
        Assertions.assertEquals(AlertStatus.RESOLVED, model.status());
        Assertions.assertEquals("gqhcjrefovg", model.creationTime());
        Assertions.assertEquals("qsl", model.closeTime());
        Assertions.assertEquals("yvxyqjp", model.modificationTime());
        Assertions.assertEquals("attpngjcrcczsq", model.statusModificationUsername());
        Assertions.assertEquals("hvmdajvnysounq", model.statusModificationTime());
    }
}
