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

public final class BackendPoolTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        BackendPool model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"resourceState\":\"Migrating\",\"backends\":[{\"address\":\"hzdxssadbzm\",\"privateLinkAlias\":\"dfznudaodv\",\"privateLinkResourceId\":\"bncblylpstdbhhx\",\"privateLinkLocation\":\"zdzucerscdntnevf\",\"privateEndpointStatus\":\"Pending\",\"privateLinkApprovalMessage\":\"ygtdsslswt\",\"httpPort\":478767297,\"httpsPort\":815719095,\"enabledState\":\"Enabled\",\"priority\":893686819,\"weight\":158092972,\"backendHostHeader\":\"emwabnet\"},{\"address\":\"hszhedplvwiwu\",\"privateLinkAlias\":\"wmbesldnkw\",\"privateLinkResourceId\":\"pp\",\"privateLinkLocation\":\"lcxog\",\"privateEndpointStatus\":\"Pending\",\"privateLinkApprovalMessage\":\"nzmnsikvm\",\"httpPort\":517153396,\"httpsPort\":1984679669,\"enabledState\":\"Disabled\",\"priority\":52302074,\"weight\":1896660287,\"backendHostHeader\":\"xmhhvhgureo\"}],\"loadBalancingSettings\":{\"id\":\"obdagxtibqdxb\"},\"healthProbeSettings\":{\"id\":\"kbogqxndlkzgx\"}},\"name\":\"ripl\",\"type\":\"odxun\",\"id\":\"ebxmubyynt\"}")
                .toObject(BackendPool.class);
        Assertions.assertEquals("ebxmubyynt", model.id());
        Assertions.assertEquals("ripl", model.name());
        Assertions.assertEquals("hzdxssadbzm", model.backends().get(0).address());
        Assertions.assertEquals("dfznudaodv", model.backends().get(0).privateLinkAlias());
        Assertions.assertEquals("bncblylpstdbhhx", model.backends().get(0).privateLinkResourceId());
        Assertions.assertEquals("zdzucerscdntnevf", model.backends().get(0).privateLinkLocation());
        Assertions.assertEquals("ygtdsslswt", model.backends().get(0).privateLinkApprovalMessage());
        Assertions.assertEquals(478767297, model.backends().get(0).httpPort());
        Assertions.assertEquals(815719095, model.backends().get(0).httpsPort());
        Assertions.assertEquals(BackendEnabledState.ENABLED, model.backends().get(0).enabledState());
        Assertions.assertEquals(893686819, model.backends().get(0).priority());
        Assertions.assertEquals(158092972, model.backends().get(0).weight());
        Assertions.assertEquals("emwabnet", model.backends().get(0).backendHostHeader());
        Assertions.assertEquals("obdagxtibqdxb", model.loadBalancingSettings().id());
        Assertions.assertEquals("kbogqxndlkzgx", model.healthProbeSettings().id());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        BackendPool model =
            new BackendPool()
                .withId("ebxmubyynt")
                .withName("ripl")
                .withBackends(
                    Arrays
                        .asList(
                            new Backend()
                                .withAddress("hzdxssadbzm")
                                .withPrivateLinkAlias("dfznudaodv")
                                .withPrivateLinkResourceId("bncblylpstdbhhx")
                                .withPrivateLinkLocation("zdzucerscdntnevf")
                                .withPrivateLinkApprovalMessage("ygtdsslswt")
                                .withHttpPort(478767297)
                                .withHttpsPort(815719095)
                                .withEnabledState(BackendEnabledState.ENABLED)
                                .withPriority(893686819)
                                .withWeight(158092972)
                                .withBackendHostHeader("emwabnet"),
                            new Backend()
                                .withAddress("hszhedplvwiwu")
                                .withPrivateLinkAlias("wmbesldnkw")
                                .withPrivateLinkResourceId("pp")
                                .withPrivateLinkLocation("lcxog")
                                .withPrivateLinkApprovalMessage("nzmnsikvm")
                                .withHttpPort(517153396)
                                .withHttpsPort(1984679669)
                                .withEnabledState(BackendEnabledState.DISABLED)
                                .withPriority(52302074)
                                .withWeight(1896660287)
                                .withBackendHostHeader("xmhhvhgureo")))
                .withLoadBalancingSettings(new SubResource().withId("obdagxtibqdxb"))
                .withHealthProbeSettings(new SubResource().withId("kbogqxndlkzgx"));
        model = BinaryData.fromObject(model).toObject(BackendPool.class);
        Assertions.assertEquals("ebxmubyynt", model.id());
        Assertions.assertEquals("ripl", model.name());
        Assertions.assertEquals("hzdxssadbzm", model.backends().get(0).address());
        Assertions.assertEquals("dfznudaodv", model.backends().get(0).privateLinkAlias());
        Assertions.assertEquals("bncblylpstdbhhx", model.backends().get(0).privateLinkResourceId());
        Assertions.assertEquals("zdzucerscdntnevf", model.backends().get(0).privateLinkLocation());
        Assertions.assertEquals("ygtdsslswt", model.backends().get(0).privateLinkApprovalMessage());
        Assertions.assertEquals(478767297, model.backends().get(0).httpPort());
        Assertions.assertEquals(815719095, model.backends().get(0).httpsPort());
        Assertions.assertEquals(BackendEnabledState.ENABLED, model.backends().get(0).enabledState());
        Assertions.assertEquals(893686819, model.backends().get(0).priority());
        Assertions.assertEquals(158092972, model.backends().get(0).weight());
        Assertions.assertEquals("emwabnet", model.backends().get(0).backendHostHeader());
        Assertions.assertEquals("obdagxtibqdxb", model.loadBalancingSettings().id());
        Assertions.assertEquals("kbogqxndlkzgx", model.healthProbeSettings().id());
    }
}
