// 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.FrontDoorProtocol;
import com.azure.resourcemanager.frontdoor.models.RouteConfiguration;
import com.azure.resourcemanager.frontdoor.models.RoutingRule;
import com.azure.resourcemanager.frontdoor.models.RoutingRuleEnabledState;
import com.azure.resourcemanager.frontdoor.models.RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class RoutingRuleTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RoutingRule model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"resourceState\":\"Disabling\",\"frontendEndpoints\":[{\"id\":\"cnapkteoell\"},{\"id\":\"tfdygpfqb\"},{\"id\":\"ceopzfqrhhuaopp\"}],\"acceptedProtocols\":[\"Http\",\"Https\"],\"patternsToMatch\":[\"lzdahzxctobgbkdm\"],\"enabledState\":\"Disabled\",\"routeConfiguration\":{\"@odata.type\":\"RouteConfiguration\"},\"rulesEngine\":{\"id\":\"tmgrcfbun\"},\"webApplicationFirewallPolicyLink\":{\"id\":\"qjhhkxbpv\"}},\"name\":\"mjh\",\"type\":\"j\",\"id\":\"gudivkrtswbxqz\"}")
                .toObject(RoutingRule.class);
        Assertions.assertEquals("gudivkrtswbxqz", model.id());
        Assertions.assertEquals("mjh", model.name());
        Assertions.assertEquals("cnapkteoell", model.frontendEndpoints().get(0).id());
        Assertions.assertEquals(FrontDoorProtocol.HTTP, model.acceptedProtocols().get(0));
        Assertions.assertEquals("lzdahzxctobgbkdm", model.patternsToMatch().get(0));
        Assertions.assertEquals(RoutingRuleEnabledState.DISABLED, model.enabledState());
        Assertions.assertEquals("tmgrcfbun", model.rulesEngine().id());
        Assertions.assertEquals("qjhhkxbpv", model.webApplicationFirewallPolicyLink().id());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RoutingRule model =
            new RoutingRule()
                .withId("gudivkrtswbxqz")
                .withName("mjh")
                .withFrontendEndpoints(
                    Arrays
                        .asList(
                            new SubResource().withId("cnapkteoell"),
                            new SubResource().withId("tfdygpfqb"),
                            new SubResource().withId("ceopzfqrhhuaopp")))
                .withAcceptedProtocols(Arrays.asList(FrontDoorProtocol.HTTP, FrontDoorProtocol.HTTPS))
                .withPatternsToMatch(Arrays.asList("lzdahzxctobgbkdm"))
                .withEnabledState(RoutingRuleEnabledState.DISABLED)
                .withRouteConfiguration(new RouteConfiguration())
                .withRulesEngine(new SubResource().withId("tmgrcfbun"))
                .withWebApplicationFirewallPolicyLink(
                    new RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink().withId("qjhhkxbpv"));
        model = BinaryData.fromObject(model).toObject(RoutingRule.class);
        Assertions.assertEquals("gudivkrtswbxqz", model.id());
        Assertions.assertEquals("mjh", model.name());
        Assertions.assertEquals("cnapkteoell", model.frontendEndpoints().get(0).id());
        Assertions.assertEquals(FrontDoorProtocol.HTTP, model.acceptedProtocols().get(0));
        Assertions.assertEquals("lzdahzxctobgbkdm", model.patternsToMatch().get(0));
        Assertions.assertEquals(RoutingRuleEnabledState.DISABLED, model.enabledState());
        Assertions.assertEquals("tmgrcfbun", model.rulesEngine().id());
        Assertions.assertEquals("qjhhkxbpv", model.webApplicationFirewallPolicyLink().id());
    }
}
