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

public final class RoutingRuleUpdateParametersTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RoutingRuleUpdateParameters model =
            BinaryData
                .fromString(
                    "{\"frontendEndpoints\":[{\"id\":\"v\"}],\"acceptedProtocols\":[\"Https\",\"Https\",\"Https\",\"Http\"],\"patternsToMatch\":[\"cgjbirxbp\",\"bsrfbj\",\"dtws\"],\"enabledState\":\"Enabled\",\"routeConfiguration\":{\"@odata.type\":\"RouteConfiguration\"},\"rulesEngine\":{\"id\":\"vjz\"},\"webApplicationFirewallPolicyLink\":{\"id\":\"ilzznfqqnvwp\"}}")
                .toObject(RoutingRuleUpdateParameters.class);
        Assertions.assertEquals("v", model.frontendEndpoints().get(0).id());
        Assertions.assertEquals(FrontDoorProtocol.HTTPS, model.acceptedProtocols().get(0));
        Assertions.assertEquals("cgjbirxbp", model.patternsToMatch().get(0));
        Assertions.assertEquals(RoutingRuleEnabledState.ENABLED, model.enabledState());
        Assertions.assertEquals("vjz", model.rulesEngine().id());
        Assertions.assertEquals("ilzznfqqnvwp", model.webApplicationFirewallPolicyLink().id());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RoutingRuleUpdateParameters model =
            new RoutingRuleUpdateParameters()
                .withFrontendEndpoints(Arrays.asList(new SubResource().withId("v")))
                .withAcceptedProtocols(
                    Arrays
                        .asList(
                            FrontDoorProtocol.HTTPS,
                            FrontDoorProtocol.HTTPS,
                            FrontDoorProtocol.HTTPS,
                            FrontDoorProtocol.HTTP))
                .withPatternsToMatch(Arrays.asList("cgjbirxbp", "bsrfbj", "dtws"))
                .withEnabledState(RoutingRuleEnabledState.ENABLED)
                .withRouteConfiguration(new RouteConfiguration())
                .withRulesEngine(new SubResource().withId("vjz"))
                .withWebApplicationFirewallPolicyLink(
                    new RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink().withId("ilzznfqqnvwp"));
        model = BinaryData.fromObject(model).toObject(RoutingRuleUpdateParameters.class);
        Assertions.assertEquals("v", model.frontendEndpoints().get(0).id());
        Assertions.assertEquals(FrontDoorProtocol.HTTPS, model.acceptedProtocols().get(0));
        Assertions.assertEquals("cgjbirxbp", model.patternsToMatch().get(0));
        Assertions.assertEquals(RoutingRuleEnabledState.ENABLED, model.enabledState());
        Assertions.assertEquals("vjz", model.rulesEngine().id());
        Assertions.assertEquals("ilzznfqqnvwp", model.webApplicationFirewallPolicyLink().id());
    }
}
