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

package com.azure.resourcemanager.frontdoor.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.frontdoor.fluent.models.FrontendEndpointInner;
import com.azure.resourcemanager.frontdoor.models.BackendPool;
import com.azure.resourcemanager.frontdoor.models.BackendPoolsSettings;
import com.azure.resourcemanager.frontdoor.models.EnforceCertificateNameCheckEnabledState;
import com.azure.resourcemanager.frontdoor.models.FrontDoorEnabledState;
import com.azure.resourcemanager.frontdoor.models.FrontDoorHealthProbeMethod;
import com.azure.resourcemanager.frontdoor.models.FrontDoorProtocol;
import com.azure.resourcemanager.frontdoor.models.FrontDoorUpdateParameters;
import com.azure.resourcemanager.frontdoor.models.HealthProbeEnabled;
import com.azure.resourcemanager.frontdoor.models.HealthProbeSettingsModel;
import com.azure.resourcemanager.frontdoor.models.LoadBalancingSettingsModel;
import com.azure.resourcemanager.frontdoor.models.RoutingRule;
import com.azure.resourcemanager.frontdoor.models.RoutingRuleEnabledState;
import com.azure.resourcemanager.frontdoor.models.SessionAffinityEnabledState;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class FrontDoorUpdateParametersTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        FrontDoorUpdateParameters model =
            BinaryData
                .fromString(
                    "{\"friendlyName\":\"pjmkhfxobbc\",\"routingRules\":[{\"properties\":{\"resourceState\":\"Migrated\",\"frontendEndpoints\":[],\"acceptedProtocols\":[],\"patternsToMatch\":[],\"enabledState\":\"Disabled\"},\"name\":\"wtgh\",\"type\":\"blcg\",\"id\":\"zvlvqhjkbegib\"}],\"loadBalancingSettings\":[{\"properties\":{\"resourceState\":\"Deleting\",\"sampleSize\":1258750458,\"successfulSamplesRequired\":1397437100,\"additionalLatencyMilliseconds\":1232796575},\"name\":\"yqcgwrtzjuzgwy\",\"type\":\"htxongmtsavjc\",\"id\":\"wxqpsrknftguvri\"},{\"properties\":{\"resourceState\":\"Deleting\",\"sampleSize\":835302956,\"successfulSamplesRequired\":1448281883,\"additionalLatencyMilliseconds\":628006410},\"name\":\"tayriwwroyqbex\",\"type\":\"cqibycnojv\",\"id\":\"mefqsgzvahapjyzh\"}],\"healthProbeSettings\":[{\"properties\":{\"resourceState\":\"Migrated\",\"path\":\"rvxdjzlmw\",\"protocol\":\"Https\",\"intervalInSeconds\":413444138,\"healthProbeMethod\":\"HEAD\",\"enabledState\":\"Enabled\"},\"name\":\"vawjvzunlu\",\"type\":\"nnprn\",\"id\":\"peilpjzuaejxdu\"},{\"properties\":{\"resourceState\":\"Enabled\",\"path\":\"bbtdzumvee\",\"protocol\":\"Http\",\"intervalInSeconds\":1817395780,\"healthProbeMethod\":\"GET\",\"enabledState\":\"Enabled\"},\"name\":\"p\",\"type\":\"jyofdxluusdtto\",\"id\":\"aboekqv\"}],\"backendPools\":[{\"properties\":{\"resourceState\":\"Enabling\",\"backends\":[]},\"name\":\"yjsflhhcaalnji\",\"type\":\"sxyawjoyaqcs\",\"id\":\"jpkiidzyexznelix\"}],\"frontendEndpoints\":[{\"properties\":{\"resourceState\":\"Deleting\",\"customHttpsProvisioningState\":\"Disabled\",\"customHttpsProvisioningSubstate\":\"CertificateDeployed\",\"hostName\":\"knalaulppg\",\"sessionAffinityEnabledState\":\"Disabled\",\"sessionAffinityTtlSeconds\":1767174247},\"name\":\"nyiropuhpi\",\"type\":\"pgylg\",\"id\":\"itxmedjvcslynqww\"}],\"backendPoolsSettings\":{\"enforceCertificateNameCheck\":\"Disabled\",\"sendRecvTimeoutSeconds\":538641166},\"enabledState\":\"Disabled\"}")
                .toObject(FrontDoorUpdateParameters.class);
        Assertions.assertEquals("pjmkhfxobbc", model.friendlyName());
        Assertions.assertEquals("zvlvqhjkbegib", model.routingRules().get(0).id());
        Assertions.assertEquals("wtgh", model.routingRules().get(0).name());
        Assertions.assertEquals(RoutingRuleEnabledState.DISABLED, model.routingRules().get(0).enabledState());
        Assertions.assertEquals("wxqpsrknftguvri", model.loadBalancingSettings().get(0).id());
        Assertions.assertEquals("yqcgwrtzjuzgwy", model.loadBalancingSettings().get(0).name());
        Assertions.assertEquals(1258750458, model.loadBalancingSettings().get(0).sampleSize());
        Assertions.assertEquals(1397437100, model.loadBalancingSettings().get(0).successfulSamplesRequired());
        Assertions.assertEquals(1232796575, model.loadBalancingSettings().get(0).additionalLatencyMilliseconds());
        Assertions.assertEquals("peilpjzuaejxdu", model.healthProbeSettings().get(0).id());
        Assertions.assertEquals("vawjvzunlu", model.healthProbeSettings().get(0).name());
        Assertions.assertEquals("rvxdjzlmw", model.healthProbeSettings().get(0).path());
        Assertions.assertEquals(FrontDoorProtocol.HTTPS, model.healthProbeSettings().get(0).protocol());
        Assertions.assertEquals(413444138, model.healthProbeSettings().get(0).intervalInSeconds());
        Assertions
            .assertEquals(FrontDoorHealthProbeMethod.HEAD, model.healthProbeSettings().get(0).healthProbeMethod());
        Assertions.assertEquals(HealthProbeEnabled.ENABLED, model.healthProbeSettings().get(0).enabledState());
        Assertions.assertEquals("jpkiidzyexznelix", model.backendPools().get(0).id());
        Assertions.assertEquals("yjsflhhcaalnji", model.backendPools().get(0).name());
        Assertions.assertEquals("itxmedjvcslynqww", model.frontendEndpoints().get(0).id());
        Assertions.assertEquals("nyiropuhpi", model.frontendEndpoints().get(0).name());
        Assertions.assertEquals("knalaulppg", model.frontendEndpoints().get(0).hostname());
        Assertions
            .assertEquals(
                SessionAffinityEnabledState.DISABLED, model.frontendEndpoints().get(0).sessionAffinityEnabledState());
        Assertions.assertEquals(1767174247, model.frontendEndpoints().get(0).sessionAffinityTtlSeconds());
        Assertions
            .assertEquals(
                EnforceCertificateNameCheckEnabledState.DISABLED,
                model.backendPoolsSettings().enforceCertificateNameCheck());
        Assertions.assertEquals(538641166, model.backendPoolsSettings().sendRecvTimeoutSeconds());
        Assertions.assertEquals(FrontDoorEnabledState.DISABLED, model.enabledState());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        FrontDoorUpdateParameters model =
            new FrontDoorUpdateParameters()
                .withFriendlyName("pjmkhfxobbc")
                .withRoutingRules(
                    Arrays
                        .asList(
                            new RoutingRule()
                                .withId("zvlvqhjkbegib")
                                .withName("wtgh")
                                .withFrontendEndpoints(Arrays.asList())
                                .withAcceptedProtocols(Arrays.asList())
                                .withPatternsToMatch(Arrays.asList())
                                .withEnabledState(RoutingRuleEnabledState.DISABLED)))
                .withLoadBalancingSettings(
                    Arrays
                        .asList(
                            new LoadBalancingSettingsModel()
                                .withId("wxqpsrknftguvri")
                                .withName("yqcgwrtzjuzgwy")
                                .withSampleSize(1258750458)
                                .withSuccessfulSamplesRequired(1397437100)
                                .withAdditionalLatencyMilliseconds(1232796575),
                            new LoadBalancingSettingsModel()
                                .withId("mefqsgzvahapjyzh")
                                .withName("tayriwwroyqbex")
                                .withSampleSize(835302956)
                                .withSuccessfulSamplesRequired(1448281883)
                                .withAdditionalLatencyMilliseconds(628006410)))
                .withHealthProbeSettings(
                    Arrays
                        .asList(
                            new HealthProbeSettingsModel()
                                .withId("peilpjzuaejxdu")
                                .withName("vawjvzunlu")
                                .withPath("rvxdjzlmw")
                                .withProtocol(FrontDoorProtocol.HTTPS)
                                .withIntervalInSeconds(413444138)
                                .withHealthProbeMethod(FrontDoorHealthProbeMethod.HEAD)
                                .withEnabledState(HealthProbeEnabled.ENABLED),
                            new HealthProbeSettingsModel()
                                .withId("aboekqv")
                                .withName("p")
                                .withPath("bbtdzumvee")
                                .withProtocol(FrontDoorProtocol.HTTP)
                                .withIntervalInSeconds(1817395780)
                                .withHealthProbeMethod(FrontDoorHealthProbeMethod.GET)
                                .withEnabledState(HealthProbeEnabled.ENABLED)))
                .withBackendPools(
                    Arrays
                        .asList(
                            new BackendPool()
                                .withId("jpkiidzyexznelix")
                                .withName("yjsflhhcaalnji")
                                .withBackends(Arrays.asList())))
                .withFrontendEndpoints(
                    Arrays
                        .asList(
                            new FrontendEndpointInner()
                                .withId("itxmedjvcslynqww")
                                .withName("nyiropuhpi")
                                .withHostname("knalaulppg")
                                .withSessionAffinityEnabledState(SessionAffinityEnabledState.DISABLED)
                                .withSessionAffinityTtlSeconds(1767174247)))
                .withBackendPoolsSettings(
                    new BackendPoolsSettings()
                        .withEnforceCertificateNameCheck(EnforceCertificateNameCheckEnabledState.DISABLED)
                        .withSendRecvTimeoutSeconds(538641166))
                .withEnabledState(FrontDoorEnabledState.DISABLED);
        model = BinaryData.fromObject(model).toObject(FrontDoorUpdateParameters.class);
        Assertions.assertEquals("pjmkhfxobbc", model.friendlyName());
        Assertions.assertEquals("zvlvqhjkbegib", model.routingRules().get(0).id());
        Assertions.assertEquals("wtgh", model.routingRules().get(0).name());
        Assertions.assertEquals(RoutingRuleEnabledState.DISABLED, model.routingRules().get(0).enabledState());
        Assertions.assertEquals("wxqpsrknftguvri", model.loadBalancingSettings().get(0).id());
        Assertions.assertEquals("yqcgwrtzjuzgwy", model.loadBalancingSettings().get(0).name());
        Assertions.assertEquals(1258750458, model.loadBalancingSettings().get(0).sampleSize());
        Assertions.assertEquals(1397437100, model.loadBalancingSettings().get(0).successfulSamplesRequired());
        Assertions.assertEquals(1232796575, model.loadBalancingSettings().get(0).additionalLatencyMilliseconds());
        Assertions.assertEquals("peilpjzuaejxdu", model.healthProbeSettings().get(0).id());
        Assertions.assertEquals("vawjvzunlu", model.healthProbeSettings().get(0).name());
        Assertions.assertEquals("rvxdjzlmw", model.healthProbeSettings().get(0).path());
        Assertions.assertEquals(FrontDoorProtocol.HTTPS, model.healthProbeSettings().get(0).protocol());
        Assertions.assertEquals(413444138, model.healthProbeSettings().get(0).intervalInSeconds());
        Assertions
            .assertEquals(FrontDoorHealthProbeMethod.HEAD, model.healthProbeSettings().get(0).healthProbeMethod());
        Assertions.assertEquals(HealthProbeEnabled.ENABLED, model.healthProbeSettings().get(0).enabledState());
        Assertions.assertEquals("jpkiidzyexznelix", model.backendPools().get(0).id());
        Assertions.assertEquals("yjsflhhcaalnji", model.backendPools().get(0).name());
        Assertions.assertEquals("itxmedjvcslynqww", model.frontendEndpoints().get(0).id());
        Assertions.assertEquals("nyiropuhpi", model.frontendEndpoints().get(0).name());
        Assertions.assertEquals("knalaulppg", model.frontendEndpoints().get(0).hostname());
        Assertions
            .assertEquals(
                SessionAffinityEnabledState.DISABLED, model.frontendEndpoints().get(0).sessionAffinityEnabledState());
        Assertions.assertEquals(1767174247, model.frontendEndpoints().get(0).sessionAffinityTtlSeconds());
        Assertions
            .assertEquals(
                EnforceCertificateNameCheckEnabledState.DISABLED,
                model.backendPoolsSettings().enforceCertificateNameCheck());
        Assertions.assertEquals(538641166, model.backendPoolsSettings().sendRecvTimeoutSeconds());
        Assertions.assertEquals(FrontDoorEnabledState.DISABLED, model.enabledState());
    }
}
