// 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.fluent.models.BackendPoolProperties;
import com.azure.resourcemanager.frontdoor.models.Backend;
import com.azure.resourcemanager.frontdoor.models.BackendEnabledState;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class BackendPoolPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        BackendPoolProperties model =
            BinaryData
                .fromString(
                    "{\"resourceState\":\"Disabling\",\"backends\":[{\"address\":\"koievseo\",\"privateLinkAlias\":\"q\",\"privateLinkResourceId\":\"ltmuwlauwzizx\",\"privateLinkLocation\":\"pgcjefuzmuvp\",\"privateEndpointStatus\":\"Disconnected\",\"privateLinkApprovalMessage\":\"um\",\"httpPort\":95905507,\"httpsPort\":360418478,\"enabledState\":\"Disabled\",\"priority\":1702938248,\"weight\":1487228003,\"backendHostHeader\":\"bhjpglkfgohdne\"},{\"address\":\"lfphsdyhtozfikd\",\"privateLinkAlias\":\"wq\",\"privateLinkResourceId\":\"v\",\"privateLinkLocation\":\"xclvit\",\"privateEndpointStatus\":\"Pending\",\"privateLinkApprovalMessage\":\"o\",\"httpPort\":485357732,\"httpsPort\":576344277,\"enabledState\":\"Disabled\",\"priority\":1373872192,\"weight\":1150860999,\"backendHostHeader\":\"dsjnka\"}],\"loadBalancingSettings\":{\"id\":\"tiiswacffg\"},\"healthProbeSettings\":{\"id\":\"zewk\"}}")
                .toObject(BackendPoolProperties.class);
        Assertions.assertEquals("koievseo", model.backends().get(0).address());
        Assertions.assertEquals("q", model.backends().get(0).privateLinkAlias());
        Assertions.assertEquals("ltmuwlauwzizx", model.backends().get(0).privateLinkResourceId());
        Assertions.assertEquals("pgcjefuzmuvp", model.backends().get(0).privateLinkLocation());
        Assertions.assertEquals("um", model.backends().get(0).privateLinkApprovalMessage());
        Assertions.assertEquals(95905507, model.backends().get(0).httpPort());
        Assertions.assertEquals(360418478, model.backends().get(0).httpsPort());
        Assertions.assertEquals(BackendEnabledState.DISABLED, model.backends().get(0).enabledState());
        Assertions.assertEquals(1702938248, model.backends().get(0).priority());
        Assertions.assertEquals(1487228003, model.backends().get(0).weight());
        Assertions.assertEquals("bhjpglkfgohdne", model.backends().get(0).backendHostHeader());
        Assertions.assertEquals("tiiswacffg", model.loadBalancingSettings().id());
        Assertions.assertEquals("zewk", model.healthProbeSettings().id());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        BackendPoolProperties model =
            new BackendPoolProperties()
                .withBackends(
                    Arrays
                        .asList(
                            new Backend()
                                .withAddress("koievseo")
                                .withPrivateLinkAlias("q")
                                .withPrivateLinkResourceId("ltmuwlauwzizx")
                                .withPrivateLinkLocation("pgcjefuzmuvp")
                                .withPrivateLinkApprovalMessage("um")
                                .withHttpPort(95905507)
                                .withHttpsPort(360418478)
                                .withEnabledState(BackendEnabledState.DISABLED)
                                .withPriority(1702938248)
                                .withWeight(1487228003)
                                .withBackendHostHeader("bhjpglkfgohdne"),
                            new Backend()
                                .withAddress("lfphsdyhtozfikd")
                                .withPrivateLinkAlias("wq")
                                .withPrivateLinkResourceId("v")
                                .withPrivateLinkLocation("xclvit")
                                .withPrivateLinkApprovalMessage("o")
                                .withHttpPort(485357732)
                                .withHttpsPort(576344277)
                                .withEnabledState(BackendEnabledState.DISABLED)
                                .withPriority(1373872192)
                                .withWeight(1150860999)
                                .withBackendHostHeader("dsjnka")))
                .withLoadBalancingSettings(new SubResource().withId("tiiswacffg"))
                .withHealthProbeSettings(new SubResource().withId("zewk"));
        model = BinaryData.fromObject(model).toObject(BackendPoolProperties.class);
        Assertions.assertEquals("koievseo", model.backends().get(0).address());
        Assertions.assertEquals("q", model.backends().get(0).privateLinkAlias());
        Assertions.assertEquals("ltmuwlauwzizx", model.backends().get(0).privateLinkResourceId());
        Assertions.assertEquals("pgcjefuzmuvp", model.backends().get(0).privateLinkLocation());
        Assertions.assertEquals("um", model.backends().get(0).privateLinkApprovalMessage());
        Assertions.assertEquals(95905507, model.backends().get(0).httpPort());
        Assertions.assertEquals(360418478, model.backends().get(0).httpsPort());
        Assertions.assertEquals(BackendEnabledState.DISABLED, model.backends().get(0).enabledState());
        Assertions.assertEquals(1702938248, model.backends().get(0).priority());
        Assertions.assertEquals(1487228003, model.backends().get(0).weight());
        Assertions.assertEquals("bhjpglkfgohdne", model.backends().get(0).backendHostHeader());
        Assertions.assertEquals("tiiswacffg", model.loadBalancingSettings().id());
        Assertions.assertEquals("zewk", model.healthProbeSettings().id());
    }
}
