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

package com.azure.resourcemanager.advisor.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.advisor.fluent.models.ConfigDataProperties;
import com.azure.resourcemanager.advisor.models.Category;
import com.azure.resourcemanager.advisor.models.CpuThreshold;
import com.azure.resourcemanager.advisor.models.DigestConfig;
import com.azure.resourcemanager.advisor.models.DigestConfigState;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ConfigDataPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ConfigDataProperties model =
            BinaryData
                .fromString(
                    "{\"exclude\":true,\"lowCpuThreshold\":\"20\",\"digests\":[{\"name\":\"pczwlo\",\"actionGroupResourceId\":\"yemkkvnip\",\"frequency\":348606393,\"categories\":[\"Performance\",\"HighAvailability\"],\"language\":\"gejspodmailzyde\",\"state\":\"Disabled\"},{\"name\":\"yahux\",\"actionGroupResourceId\":\"pmqnja\",\"frequency\":1876507017,\"categories\":[\"Performance\",\"Performance\",\"Performance\"],\"language\":\"zvcputegjvwmfda\",\"state\":\"Active\"},{\"name\":\"dvpjhulsuuvmk\",\"actionGroupResourceId\":\"zkrwfn\",\"frequency\":287620729,\"categories\":[\"Performance\",\"Cost\"],\"language\":\"w\",\"state\":\"Disabled\"}]}")
                .toObject(ConfigDataProperties.class);
        Assertions.assertEquals(true, model.exclude());
        Assertions.assertEquals(CpuThreshold.TWO_ZERO, model.lowCpuThreshold());
        Assertions.assertEquals("pczwlo", model.digests().get(0).name());
        Assertions.assertEquals("yemkkvnip", model.digests().get(0).actionGroupResourceId());
        Assertions.assertEquals(348606393, model.digests().get(0).frequency());
        Assertions.assertEquals(Category.PERFORMANCE, model.digests().get(0).categories().get(0));
        Assertions.assertEquals("gejspodmailzyde", model.digests().get(0).language());
        Assertions.assertEquals(DigestConfigState.DISABLED, model.digests().get(0).state());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ConfigDataProperties model =
            new ConfigDataProperties()
                .withExclude(true)
                .withLowCpuThreshold(CpuThreshold.TWO_ZERO)
                .withDigests(
                    Arrays
                        .asList(
                            new DigestConfig()
                                .withName("pczwlo")
                                .withActionGroupResourceId("yemkkvnip")
                                .withFrequency(348606393)
                                .withCategories(Arrays.asList(Category.PERFORMANCE, Category.HIGH_AVAILABILITY))
                                .withLanguage("gejspodmailzyde")
                                .withState(DigestConfigState.DISABLED),
                            new DigestConfig()
                                .withName("yahux")
                                .withActionGroupResourceId("pmqnja")
                                .withFrequency(1876507017)
                                .withCategories(
                                    Arrays.asList(Category.PERFORMANCE, Category.PERFORMANCE, Category.PERFORMANCE))
                                .withLanguage("zvcputegjvwmfda")
                                .withState(DigestConfigState.ACTIVE),
                            new DigestConfig()
                                .withName("dvpjhulsuuvmk")
                                .withActionGroupResourceId("zkrwfn")
                                .withFrequency(287620729)
                                .withCategories(Arrays.asList(Category.PERFORMANCE, Category.COST))
                                .withLanguage("w")
                                .withState(DigestConfigState.DISABLED)));
        model = BinaryData.fromObject(model).toObject(ConfigDataProperties.class);
        Assertions.assertEquals(true, model.exclude());
        Assertions.assertEquals(CpuThreshold.TWO_ZERO, model.lowCpuThreshold());
        Assertions.assertEquals("pczwlo", model.digests().get(0).name());
        Assertions.assertEquals("yemkkvnip", model.digests().get(0).actionGroupResourceId());
        Assertions.assertEquals(348606393, model.digests().get(0).frequency());
        Assertions.assertEquals(Category.PERFORMANCE, model.digests().get(0).categories().get(0));
        Assertions.assertEquals("gejspodmailzyde", model.digests().get(0).language());
        Assertions.assertEquals(DigestConfigState.DISABLED, model.digests().get(0).state());
    }
}
