// 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.ConfigDataInner;
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 ConfigDataInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ConfigDataInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"exclude\":false,\"lowCpuThreshold\":\"10\",\"digests\":[{\"name\":\"hanufhfcbjysagi\",\"actionGroupResourceId\":\"xqhabi\",\"frequency\":1105410727,\"categories\":[],\"language\":\"wczbys\",\"state\":\"Active\"},{\"name\":\"x\",\"actionGroupResourceId\":\"ivyqniwbybrkxvd\",\"frequency\":920256064,\"categories\":[],\"language\":\"tfwvukxgaudc\",\"state\":\"Disabled\"}]},\"id\":\"h\",\"name\":\"jcny\",\"type\":\"j\"}")
                .toObject(ConfigDataInner.class);
        Assertions.assertEquals(false, model.exclude());
        Assertions.assertEquals(CpuThreshold.ONE_ZERO, model.lowCpuThreshold());
        Assertions.assertEquals("hanufhfcbjysagi", model.digests().get(0).name());
        Assertions.assertEquals("xqhabi", model.digests().get(0).actionGroupResourceId());
        Assertions.assertEquals(1105410727, model.digests().get(0).frequency());
        Assertions.assertEquals("wczbys", model.digests().get(0).language());
        Assertions.assertEquals(DigestConfigState.ACTIVE, model.digests().get(0).state());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ConfigDataInner model =
            new ConfigDataInner()
                .withExclude(false)
                .withLowCpuThreshold(CpuThreshold.ONE_ZERO)
                .withDigests(
                    Arrays
                        .asList(
                            new DigestConfig()
                                .withName("hanufhfcbjysagi")
                                .withActionGroupResourceId("xqhabi")
                                .withFrequency(1105410727)
                                .withCategories(Arrays.asList())
                                .withLanguage("wczbys")
                                .withState(DigestConfigState.ACTIVE),
                            new DigestConfig()
                                .withName("x")
                                .withActionGroupResourceId("ivyqniwbybrkxvd")
                                .withFrequency(920256064)
                                .withCategories(Arrays.asList())
                                .withLanguage("tfwvukxgaudc")
                                .withState(DigestConfigState.DISABLED)));
        model = BinaryData.fromObject(model).toObject(ConfigDataInner.class);
        Assertions.assertEquals(false, model.exclude());
        Assertions.assertEquals(CpuThreshold.ONE_ZERO, model.lowCpuThreshold());
        Assertions.assertEquals("hanufhfcbjysagi", model.digests().get(0).name());
        Assertions.assertEquals("xqhabi", model.digests().get(0).actionGroupResourceId());
        Assertions.assertEquals(1105410727, model.digests().get(0).frequency());
        Assertions.assertEquals("wczbys", model.digests().get(0).language());
        Assertions.assertEquals(DigestConfigState.ACTIVE, model.digests().get(0).state());
    }
}
