// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.resourcemover.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.resourcemover.models.LBBackendAddressPoolResourceSettings;
import com.azure.resourcemanager.resourcemover.models.LBFrontendIpConfigurationResourceSettings;
import com.azure.resourcemanager.resourcemover.models.LoadBalancerResourceSettings;
import com.azure.resourcemanager.resourcemover.models.SubnetReference;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class LoadBalancerResourceSettingsTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        LoadBalancerResourceSettings model =
            BinaryData
                .fromString(
                    "{\"resourceType\":\"Microsoft.Network/loadBalancers\",\"sku\":\"crnwbmeh\",\"frontendIPConfigurations\":[{\"name\":\"v\",\"privateIpAddress\":\"srtslhspkdeem\",\"privateIpAllocationMethod\":\"fm\",\"subnet\":{\"name\":\"kv\",\"sourceArmResourceId\":\"melmqkrha\"},\"zones\":\"ljuahaquhcdh\"},{\"name\":\"ualaexqpvfadmw\",\"privateIpAddress\":\"crgvxpvgom\",\"privateIpAllocationMethod\":\"fmisg\",\"subnet\":{\"name\":\"b\",\"sourceArmResourceId\":\"e\"},\"zones\":\"awkz\"},{\"name\":\"liourqhak\",\"privateIpAddress\":\"hashsfwxosow\",\"privateIpAllocationMethod\":\"cugicjoox\",\"subnet\":{\"name\":\"bwpucwwfvovbv\",\"sourceArmResourceId\":\"euecivyhzceuoj\"},\"zones\":\"rw\"},{\"name\":\"eiotwmcdytdx\",\"privateIpAddress\":\"txnrjaw\",\"privateIpAllocationMethod\":\"wgxhn\",\"subnet\":{\"name\":\"x\",\"sourceArmResourceId\":\"bkpyc\"},\"zones\":\"lwn\"}],\"backendAddressPools\":[{\"name\":\"dauwhvylwzbtd\"},{\"name\":\"ujznb\"},{\"name\":\"ow\"}],\"zones\":\"przqlveu\",\"targetResourceName\":\"lupj\"}")
                .toObject(LoadBalancerResourceSettings.class);
        Assertions.assertEquals("lupj", model.targetResourceName());
        Assertions.assertEquals("crnwbmeh", model.sku());
        Assertions.assertEquals("v", model.frontendIpConfigurations().get(0).name());
        Assertions.assertEquals("srtslhspkdeem", model.frontendIpConfigurations().get(0).privateIpAddress());
        Assertions.assertEquals("fm", model.frontendIpConfigurations().get(0).privateIpAllocationMethod());
        Assertions.assertEquals("melmqkrha", model.frontendIpConfigurations().get(0).subnet().sourceArmResourceId());
        Assertions.assertEquals("kv", model.frontendIpConfigurations().get(0).subnet().name());
        Assertions.assertEquals("ljuahaquhcdh", model.frontendIpConfigurations().get(0).zones());
        Assertions.assertEquals("dauwhvylwzbtd", model.backendAddressPools().get(0).name());
        Assertions.assertEquals("przqlveu", model.zones());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        LoadBalancerResourceSettings model =
            new LoadBalancerResourceSettings()
                .withTargetResourceName("lupj")
                .withSku("crnwbmeh")
                .withFrontendIpConfigurations(
                    Arrays
                        .asList(
                            new LBFrontendIpConfigurationResourceSettings()
                                .withName("v")
                                .withPrivateIpAddress("srtslhspkdeem")
                                .withPrivateIpAllocationMethod("fm")
                                .withSubnet(new SubnetReference().withSourceArmResourceId("melmqkrha").withName("kv"))
                                .withZones("ljuahaquhcdh"),
                            new LBFrontendIpConfigurationResourceSettings()
                                .withName("ualaexqpvfadmw")
                                .withPrivateIpAddress("crgvxpvgom")
                                .withPrivateIpAllocationMethod("fmisg")
                                .withSubnet(new SubnetReference().withSourceArmResourceId("e").withName("b"))
                                .withZones("awkz"),
                            new LBFrontendIpConfigurationResourceSettings()
                                .withName("liourqhak")
                                .withPrivateIpAddress("hashsfwxosow")
                                .withPrivateIpAllocationMethod("cugicjoox")
                                .withSubnet(
                                    new SubnetReference()
                                        .withSourceArmResourceId("euecivyhzceuoj")
                                        .withName("bwpucwwfvovbv"))
                                .withZones("rw"),
                            new LBFrontendIpConfigurationResourceSettings()
                                .withName("eiotwmcdytdx")
                                .withPrivateIpAddress("txnrjaw")
                                .withPrivateIpAllocationMethod("wgxhn")
                                .withSubnet(new SubnetReference().withSourceArmResourceId("bkpyc").withName("x"))
                                .withZones("lwn")))
                .withBackendAddressPools(
                    Arrays
                        .asList(
                            new LBBackendAddressPoolResourceSettings().withName("dauwhvylwzbtd"),
                            new LBBackendAddressPoolResourceSettings().withName("ujznb"),
                            new LBBackendAddressPoolResourceSettings().withName("ow")))
                .withZones("przqlveu");
        model = BinaryData.fromObject(model).toObject(LoadBalancerResourceSettings.class);
        Assertions.assertEquals("lupj", model.targetResourceName());
        Assertions.assertEquals("crnwbmeh", model.sku());
        Assertions.assertEquals("v", model.frontendIpConfigurations().get(0).name());
        Assertions.assertEquals("srtslhspkdeem", model.frontendIpConfigurations().get(0).privateIpAddress());
        Assertions.assertEquals("fm", model.frontendIpConfigurations().get(0).privateIpAllocationMethod());
        Assertions.assertEquals("melmqkrha", model.frontendIpConfigurations().get(0).subnet().sourceArmResourceId());
        Assertions.assertEquals("kv", model.frontendIpConfigurations().get(0).subnet().name());
        Assertions.assertEquals("ljuahaquhcdh", model.frontendIpConfigurations().get(0).zones());
        Assertions.assertEquals("dauwhvylwzbtd", model.backendAddressPools().get(0).name());
        Assertions.assertEquals("przqlveu", model.zones());
    }
}
