// 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.management.SubResource;
import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.frontdoor.models.CacheConfiguration;
import com.azure.resourcemanager.frontdoor.models.DynamicCompressionEnabled;
import com.azure.resourcemanager.frontdoor.models.ForwardingConfiguration;
import com.azure.resourcemanager.frontdoor.models.FrontDoorForwardingProtocol;
import com.azure.resourcemanager.frontdoor.models.FrontDoorQuery;
import java.time.Duration;
import org.junit.jupiter.api.Assertions;

public final class ForwardingConfigurationTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ForwardingConfiguration model =
            BinaryData
                .fromString(
                    "{\"@odata.type\":\"#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration\",\"customForwardingPath\":\"zphv\",\"forwardingProtocol\":\"MatchRequest\",\"cacheConfiguration\":{\"queryParameterStripDirective\":\"StripNone\",\"queryParameters\":\"ygupkv\",\"dynamicCompression\":\"Disabled\",\"cacheDuration\":\"PT106H24M9S\"},\"backendPool\":{\"id\":\"xqupevzhf\"}}")
                .toObject(ForwardingConfiguration.class);
        Assertions.assertEquals("zphv", model.customForwardingPath());
        Assertions.assertEquals(FrontDoorForwardingProtocol.MATCH_REQUEST, model.forwardingProtocol());
        Assertions.assertEquals(FrontDoorQuery.STRIP_NONE, model.cacheConfiguration().queryParameterStripDirective());
        Assertions.assertEquals("ygupkv", model.cacheConfiguration().queryParameters());
        Assertions.assertEquals(DynamicCompressionEnabled.DISABLED, model.cacheConfiguration().dynamicCompression());
        Assertions.assertEquals(Duration.parse("PT106H24M9S"), model.cacheConfiguration().cacheDuration());
        Assertions.assertEquals("xqupevzhf", model.backendPool().id());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ForwardingConfiguration model =
            new ForwardingConfiguration()
                .withCustomForwardingPath("zphv")
                .withForwardingProtocol(FrontDoorForwardingProtocol.MATCH_REQUEST)
                .withCacheConfiguration(
                    new CacheConfiguration()
                        .withQueryParameterStripDirective(FrontDoorQuery.STRIP_NONE)
                        .withQueryParameters("ygupkv")
                        .withDynamicCompression(DynamicCompressionEnabled.DISABLED)
                        .withCacheDuration(Duration.parse("PT106H24M9S")))
                .withBackendPool(new SubResource().withId("xqupevzhf"));
        model = BinaryData.fromObject(model).toObject(ForwardingConfiguration.class);
        Assertions.assertEquals("zphv", model.customForwardingPath());
        Assertions.assertEquals(FrontDoorForwardingProtocol.MATCH_REQUEST, model.forwardingProtocol());
        Assertions.assertEquals(FrontDoorQuery.STRIP_NONE, model.cacheConfiguration().queryParameterStripDirective());
        Assertions.assertEquals("ygupkv", model.cacheConfiguration().queryParameters());
        Assertions.assertEquals(DynamicCompressionEnabled.DISABLED, model.cacheConfiguration().dynamicCompression());
        Assertions.assertEquals(Duration.parse("PT106H24M9S"), model.cacheConfiguration().cacheDuration());
        Assertions.assertEquals("xqupevzhf", model.backendPool().id());
    }
}
